Skip to content
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

Compiler unexpectedly panicked - pattern matching to set const #38199

Closed
callicles opened this issue Dec 6, 2016 · 0 comments · Fixed by #41055
Closed

Compiler unexpectedly panicked - pattern matching to set const #38199

callicles opened this issue Dec 6, 2016 · 0 comments · Fixed by #41055
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@callicles
Copy link

callicles commented Dec 6, 2016

I am setting a const on runtime (probably a bad idea)

I tried this code:

const DEV_MODE: bool = match env::var("GITLINKS_DEV_MODE") {
     Ok(something) => true,
     Err(e) => false
};

This is easily reproducible in the rust-playground:

I expected to see this happen: Compilation/error

Instead, this happened: The compiler panicked

   Compiling hermes-rust-ci v0.1.0 (file:///Users/nicolas/Code/Gitlinks/hermes-rust-ci)
error: internal compiler error: ../src/librustc_typeck/check/dropck.rs:275: no enclosing scope found for scope: CodeExtent(928/Misc(NodeId(89)))
  --> src/main.rs:47:12
   |
47 |         Ok(something) => true,
   |            ^^^^^^^^^

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: run with `RUST_BACKTRACE=1` for a backtrace

Meta

rustc --version --verbose:

rustc 1.13.0 (2c6933acc 2016-11-07)
binary: rustc
commit-hash: 2c6933acc05c61e041be764cb1331f6281993f3f
commit-date: 2016-11-07
host: x86_64-apple-darwin
release: 1.13.0

Backtrace:

   1:        0x10c378138 - std::sys::backtrace::tracing::imp::write::h6f1d53a70916b90d
   2:        0x10c3858ff - std::panicking::default_hook::{{closure}}::h137e876f7d3b5850
   3:        0x10c382dad - std::panicking::default_hook::h0ac3811ec7cee78c
   4:        0x10c383446 - std::panicking::rust_panic_with_hook::hc303199e04562edf
   5:        0x108f7702b - std::panicking::begin_panic::hf3c77cb5fd5814c4
   6:        0x1090a1ba3 - rustc::session::opt_span_bug_fmt::{{closure}}::hf0e25c590c479ec5
   7:        0x108fbc6e9 - rustc::session::span_bug_fmt::h42d4c0a219d5e4ec
   8:        0x108fe1b5b - rustc_typeck::check::dropck::check_safety_of_destructor_if_necessary::hb235377900186746
   9:        0x108fb4ede - rustc::hir::Pat::walk_::h4efc10712dfc4116
  10:        0x108fb500e - rustc::hir::Pat::walk_::h4efc10712dfc4116
  11:        0x108fb46dc - rustc::hir::intravisit::walk_expr::he86193ca4385dfe8
  12:        0x108ff5597 - <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_expr::h8c3b7edd059225ea
  13:        0x108ff1dd0 - rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_expr::hea9fefa930b3b048
  14:        0x10903d8d0 - rustc_typeck::check::check_const_with_type::hde9362004e8817d1
  15:        0x109037bc5 - rustc_typeck::check::check_item_type::h465806f7c36cce01
  16:        0x109031a8e - <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::h232a101fa871d7c6
  17:        0x1090336d1 - rustc_typeck::check::check_item_types::h051b17d53935a164
  18:        0x10909d7a7 - rustc_typeck::check_crate::h54ff5b2dd08c0691
  19:        0x1087f070c - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h4091eeab6f271a29
  20:        0x1087cc956 - rustc_driver::driver::phase_3_run_analysis_passes::hff1c31d493acfd09
  21:        0x1087ba76a - rustc_driver::driver::compile_input::hef221f9f618e92f5
  22:        0x1087e2848 - rustc_driver::run_compiler::h7dddd4089f8330b4
  23:        0x108724340 - std::panicking::try::do_call::h1e3ece12e3f812df
  24:        0x10c385eba - __rust_maybe_catch_panic
  25:        0x108743004 - <F as alloc::boxed::FnBox<A>>::call_box::h05b222e46803eb30
  26:        0x10c382064 - std::sys::thread::Thread::new::thread_start::h759e10bc4abc7e72
  27:     0x7fffd1eb3aaa - _pthread_body
  28:     0x7fffd1eb39f6 - _pthread_start
@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 28, 2016
ryan-scott-dev pushed a commit to ryan-scott-dev/rust that referenced this issue Apr 4, 2017
bors added a commit that referenced this issue Apr 8, 2017
…, r=arielb1

Fixed ICEs with pattern matching in const expression

Fixed 2 ICEs with when pattern matching inside a constant expression.

Both of these ICEs now resolve to an appropriate compiler error.

1. ICE was caused by a compiler bug to implement discriminant const qualify.

    I removed this intentionally thrown bug and changed it to a FIXME as the unimplemented expression type is handled as a compiler error elsewhere.

2. ICE was caused during a drop check when checking if a variable lifetime outlives the current scope if there was no parent scope .

    I've changed it to stop checking if there is no parent scope for the current scope. It is valid syntax for a const variable to be assigned a match expression with no enclosing scope.

    The ICE seemed to mainly be used as a defensive check for bugs elsewhere.

Fixes #38199.
Fixes #31577.
Fixes #29093.
Fixes #40012.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants