Open
Description
Code
fn main() {
let c = std::hint::black_box('c');
let r = match c {
'\0'..='亹' | '亻'..='及' | '双'..='\u{10ffff}' => 1usize,
'友' => 2usize,
'人' => 3usize,
};
println!("{r}");
}
Meta
rustc --version --verbose
:
rustc 1.87.0 (17067e9ac 2025-05-09) running on x86_64-unknown-linux-gnu
Error output
thread 'rustc' panicked at compiler/rustc_mir_transform/src/match_branches.rs:297:14:
internal error: entered unreachable code: invalid int
stack backtrace:
0: 0x7a0487e8a3c3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hc04c8f544ab24d66
1: 0x7a0488605b51 - core::fmt::write::hfe57b7174b7d8eab
2: 0x7a0489a8e011 - std::io::Write::write_fmt::h154385efa8565236
3: 0x7a0487e8a222 - std::sys::backtrace::BacktraceLock::print::h0c8f24e22f5873a8
4: 0x7a0487e8cada - std::panicking::default_hook::{{closure}}::hd07d57e6a602c8e4
5: 0x7a0487e8c65f - std::panicking::default_hook::h63d12f7d95bd91ed
6: 0x7a0486ef0450 - std[ab9b65b5f5dd2f44]::panicking::update_hook::<alloc[4810a64b00f2b3b7]::boxed::Box<rustc_driver_impl[ddaea9a5059e4009]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7a0487e8d353 - std::panicking::rust_panic_with_hook::h33b18b24045abff4
8: 0x7a0487e8d016 - std::panicking::begin_panic_handler::{{closure}}::hf8313cc2fd0126bc
9: 0x7a0487e8a899 - std::sys::backtrace::__rust_end_short_backtrace::h57fe07c8aea5c98a
10: 0x7a0487e8cd0d - __rustc[95feac21a9532783]::rust_begin_unwind
11: 0x7a0484894960 - core::panicking::panic_fmt::hd54fb667be51beea
12: 0x7a048a431d02 - rustc_mir_transform[3f8bf91e0e7bcf96]::match_branches::can_cast::<u128>.cold
13: 0x7a04890e7299 - <rustc_mir_transform[3f8bf91e0e7bcf96]::match_branches::MatchBranchSimplification as rustc_mir_transform[3f8bf91e0e7bcf96]::pass_manager::MirPass>::run_pass
14: 0x7a04886039fb - rustc_mir_transform[3f8bf91e0e7bcf96]::pass_manager::run_passes_inner
15: 0x7a0488ff63e2 - rustc_mir_transform[3f8bf91e0e7bcf96]::optimized_mir
16: 0x7a0488ff59cb - rustc_query_impl[9eb226868f218d86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9eb226868f218d86]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 8usize]>>
17: 0x7a04886224af - rustc_query_system[719b00724ab1874c]::query::plumbing::try_execute_query::<rustc_query_impl[9eb226868f218d86]::DynamicConfig<rustc_query_system[719b00724ab1874c]::query::caches::DefIdCache<rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9eb226868f218d86]::plumbing::QueryCtxt, false>
18: 0x7a04886218dd - rustc_query_impl[9eb226868f218d86]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
19: 0x7a04890cb8f2 - <rustc_middle[f5c565be837cd477]::ty::context::TyCtxt>::instance_mir
20: 0x7a0485639277 - rustc_monomorphize[4f6dde2ed994733c]::mono_checks::check_mono_item
21: 0x7a04890fcbfe - rustc_query_impl[9eb226868f218d86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9eb226868f218d86]::query_impl::check_mono_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 0usize]>>
22: 0x7a04890fcf1d - rustc_query_system[719b00724ab1874c]::query::plumbing::try_execute_query::<rustc_query_impl[9eb226868f218d86]::DynamicConfig<rustc_query_system[719b00724ab1874c]::query::caches::DefaultCache<rustc_middle[f5c565be837cd477]::ty::instance::Instance, rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[9eb226868f218d86]::plumbing::QueryCtxt, false>
23: 0x7a04890fcbcd - rustc_query_impl[9eb226868f218d86]::query_impl::check_mono_item::get_query_non_incr::__rust_end_short_backtrace
24: 0x7a0485642bff - rustc_monomorphize[4f6dde2ed994733c]::collector::items_of_instance
25: 0x7a0488ea6f32 - rustc_query_impl[9eb226868f218d86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9eb226868f218d86]::query_impl::items_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 32usize]>>
26: 0x7a0488ea729a - rustc_query_system[719b00724ab1874c]::query::plumbing::try_execute_query::<rustc_query_impl[9eb226868f218d86]::DynamicConfig<rustc_query_system[719b00724ab1874c]::query::caches::DefaultCache<(rustc_middle[f5c565be837cd477]::ty::instance::Instance, rustc_middle[f5c565be837cd477]::mir::mono::CollectionMode), rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[9eb226868f218d86]::plumbing::QueryCtxt, false>
27: 0x7a0488ea6eab - rustc_query_impl[9eb226868f218d86]::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
28: 0x7a0488ea8f6a - rustc_monomorphize[4f6dde2ed994733c]::collector::collect_items_rec::{closure#0}
29: 0x7a0488ea9e7b - rustc_monomorphize[4f6dde2ed994733c]::collector::collect_items_rec
30: 0x7a0488c16765 - rustc_monomorphize[4f6dde2ed994733c]::partitioning::collect_and_partition_mono_items
31: 0x7a04898d8da6 - rustc_query_impl[9eb226868f218d86]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9eb226868f218d86]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 40usize]>>
32: 0x7a04898d8d8b - <rustc_query_impl[9eb226868f218d86]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[6e25f1b983e4a449]::ops::function::FnOnce<(rustc_middle[f5c565be837cd477]::ty::context::TyCtxt, ())>>::call_once
33: 0x7a04898d88b4 - rustc_query_system[719b00724ab1874c]::query::plumbing::try_execute_query::<rustc_query_impl[9eb226868f218d86]::DynamicConfig<rustc_query_system[719b00724ab1874c]::query::caches::SingleCache<rustc_middle[f5c565be837cd477]::query::erase::Erased<[u8; 40usize]>>, false, false, false>, rustc_query_impl[9eb226868f218d86]::plumbing::QueryCtxt, false>
34: 0x7a04898d8644 - rustc_query_impl[9eb226868f218d86]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
35: 0x7a04897935e0 - <rustc_codegen_llvm[dedd2c942a2348b0]::LlvmCodegenBackend as rustc_codegen_ssa[22cc9466fca14ff3]::traits::backend::CodegenBackend>::codegen_crate
36: 0x7a0489734895 - <rustc_interface[4f8e933b45f54331]::queries::Linker>::codegen_and_build_linker
37: 0x7a0489731f28 - rustc_interface[4f8e933b45f54331]::passes::create_and_enter_global_ctxt::<core[6e25f1b983e4a449]::option::Option<rustc_interface[4f8e933b45f54331]::queries::Linker>, rustc_driver_impl[ddaea9a5059e4009]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
38: 0x7a0489723eaa - rustc_interface[4f8e933b45f54331]::interface::run_compiler::<(), rustc_driver_impl[ddaea9a5059e4009]::run_compiler::{closure#0}>::{closure#1}
39: 0x7a0489564f08 - std[ab9b65b5f5dd2f44]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[4f8e933b45f54331]::util::run_in_thread_with_globals<rustc_interface[4f8e933b45f54331]::util::run_in_thread_pool_with_globals<rustc_interface[4f8e933b45f54331]::interface::run_compiler<(), rustc_driver_impl[ddaea9a5059e4009]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
40: 0x7a04895657f4 - <<std[ab9b65b5f5dd2f44]::thread::Builder>::spawn_unchecked_<rustc_interface[4f8e933b45f54331]::util::run_in_thread_with_globals<rustc_interface[4f8e933b45f54331]::util::run_in_thread_pool_with_globals<rustc_interface[4f8e933b45f54331]::interface::run_compiler<(), rustc_driver_impl[ddaea9a5059e4009]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[6e25f1b983e4a449]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
41: 0x7a0489566bf7 - std::sys::pal::unix::thread::Thread::new::thread_start::h2717d4f9aca577e6
42: 0x7a048348aaa4 - <unknown>
43: 0x7a0483517a34 - clone
44: 0x0 - <unknown>
error: the compiler unexpectedly panicked. this is a bug.
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: rustc 1.87.0 (17067e9ac 2025-05-09) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [optimized_mir] optimizing MIR for `main`
#1 [check_mono_item] monomorphization-time checking
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: could not compile `playground` (bin "playground")
Backtrace
Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at compiler/rustc_mir_transform/src/match_branches.rs:297:14:
internal error: entered unreachable code: invalid int
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: rustc_mir_transform::match_branches::can_cast::<u128>.cold
3: <rustc_mir_transform::match_branches::MatchBranchSimplification as rustc_mir_transform::pass_manager::MirPass>::run_pass
4: rustc_mir_transform::pass_manager::run_passes_inner
5: rustc_mir_transform::optimized_mir
[... omitted 1 frame ...]
6: <rustc_middle::ty::context::TyCtxt>::instance_mir
7: rustc_monomorphize::mono_checks::check_mono_item
[... omitted 1 frame ...]
8: rustc_monomorphize::collector::items_of_instance
[... omitted 1 frame ...]
9: rustc_monomorphize::collector::collect_items_rec::{closure#0}
10: rustc_monomorphize::collector::collect_items_rec
11: rustc_monomorphize::partitioning::collect_and_partition_mono_items
[... omitted 2 frames ...]
12: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
13: <rustc_interface::queries::Linker>::codegen_and_build_linker
14: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
15: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: the compiler unexpectedly panicked. this is a bug.
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: rustc 1.87.0 (17067e9ac 2025-05-09) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [optimized_mir] optimizing MIR for `main`
#1 [check_mono_item] monomorphization-time checking
#2 [items_of_instance] collecting items used by `main`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `playground` (bin "playground")
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Medium priorityStatus: A bisection has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.