Skip to content

breaking on unknown lifetime #43591

Closed
Closed
@sampersand

Description

@sampersand

I was poking around with lifetimes and break statements when I came across this bug:

fn main() {
   loop {
      break 'a ()
   }
}

I just expected it to complain that 'a was an undeclared liftime. However, it spit out an internal compiler error:

   Compiling test v0.4.0 (file:///tests/src/main.rs)
error[E0426]: use of undeclared label `'a`
  --> src/main.rs:3:13
  |
3 |       break 'a ()
  |             ^^ undeclared label `'a`

error: internal compiler error: src/librustc_typeck/check/mod.rs:1984: no type for node 8: expr () (id=8) in fcx 0x700006bdab28

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.20.0-nightly (b2c070787 2017-07-13) running on x86_64-apple-darwin

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:489:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `tests`.

Version

rustc --version --verbose yields:

rustc 1.20.0-nightly (b2c070787 2017-07-13)
binary: rustc
commit-hash: b2c0707872082c890f332178f59fd02eea5b98f3
commit-date: 2017-07-13
host: x86_64-apple-darwin
release: 1.20.0-nightly
LLVM version: 4.0

Backtrace

   Compiling test v0.4.0 (file:///tests/src/main.rs)
error[E0426]: use of undeclared label `'a`
  --> src/main.rs:3:13
  |
3 |       break 'a ()
  |             ^^ undeclared label `'a`

error: internal compiler error: src/librustc_typeck/check/mod.rs:1984: no type for node 8: expr () (id=8) in fcx 0x70000fd92b28

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.20.0-nightly (b2c070787 2017-07-13) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:489:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic_new
   5: rustc_errors::Handler::bug
   6: rustc::session::opt_span_bug_fmt::{{closure}}
   7: rustc::session::opt_span_bug_fmt
   8: rustc::session::bug_fmt
   9: rustc_typeck::check::FnCtxt::node_ty
  10: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  11: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  12: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  13: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_expr
  14: rustc_typeck::check::regionck::RegionCtxt::visit_fn_body
  15: rustc_typeck::check::typeck_tables_of::{{closure}}
  16: rustc_typeck::check::typeck_tables_of
  17: rustc::dep_graph::graph::DepGraph::with_task
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  19: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  20: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  21: rustc_typeck::check::typeck_item_bodies
  22: rustc::dep_graph::graph::DepGraph::with_task
  23: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  24: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  25: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  26: rustc_typeck::check_crate
  27: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  28: rustc_driver::driver::phase_3_run_analysis_passes
  29: rustc_driver::driver::compile_input
  30: rustc_driver::run_compiler

error: Could not compile `tests`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions