Skip to content

breaking labeled while-loop in const assignment results in ICE #51350

Closed
@DutchGhost

Description

@DutchGhost

A while ago, this would cause an illigal instruction, but has been fixed, see #50856 , and no longer is an issue in the current nightly.

'a: while break 'a {};

Except, using such code while creating a constant, results in an ICE:
https://play.rust-lang.org/?gist=e974c3b625754ce340a4bd77bd3b7235&version=nightly&mode=debug

const crash: () = 'a: while break 'a {};

fn main() {

}

This is rustc 1.28.0-nightly (5d0631a 2018-05-30).

Backtrace:

error: internal compiler error: librustc_mir\transform\qualify_consts.rs:272: multiple assignments to _0
 --> src\main.rs:1:19
  |
1 | const crash: () = 'a: while break 'a {};
  |                   ^^^^^^^^^^^^^^^^^^^^^

thread 'main' panicked at 'Box<Any>', librustc_errors\lib.rs:499:9
stack backtrace:
   0: <std::sync::mpsc::RecvTimeoutError as core::fmt::Debug>::fmt
   1: <std::sys::windows::dynamic_lib::DynamicLibrary as core::ops::drop::Drop>::drop
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::middle::const_val::ErrKind<'a>>::lift_to_tcx
   5: std::panicking::rust_panic_with_hook
   6: <rustc_mir::transform::uniform_array_move_out::LocalUse as core::fmt::Debug>::fmt
   7: <rustc_mir::transform::uniform_array_move_out::LocalUse as core::fmt::Debug>::fmt
   8: <rustc_mir::dataflow::move_paths::abs_domain::AbstractOperand as core::fmt::Debug>::fmt
   9: <rustc_mir::dataflow::move_paths::abs_domain::AbstractOperand as core::fmt::Debug>::fmt
  10: <rustc_mir::dataflow::move_paths::abs_domain::AbstractOperand as core::fmt::Debug>::fmt
  11: <rustc_mir::dataflow::move_paths::abs_domain::AbstractOperand as core::fmt::Debug>::fmt
  12: <rustc_mir::transform::qualify_consts::Qualif as core::fmt::UpperHex>::fmt
  13: <rustc_mir::transform::qualify_consts::Qualif as core::fmt::UpperHex>::fmt
  14: <rustc_mir::transform::qualify_consts::Mode as core::fmt::Display>::fmt
  15: <rustc_mir::monomorphize::collector::MonoItemCollectionMode as core::fmt::Debug>::fmt
  16: <rustc_mir::transform::qualify_consts::Mode as core::fmt::Display>::fmt
  17: rustc_mir::transform::qualify_consts::provide
  18: rustc::ty::context::tls::track_diagnostic
  19: rustc::ty::context::tls::track_diagnostic
  20: rustc::dep_graph::graph::DepGraph::assert_ignored
  21: rustc::ty::context::tls::track_diagnostic
  22: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  23: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const_qualif
  25: rustc_mir::transform::mir_validated
  26: rustc::ty::maps::on_disk_cache::__ty_decoder_impl::<impl serialize::serialize::Decoder for rustc::ty::maps::on_disk_cache::CacheDecoder<'a, 'tcx, 'x>>::read_str
  27: rustc::ty::context::tls::track_diagnostic
  28: rustc::ty::context::tls::track_diagnostic
  29: rustc::dep_graph::graph::DepGraph::assert_ignored
  30: rustc::ty::context::tls::track_diagnostic
  31: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  32: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  33: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  34: rustc_borrowck::borrowck::provide
  35: rustc::ty::context::tls::track_diagnostic
  36: rustc::ty::context::tls::track_diagnostic
  37: rustc::dep_graph::graph::DepGraph::assert_ignored
  38: rustc::ty::context::tls::track_diagnostic
  39: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  40: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
  41: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::borrowck
  42: rustc_borrowck::borrowck::check_crate
  43: <humantime::duration::Error as std::error::Error>::cause
  44: <rustc_driver::pretty::NoAnn<'hir> as rustc_driver::pretty::HirPrinterSupport<'hir>>::sess
  45: <unknown>
  46: rustc_driver::driver::compile_input
  47: rustc_driver::run_compiler
  48: rustc_driver::target_features::add_configuration
  49: rustc_driver::target_features::add_configuration
  50: _rust_maybe_catch_panic
  51: rustc_driver::set_sigpipe_handler
  52: rustc_driver::main
  53: <unknown>
  54: std::panicking::update_panic_count
  55: _rust_maybe_catch_panic
  56: std::rt::lang_start_internal
  57: <unknown>
  58: <unknown>
  59: BaseThreadInitThunk
  60: RtlUserThreadStart
query stack during panic:
#0 [mir_const_qualif] processing `crash`
#1 [mir_validated] processing `crash`
#2 [borrowck] processing `crash`
end of query stack
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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