Skip to content

Compiler unexpectedly panicked - pattern matching to set const #38199

Closed
@callicles

Description

@callicles

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions