Skip to content

error: internal compiler error: librustc_mir/hair/cx/expr.rs:544: invalid loop id for break: label not found #50576

Closed
@vegard

Description

@vegard

Input:

fn main() {
    |bool: [u8; break 'L]| 0;
}

Output:

$ rustc -
error[E0426]: use of undeclared label `'L`
 --> <anon>:2:23
  |
2 |     |bool: [u8; break 'L]| 0;
  |                       ^^ undeclared label `'L`

error: internal compiler error: librustc_mir/hair/cx/expr.rs:544: invalid loop id for break: label not found

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
...
  13: rustc::session::bug_fmt
             at librustc/session/mod.rs:1256
  14: rustc_mir::hair::cx::expr::make_mirror_unadjusted
             at librustc_mir/hair/cx/expr.rs:544
  15: rustc_mir::hair::cx::expr::<impl rustc_mir::hair::Mirror<'tcx> for &'tcx rustc::hir::Expr>::make_mirror
             at librustc_mir/hair/cx/expr.rs:35
  16: rustc_mir::build::mir_build::{{closure}}
             at librustc_mir/hair/cx/mod.rs:111
             at librustc_mir/build/mod.rs:577
             at librustc_mir/build/mod.rs:145
...
Complete output
$ rustc -
error[E0426]: use of undeclared label `'L`
 --> <anon>:2:23
  |
2 |     |bool: [u8; break 'L]| 0;
  |                       ^^ undeclared label `'L`

error: internal compiler error: librustc_mir/hair/cx/expr.rs:544: invalid loop id for break: label not found

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
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
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
             at librustc/util/common.rs:54
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:467
   6: std::panicking::begin_panic
             at /home/vegard/rust/src/libstd/panicking.rs:397
   7: rustc_errors::Handler::bug
             at librustc_errors/lib.rs:554
   8: rustc::session::opt_span_bug_fmt::{{closure}}
             at librustc/session/mod.rs:1280
   9: rustc::ty::context::tls::with_opt::{{closure}}
             at librustc/ty/context.rs:1943
  10: rustc::ty::context::tls::with_context_opt
             at librustc/ty/context.rs:1880
  11: rustc::ty::context::tls::with_opt
             at librustc/ty/context.rs:1943
  12: rustc::session::opt_span_bug_fmt
             at librustc/session/mod.rs:1276
  13: rustc::session::bug_fmt
             at librustc/session/mod.rs:1256
  14: rustc_mir::hair::cx::expr::make_mirror_unadjusted
             at librustc_mir/hair/cx/expr.rs:544
  15: rustc_mir::hair::cx::expr::<impl rustc_mir::hair::Mirror<'tcx> for &'tcx rustc::hir::Expr>::make_mirror
             at librustc_mir/hair/cx/expr.rs:35
  16: rustc_mir::build::mir_build::{{closure}}
             at librustc_mir/hair/cx/mod.rs:111
             at librustc_mir/build/mod.rs:577
             at librustc_mir/build/mod.rs:145
  17: rustc_mir::build::mir_build
             at /home/vegard/rust/src/librustc/infer/mod.rs:453
             at /home/vegard/rust/src/librustc/ty/context.rs:1578
             at /home/vegard/rust/src/librustc/ty/context.rs:1844
             at /home/vegard/rust/src/librustc/ty/context.rs:1787
             at /home/vegard/rust/src/librustc/ty/context.rs:1843
             at /home/vegard/rust/src/librustc/ty/context.rs:1577
             at /home/vegard/rust/src/librustc/ty/context.rs:1905
             at /home/vegard/rust/src/librustc/ty/context.rs:1889
             at /home/vegard/rust/src/librustc/ty/context.rs:1880
             at /home/vegard/rust/src/librustc/ty/context.rs:1889
             at /home/vegard/rust/src/librustc/ty/context.rs:1900
             at /home/vegard/rust/src/librustc/ty/context.rs:1570
             at /home/vegard/rust/src/librustc/infer/mod.rs:453
             at librustc_mir/build/mod.rs:87
  18: rustc_mir::transform::mir_built
             at librustc_mir/transform/mod.rs:110
  19: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::mir_built<'tcx>>::compute
             at librustc/ty/maps/plumbing.rs:723
  20: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:343
  21: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  22: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  23: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_built
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
  24: rustc_mir::transform::check_unsafety::unsafety_check_result
             at librustc_mir/transform/check_unsafety.rs:327
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  26: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  27: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  28: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::unsafety_check_result
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
  29: rustc_mir::transform::mir_const
             at librustc_mir/transform/mod.rs:191
  30: rustc::ty::maps::<impl rustc::ty::maps::config::QueryConfig<'tcx> for rustc::ty::maps::queries::mir_const<'tcx>>::compute
             at librustc/ty/maps/plumbing.rs:723
  31: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:343
  32: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  33: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  34: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
  35: rustc_mir::transform::qualify_consts::mir_const_qualif
             at librustc_mir/transform/qualify_consts.rs:1130
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  37: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  38: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  39: rustc_mir::interpret::const_eval::const_eval_provider
             at librustc_mir/interpret/const_eval.rs:459
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  41: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  42: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
  43: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
             at librustc/ty/maps/plumbing.rs:606
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
             at librustc/traits/project.rs:436
  44: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
             at librustc/ty/structural_impls.rs:1176
             at librustc/ty/structural_impls.rs:857
             at librustc/traits/project.rs:346
  45: rustc_typeck::check::Inherited::normalize_associated_types_in
             at /home/vegard/rust/src/librustc/ty/structural_impls.rs:890
             at /home/vegard/rust/src/librustc/traits/project.rs:324
             at /home/vegard/rust/src/librustc/traits/project.rs:283
             at /home/vegard/rust/src/librustc/traits/project.rs:267
             at /home/vegard/rust/src/librustc/infer/mod.rs:1358
             at librustc_typeck/check/mod.rs:677
  46: <rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx> as rustc_typeck::astconv::AstConv<'gcx, 'tcx>>::normalize_ty
             at librustc_typeck/check/mod.rs:2075
             at librustc_typeck/check/mod.rs:1776
  47: <rustc_typeck::astconv::AstConv<'gcx, 'tcx> + 'o>::ast_ty_to_ty
             at librustc_typeck/astconv.rs:1095
  48: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::supplied_sig_of_closure
             at librustc_typeck/check/closure.rs:604
             at /home/vegard/rust/src/libcore/ops/function.rs:271
             at /home/vegard/rust/src/libcore/option.rs:404
             at /home/vegard/rust/src/libcore/iter/mod.rs:1347
             at /home/vegard/rust/src/libcore/iter/mod.rs:814
             at /home/vegard/rust/src/librustc_data_structures/array_vec.rs:197
             at /home/vegard/rust/src/librustc_data_structures/accumulate_vec.rs:113
             at /home/vegard/rust/src/libcore/iter/iterator.rs:1375
             at /home/vegard/rust/src/librustc/ty/context.rs:2729
             at /home/vegard/rust/src/librustc/ty/context.rs:2717
             at /home/vegard/rust/src/librustc/ty/context.rs:2569
             at librustc_typeck/check/closure.rs:610
  49: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::sig_of_closure_no_expectation
             at librustc_typeck/check/closure.rs:379
  50: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_closure
             at librustc_typeck/check/closure.rs:365
             at librustc_typeck/check/closure.rs:88
  51: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/closure.rs:66
             at librustc_typeck/check/mod.rs:3910
  52: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3530
  53: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
             at librustc_typeck/check/mod.rs:2864
             at librustc_typeck/check/mod.rs:2868
             at librustc_typeck/check/mod.rs:4296
             at librustc_typeck/check/mod.rs:4361
  54: rustc_typeck::check::FnCtxt::check_block_with_expected
             at librustc_typeck/check/mod.rs:5070
             at librustc_typeck/check/mod.rs:4359
  55: rustc_typeck::check::FnCtxt::check_expr_kind
             at librustc_typeck/check/mod.rs:3913
  56: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
             at librustc_typeck/check/mod.rs:3530
  57: rustc_typeck::check::FnCtxt::check_return_expr
             at librustc_typeck/check/mod.rs:2864
             at librustc_typeck/check/mod.rs:2858
             at librustc_typeck/check/mod.rs:2996
  58: rustc_typeck::check::check_fn
             at librustc_typeck/check/mod.rs:1081
  59: rustc_typeck::check::typeck_tables_of::{{closure}}
             at librustc_typeck/check/mod.rs:871
  60: rustc_typeck::check::typeck_tables_of
             at librustc_typeck/check/mod.rs:617
             at /home/vegard/rust/src/librustc/infer/mod.rs:453
             at /home/vegard/rust/src/librustc/ty/context.rs:1578
             at /home/vegard/rust/src/librustc/ty/context.rs:1844
             at /home/vegard/rust/src/librustc/ty/context.rs:1787
             at /home/vegard/rust/src/librustc/ty/context.rs:1843
             at /home/vegard/rust/src/librustc/ty/context.rs:1577
             at /home/vegard/rust/src/librustc/ty/context.rs:1905
             at /home/vegard/rust/src/librustc/ty/context.rs:1889
             at /home/vegard/rust/src/librustc/ty/context.rs:1880
             at /home/vegard/rust/src/librustc/ty/context.rs:1889
             at /home/vegard/rust/src/librustc/ty/context.rs:1900
             at /home/vegard/rust/src/librustc/ty/context.rs:1570
             at /home/vegard/rust/src/librustc/infer/mod.rs:453
             at librustc_typeck/check/mod.rs:617
             at librustc_typeck/check/mod.rs:855
  61: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  62: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  63: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  64: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
             at librustc/ty/maps/plumbing.rs:574
             at librustc/ty/maps/plumbing.rs:740
  65: rustc_typeck::check::typeck_item_bodies
             at librustc_typeck/check/mod.rs:715
             at /home/vegard/rust/src/librustc/session/mod.rs:318
             at librustc_typeck/check/mod.rs:713
  66: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  67: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  68: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  69: rustc_typeck::check_crate
             at librustc_typeck/check/mod.rs:706
             at librustc_typeck/lib.rs:344
             at /home/vegard/rust/src/librustc/util/common.rs:166
             at /home/vegard/rust/src/librustc/util/common.rs:160
             at librustc_typeck/lib.rs:344
  70: rustc::ty::context::TyCtxt::create_and_enter
             at librustc_driver/driver.rs:1121
             at /home/vegard/rust/src/librustc/ty/context.rs:1867
             at /home/vegard/rust/src/librustc/ty/context.rs:1844
             at /home/vegard/rust/src/librustc/ty/context.rs:1787
             at /home/vegard/rust/src/librustc/ty/context.rs:1843
             at /home/vegard/rust/src/librustc/ty/context.rs:1866
             at /home/vegard/rust/src/librustc/ty/context.rs:1833
             at /home/vegard/rust/src/libstd/thread/local.rs:294
             at /home/vegard/rust/src/libstd/thread/local.rs:248
             at /home/vegard/rust/src/librustc/ty/context.rs:1825
             at /home/vegard/rust/src/libstd/thread/local.rs:294
             at /home/vegard/rust/src/libstd/thread/local.rs:248
             at /home/vegard/rust/src/librustc/ty/context.rs:1817
             at /home/vegard/rust/src/librustc/ty/context.rs:1855
             at /home/vegard/rust/src/librustc/ty/context.rs:1299
  71: rustc_driver::driver::compile_input
             at librustc_driver/driver.rs:1095
             at librustc_driver/driver.rs:231
  72: rustc_driver::run_compiler
             at librustc_driver/lib.rs:540
             at librustc_driver/lib.rs:457
             at /home/vegard/.cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
             at /home/vegard/rust/src/libsyntax/lib.rs:97
             at /home/vegard/.cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
             at /home/vegard/rust/src/libsyntax/lib.rs:96
             at librustc_driver/lib.rs:456
  73: rustc_driver::monitor::{{closure}}
             at librustc_driver/lib.rs:1684
             at librustc_driver/lib.rs:174
             at librustc_driver/lib.rs:1598
  74: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  75: rustc_driver::run
             at /home/vegard/rust/src/libstd/panicking.rs:289
             at /home/vegard/rust/src/libstd/panic.rs:374
             at librustc_driver/lib.rs:1530
             at librustc_driver/lib.rs:1597
             at librustc_driver/lib.rs:173
  76: rustc_driver::main
             at librustc_driver/lib.rs:1677
  77: std::rt::lang_start::{{closure}}
             at /home/vegard/rust/src/libstd/rt.rs:74
  78: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  79: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  80: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  81: main
  82: __libc_start_main
  83: _start
query stack during panic:
#0 [mir_built] processing `main::{{closure}}::{{initializer}}`
#1 [unsafety_check_result] processing `main::{{closure}}::{{initializer}}`
#2 [mir_const] processing `main::{{closure}}::{{initializer}}`
#3 [mir_const_qualif] processing `main::{{closure}}::{{initializer}}`
#4 [const_eval] const-evaluating `main::{{closure}}::{{initializer}}`
#5 [typeck_tables_of] processing `main`
#6 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 2 previous errors

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

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.27.0-dev running on x86_64-unknown-linux-gnu

On commit c166b03

Activity

added
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.
C-bugCategory: This is a bug.
on May 9, 2018
vegard

vegard commented on May 9, 2018

@vegard
Author

Here's another input that causes a similar enough crash that I don't want to open another issue for it (but let me know if I should do it anyway):

fn main() {
    Vec::<[u8; break]>::new();
}

Output:

error[E0268]: `break` outside of loop
 --> <anon>:2:16
  |
2 |     Vec::<[u8; break]>::new();
  |                ^^^^^ cannot break outside of a loop

error: internal compiler error: librustc_mir/hair/cx/expr.rs:544: invalid loop id for break: not inside loop scope

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors

And if you put a loop {} around it:

fn main() {
    loop {
        Vec::<[u8; break]>::new();
    }
}

Output:
error: internal compiler error: librustc_typeck/check/mod.rs:501: could not find enclosing breakable with id 13

vegard

vegard commented on May 11, 2018

@vegard
Author

This also looks like it might be part of the same problem:

fn main() {
    move |u8: u8| while true {
        [u8; continue]
    };
}

Output:

error: internal compiler error: librustc_mir/build/scope.rs:552: no enclosing breakable scope found
 --> <anon>:3:14
  |
3 |         [u8; continue]
  |              ^^^^^^^^

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
est31

est31 commented on May 17, 2018

@est31
Member

Found another ICE:

fn main() {
    |_: [u8; break]| ();
}

This one's giving a different ICE though. Made a PR to make it be the same ICE (the change is needed anyway): #50849

est31

est31 commented on May 17, 2018

@est31
Member

I gave this bug a look. My results: const eval attempts to build MIR but MIR building fails because MIR building expects break destinations to be well formed. This only dawned to me when I looked at stack traces but I guess it is obvious from the code invoked as well as the place the ICE occurs.

In vanilla compilation, it seems that code like this is handled by MIR not being built if typecheck failed, but apparently this isn't upheld during const eval. Apparently const eval runs here during type check... at least according to stack traces.

No idea what a good way of fixing this is. Making MIR building failible? Somehow running type check during type check? Maybe adding some tainted_by_errors checks will fix this?

It feels weird tho that only this code runs into this particular constellation.

added a commit that references this issue on May 22, 2018

Rollup merge of rust-lang#50849 - est31:visit_closure_args, r=michael…

eb92280
est31

est31 commented on May 24, 2018

@est31
Member

cc @oli-obk as this is miri related

oli-obk

oli-obk commented on May 24, 2018

@oli-obk
Contributor

I think this is essentially the same issue as #50637

Apparently const eval runs here during type check

Yes, and that's necessary, otherwise you couldn't figure out that [T; 2] and [T; 1 + 1] are the same type.

No idea what a good way of fixing this is. Making MIR building failible? Somehow running type check during type check? Maybe adding some tainted_by_errors checks will fix this?

The latter sounds like it would be about right. Essentially const eval should return the TypeckError error variant whenever it encounters a type that has is tainted_by_errors. Backtraces into the ICEs above should show where such a type is used.

9 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @vegard@kennytm@oli-obk@est31

      Issue actions

        error: internal compiler error: librustc_mir/hair/cx/expr.rs:544: invalid loop id for break: label not found · Issue #50576 · rust-lang/rust