-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-loop_matchwhen you match up with someone and they really throw you for a loopwhen you match up with someone and they really throw you for a loopI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
auto-reduced (treereduce-rust):
fn test(mut state: u8) {
#[loop_match]
loop {
state = 'blk {
match state {
0 => {
#[const_continue]
break 'blk state;
}
_ => unreachable!(),
}
}
}
}
original:
#![feature(loop_match)]
#![crate_type = "lib"]
const CONST_THAT_PANICS: u8 = panic!("diverge!");
//~^ ERROR: evaluation panicked: diverge!
fn test(mut state: u8) {
#[loop_match]
loop {
state = 'blk {
match state {
0 => {
#[const_continue]
break 'blk state;
}
_ => unreachable!(),
}
}
}
}
Version information
rustc 1.90.0-nightly (cccf075eb 2025-07-14)
binary: rustc
commit-hash: cccf075eba88363269e8589ebb8d40874cc542d8
commit-date: 2025-07-14
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
Possibly related line of code:
rust/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
Lines 90 to 102 in cccf075
ExprKind::StaticRef { alloc_id, ty, .. } => { | |
let const_val = ConstValue::Scalar(Scalar::from_pointer(alloc_id.into(), &tcx)); | |
let const_ = Const::Val(const_val, ty); | |
ConstOperand { span, user_ty: None, const_ } | |
} | |
_ => span_bug!(span, "expression is not a valid constant {:?}", kind), | |
} | |
} | |
#[instrument(skip(tcx, lit_input))] | |
fn lit_to_mir_constant<'tcx>(tcx: TyCtxt<'tcx>, lit_input: LitToConstInput<'tcx>) -> Const<'tcx> { | |
let LitToConstInput { lit, ty, neg } = lit_input; |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error: labeled expression must be followed by `:`
--> /tmp/icemaker_global_tempdir.134piiFNPBRY/rustc_testrunner_tmpdir_reporting.IEFcfLh4qE8H/mvce.rs:10:17
|
10 | state = 'blk {
| ^---
| |
| _________________the label
| |
11 | | match state {
12 | | 0 => {
13 | | #[const_continue]
... |
19 | | }
| |_________^
|
= note: labels are used before loops and blocks, allowing e.g., `break 'label` to them
help: add `:` after the label
|
10 | state = 'blk: {
| +
error[E0658]: the `#[loop_match]` attribute is an experimental feature
--> /tmp/icemaker_global_tempdir.134piiFNPBRY/rustc_testrunner_tmpdir_reporting.IEFcfLh4qE8H/mvce.rs:8:5
|
8 | #[loop_match]
| ^^^^^^^^^^^^^
|
= note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information
= help: add `#![feature(loop_match)]` to the crate attributes to enable
= note: this compiler was built on 2025-07-14; consider upgrading it if it is out of date
error[E0658]: the `#[const_continue]` attribute is an experimental feature
--> /tmp/icemaker_global_tempdir.134piiFNPBRY/rustc_testrunner_tmpdir_reporting.IEFcfLh4qE8H/mvce.rs:13:21
|
13 | #[const_continue]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information
= help: add `#![feature(loop_match)]` to the crate attributes to enable
= note: this compiler was built on 2025-07-14; consider upgrading it if it is out of date
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.134piiFNPBRY/rustc_testrunner_tmpdir_reporting.IEFcfLh4qE8H/mvce.rs:21:2
|
21 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.134piiFNPBRY/rustc_testrunner_tmpdir_reporting.IEFcfLh4qE8H/mvce.rs`
error: internal compiler error: compiler/rustc_mir_build/src/builder/expr/as_constant.rs:96:14: expression is not a valid constant VarRef { id: LocalVarId(HirId(DefId(0:3 ~ mvce[b8a6]::test).2)) }
--> /tmp/icemaker_global_tempdir.134piiFNPBRY/rustc_testrunner_tmpdir_reporting.IEFcfLh4qE8H/mvce.rs:14:32
|
14 | break 'blk state;
| ^^^^^
thread 'rustc' panicked at compiler/rustc_mir_build/src/builder/expr/as_constant.rs:96:14:
Box<dyn Any>
stack backtrace:
0: 0x7c96619c1673 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfa58e48a5ae2f127
1: 0x7c96622026f7 - core::fmt::write::h3347b3b5b53dd0c2
2: 0x7c96619b72b3 - std::io::Write::write_fmt::hddcaacf2e1404fe5
3: 0x7c96619c14d2 - std::sys::backtrace::BacktraceLock::print::h6958395e357d58e8
4: 0x7c96619c4f77 - std::panicking::default_hook::{{closure}}::hf97f9b8a91d4a329
5: 0x7c96619c4adb - std::panicking::default_hook::h0fe123f3342c8b27
6: 0x7c9660a5d743 - std[30a820b5eb065398]::panicking::update_hook::<alloc[5f6e8daaad3bb231]::boxed::Box<rustc_driver_impl[935dee76a1e5c66c]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7c96619c57be - std::panicking::rust_panic_with_hook::h64d7a2df483fc2c4
8: 0x7c9660a972f1 - std[30a820b5eb065398]::panicking::begin_panic::<rustc_errors[23304b264715cc64]::ExplicitBug>::{closure#0}
9: 0x7c9660a8c286 - std[30a820b5eb065398]::sys::backtrace::__rust_end_short_backtrace::<std[30a820b5eb065398]::panicking::begin_panic<rustc_errors[23304b264715cc64]::ExplicitBug>::{closure#0}, !>
10: 0x7c9660a88a89 - std[30a820b5eb065398]::panicking::begin_panic::<rustc_errors[23304b264715cc64]::ExplicitBug>
11: 0x7c9660aa0dd1 - <rustc_errors[23304b264715cc64]::diagnostic::BugAbort as rustc_errors[23304b264715cc64]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7c9661007dcc - <rustc_errors[23304b264715cc64]::DiagCtxtHandle>::span_bug::<rustc_span[8cb7c19697a3298c]::span_encoding::Span, alloc[5f6e8daaad3bb231]::string::String>
13: 0x7c966109c907 - rustc_middle[7ce7839b08b696ce]::util::bug::opt_span_bug_fmt::<rustc_span[8cb7c19697a3298c]::span_encoding::Span>::{closure#0}
14: 0x7c966107c82a - rustc_middle[7ce7839b08b696ce]::ty::context::tls::with_opt::<rustc_middle[7ce7839b08b696ce]::util::bug::opt_span_bug_fmt<rustc_span[8cb7c19697a3298c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x7c966107c69b - rustc_middle[7ce7839b08b696ce]::ty::context::tls::with_context_opt::<rustc_middle[7ce7839b08b696ce]::ty::context::tls::with_opt<rustc_middle[7ce7839b08b696ce]::util::bug::opt_span_bug_fmt<rustc_span[8cb7c19697a3298c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x7c965e897357 - rustc_middle[7ce7839b08b696ce]::util::bug::span_bug_fmt::<rustc_span[8cb7c19697a3298c]::span_encoding::Span>
17: 0x7c96627460f2 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::as_constant
18: 0x7c966277950a - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::stmt_expr
19: 0x7c9662777b0a - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::stmt_expr
20: 0x7c96631f0510 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::ast_block_stmts
21: 0x7c96631ef805 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::ast_block
22: 0x7c9662762e3a - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
23: 0x7c96627445bb - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::as_temp::{closure#0}
24: 0x7c9662763d87 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
25: 0x7c96627625a0 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
26: 0x7c9662772abf - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::lower_match_arms
27: 0x7c966110c1f3 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::in_breakable_scope::<<rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest::{closure#4}>
28: 0x7c966276b18f - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
29: 0x7c96627445bb - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::as_temp::{closure#0}
30: 0x7c9662763d87 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
31: 0x7c96627625a0 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
32: 0x7c96631f1a82 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::ast_block_stmts
33: 0x7c96631ef805 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::ast_block
34: 0x7c9662762e3a - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
35: 0x7c96627625a0 - <rustc_mir_build[3e8b78bd702d6f7]::builder::Builder>::expr_into_dest
36: 0x7c966277d824 - rustc_mir_build[3e8b78bd702d6f7]::builder::build_mir
37: 0x7c9662208446 - rustc_mir_transform[7553d0c8a2a6ff48]::mir_built
38: 0x7c9662208417 - rustc_query_impl[c45aa3b3181847a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c45aa3b3181847a2]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ce7839b08b696ce]::query::erase::Erased<[u8; 8usize]>>
39: 0x7c9662817eee - rustc_query_system[985c31aefa838be3]::query::plumbing::try_execute_query::<rustc_query_impl[c45aa3b3181847a2]::DynamicConfig<rustc_data_structures[a4363df8adba9f3d]::vec_cache::VecCache<rustc_span[8cb7c19697a3298c]::def_id::LocalDefId, rustc_middle[7ce7839b08b696ce]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[985c31aefa838be3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[c45aa3b3181847a2]::plumbing::QueryCtxt, false>
40: 0x7c9662817949 - rustc_query_impl[c45aa3b3181847a2]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
41: 0x7c9662b65e74 - rustc_mir_build[3e8b78bd702d6f7]::check_unsafety::check_unsafety
42: 0x7c9662b65bf7 - rustc_query_impl[c45aa3b3181847a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c45aa3b3181847a2]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ce7839b08b696ce]::query::erase::Erased<[u8; 0usize]>>
43: 0x7c9662b5e8c7 - rustc_query_system[985c31aefa838be3]::query::plumbing::try_execute_query::<rustc_query_impl[c45aa3b3181847a2]::DynamicConfig<rustc_data_structures[a4363df8adba9f3d]::vec_cache::VecCache<rustc_span[8cb7c19697a3298c]::def_id::LocalDefId, rustc_middle[7ce7839b08b696ce]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[985c31aefa838be3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[c45aa3b3181847a2]::plumbing::QueryCtxt, false>
44: 0x7c9662b5e5bd - rustc_query_impl[c45aa3b3181847a2]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
45: 0x7c9662b5cfec - <rustc_middle[7ce7839b08b696ce]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[eb90780461757de5]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
46: 0x7c9662b5aab5 - rustc_interface[eb90780461757de5]::passes::analysis
47: 0x7c9662b59f6f - rustc_query_impl[c45aa3b3181847a2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c45aa3b3181847a2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7ce7839b08b696ce]::query::erase::Erased<[u8; 0usize]>>
48: 0x7c9663276b7c - rustc_query_system[985c31aefa838be3]::query::plumbing::try_execute_query::<rustc_query_impl[c45aa3b3181847a2]::DynamicConfig<rustc_query_system[985c31aefa838be3]::query::caches::SingleCache<rustc_middle[7ce7839b08b696ce]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c45aa3b3181847a2]::plumbing::QueryCtxt, false>
49: 0x7c9663276744 - rustc_query_impl[c45aa3b3181847a2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
50: 0x7c9663523b4b - rustc_interface[eb90780461757de5]::passes::create_and_enter_global_ctxt::<core[48959e4b1b95f79b]::option::Option<rustc_interface[eb90780461757de5]::queries::Linker>, rustc_driver_impl[935dee76a1e5c66c]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
51: 0x7c9663511a14 - rustc_interface[eb90780461757de5]::interface::run_compiler::<(), rustc_driver_impl[935dee76a1e5c66c]::run_compiler::{closure#0}>::{closure#1}
52: 0x7c96633d88f8 - std[30a820b5eb065398]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eb90780461757de5]::util::run_in_thread_with_globals<rustc_interface[eb90780461757de5]::util::run_in_thread_pool_with_globals<rustc_interface[eb90780461757de5]::interface::run_compiler<(), rustc_driver_impl[935dee76a1e5c66c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
53: 0x7c96633d85d6 - <<std[30a820b5eb065398]::thread::Builder>::spawn_unchecked_<rustc_interface[eb90780461757de5]::util::run_in_thread_with_globals<rustc_interface[eb90780461757de5]::util::run_in_thread_pool_with_globals<rustc_interface[eb90780461757de5]::interface::run_compiler<(), rustc_driver_impl[935dee76a1e5c66c]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[48959e4b1b95f79b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
54: 0x7c96633de47d - std::sys::pal::unix::thread::Thread::new::thread_start::h65cf4f75df3829a5
55: 0x7c965cca57eb - <unknown>
56: 0x7c965cd2918c - <unknown>
57: 0x0 - <unknown>
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: please make sure that you have updated to the latest nightly
note: rustc 1.90.0-nightly (cccf075eb 2025-07-14) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [mir_built] building MIR for `test`
#1 [check_unsafety] unsafety-checking `test`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.
@rustbot label +F-loop_match
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-loop_matchwhen you match up with someone and they really throw you for a loopwhen you match up with someone and they really throw you for a loopI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.