Skip to content

Unclosed parentheses causes panic #49148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tuomas56 opened this issue Mar 18, 2018 · 2 comments
Closed

Unclosed parentheses causes panic #49148

tuomas56 opened this issue Mar 18, 2018 · 2 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tuomas56
Copy link

When attempting to compile this expression, the compiler panics. If the parentheses are fixed, there is no panic:

a(b[c

Many variations on this also cause the same panic, for instance a(b[c), a(b[c, e, f);, a(b[c as d); etc. It also happens when the symbols are actually defined and when they are more complex expressions, i.e:

ptr::copy(&(*self.ptr)[self.length as *const T, &mut res as *mut T, 1);

Where I originally found it. The compiler reports the error:

error: incorrect close delimiter: `)`
   --> src/heap.rs:199:86
    |
199 |                 ptr::copy(&(*self.ptr)[self.length as *const T, &mut res as *mut T, 1);
    |                                                                                      ^
    |
note: unclosed delimiter
   --> src/heap.rs:199:39
    |
199 |                 ptr::copy(&(*self.ptr)[self.length as *const T, &mut res as *mut T, 1);
    |                                       ^

error: expected one of `!`, `(`, `::`, `<`, or `]`, found `,`
   --> src/heap.rs:199:63
    |
199 |                 ptr::copy(&(*self.ptr)[self.length as *const T, &mut res as *mut T, 1);
    |                                                               ^ expected one of `!`, `(`, `::`, `<`, or `]` here

And then panics:

error: internal compiler error: librustc/ich/impls_ty.rs:906: ty::TypeVariants::hash_stable() - Unexpected variant TyInfer(?0).

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:543:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:207
   3: std::panicking::default_hook
             at libstd/panicking.rs:223
   4: core::ops::function::Fn::call
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:403
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::session::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: <std::thread::local::LocalKey<T>>::try_with
  11: <std::thread::local::LocalKey<T>>::with
  12: rustc::ty::context::tls::with
  13: rustc::ty::context::tls::with_opt
  14: rustc::session::opt_span_bug_fmt
  15: rustc::session::bug_fmt
  16: rustc::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc::ich::hcx::StableHashingContext<'a>> for rustc::ty::sty::TypeVariants<'gcx>>::hash_stable
  17: <T as rustc::dep_graph::dep_node::DepNodeParams<'a, 'gcx, 'tcx>>::to_fingerprint
  18: rustc::dep_graph::dep_node::DepNode::new
  19: rustc::ty::maps::<impl rustc::ty::maps::queries::dropck_outlives<'tcx>>::try_get
  20: rustc::ty::maps::TyCtxtAt::dropck_outlives
  21: rustc::traits::query::dropck_outlives::<impl rustc::infer::at::At<'cx, 'gcx, 'tcx>>::dropck_outlives
  22: rustc_typeck::check::dropck::check_safety_of_destructor_if_necessary
  23: rustc::hir::Pat::walk_
  24: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_local
  25: rustc::hir::intravisit::walk_expr
  26: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  27: rustc::hir::intravisit::walk_expr
  28: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  29: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  30: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  31: rustc_typeck::check::regionck::RegionCtxt::visit_fn_body
  32: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_fn
  33: rustc::ty::context::tls::enter
  34: rustc::infer::InferCtxtBuilder::enter
  35: rustc_typeck::check::typeck_tables_of
  36: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::compute_result
  37: rustc::dep_graph::graph::DepGraph::with_task_impl
  38: rustc_errors::Handler::track_diagnostics
  39: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  40: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force
  41: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  42: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  43: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
  44: rustc::session::Session::track_errors
  45: rustc_typeck::check::typeck_item_bodies
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc_errors::Handler::track_diagnostics
  48: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  49: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::force
  50: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  51: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  52: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  53: rustc_typeck::check_crate
  54: <std::thread::local::LocalKey<T>>::with
  55: <std::thread::local::LocalKey<T>>::with
  56: rustc::ty::context::TyCtxt::create_and_enter
  57: rustc_driver::driver::compile_input
  58: rustc_driver::run_compiler_impl
  59: syntax::with_globals

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.26.0-nightly (adf2135ad 2018-03-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type staticlib

note: some of the compiler flags provided by cargo are hidden
@tuomas56 tuomas56 changed the title Unclosed Parentheses Causes Panic in rustc unclosed parentheses causes panic Mar 18, 2018
@tuomas56 tuomas56 changed the title unclosed parentheses causes panic Unclosed parentheses causes panic Mar 18, 2018
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 18, 2018
@sapphire-arches sapphire-arches added the C-bug Category: This is a bug. label Mar 19, 2018
@estebank
Copy link
Contributor

I'm unable to repro on stable, beta or nightly. Are you still seeing the ICE?

@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 22, 2018
@kolmodin
Copy link

kolmodin commented Jan 3, 2019

Unable to repro.

$ rustc --version
rustc 1.31.1 (b6c32da9b 2018-12-18)

$ cat rust-issue-49148.rs 
fn a(n: int) {}

fn main() {
  let b = vec![];
  let c = 0;
  a(b[c;
}

$ rustc rust-issue-49148.rs 
$ rustc rust-issue-49148.rs 
error: incorrect close delimiter: `}`
 --> rust-issue-49148.rs:7:1
  |
3 | fn main() {
  |           - close delimiter possibly meant for this
...
6 |   a(b[c;
  |      - un-closed delimiter
7 | }
  | ^ incorrect close delimiter

error: expected one of `!`, `.`, `::`, `?`, `]`, `{`, or an operator, found `;`
 --> rust-issue-49148.rs:6:8
  |
6 |   a(b[c;
  |        ^ expected one of 7 possible tokens here

error[E0412]: cannot find type `int` in this scope
 --> rust-issue-49148.rs:1:9
  |
1 | fn a(n: int) {}
  |         ^^^ not found in this scope

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0412`.

@tuomas56 tuomas56 closed this as completed Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants