-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`I-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):
#![feature(generic_const_exprs)]
fn can_double<const N: usize>(x: [(); N])
where
[(); N * 2]:,
{
x[0];
}
fn foo<const N: usize>()
where
[(); (N + 1) * 2]:,
{
can_double([(); { N + 1 }]);
}
fn main() {
foo::<1>();
}
original:
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn can_double<const N: usize>(x: [(); N])
where
[(); N * 2]:,
{
x[0];
unimplemented!()
}
fn foo<const N: usize>()
where
[(); (N + 1) * 2]:,
{
can_double([(); { N + 1 }]);
// can_double::<{N + 1}>([(); { N + 1 }]);
// can_double::<{N + 1}>([(); { N + 1 }]);
}
fn main() {
foo::<1>();
}
Version information
rustc 1.92.0-nightly (ce4beebec 2025-09-22)
binary: rustc
commit-hash: ce4beebecb77821734079cff47d8af08f9f27f11
commit-date: 2025-09-22
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.1
Possibly related line of code:
rust/compiler/rustc_ty_utils/src/layout.rs
Lines 142 to 154 in ce4beeb
ct: ty::Const<'tcx>, | |
) -> Result<ty::Value<'tcx>, &'tcx LayoutError<'tcx>> { | |
match ct.kind() { | |
ty::ConstKind::Value(cv) => Ok(cv), | |
ty::ConstKind::Param(_) | ty::ConstKind::Expr(_) => { | |
if !ct.has_param() { | |
bug!("failed to normalize const, but it is not generic: {ct:?}"); | |
} | |
Err(error(cx, LayoutError::TooGeneric(ty))) | |
} | |
ty::ConstKind::Unevaluated(_) => { | |
let err = if ct.has_param() { | |
LayoutError::TooGeneric(ty) |
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.xLfdc4uD19aC/rustc_testrunner_tmpdir_reporting.NJBgu9wYiPWw/mvce.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:148:17: failed to normalize const, but it is not generic: (Add: (1_usize: usize), (1_usize: usize))
thread 'rustc' (312868) panicked at compiler/rustc_ty_utils/src/layout.rs:148:17:
Box<dyn Any>
stack backtrace:
0: 0x7f826e202753 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h3e5bd3a23c0347a9
1: 0x7f826ea02044 - core::fmt::write::heee6829eb564c27d
2: 0x7f826e1b7101 - std::io::Write::write_fmt::ha453775b50cc97a5
3: 0x7f826e1c84c2 - std::sys::backtrace::BacktraceLock::print::h71d64778f60f39dd
4: 0x7f826e1ce429 - std::panicking::default_hook::{{closure}}::h0c1df9123d837333
5: 0x7f826e1cdf53 - std::panicking::default_hook::h1518572259f2e3d5
6: 0x7f826d1f1e47 - std[18d792bd9b3d078a]::panicking::update_hook::<alloc[cb65cdfa434cac9f]::boxed::Box<rustc_driver_impl[477d964a0f4cf97e]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7f826e1ce84f - std::panicking::panic_with_hook::hec947c027cbe77e3
8: 0x7f826d22e701 - std[18d792bd9b3d078a]::panicking::begin_panic::<rustc_errors[93e6452cd29fe3a8]::ExplicitBug>::{closure#0}
9: 0x7f826d221f16 - std[18d792bd9b3d078a]::sys::backtrace::__rust_end_short_backtrace::<std[18d792bd9b3d078a]::panicking::begin_panic<rustc_errors[93e6452cd29fe3a8]::ExplicitBug>::{closure#0}, !>
10: 0x7f826d21f9b9 - std[18d792bd9b3d078a]::panicking::begin_panic::<rustc_errors[93e6452cd29fe3a8]::ExplicitBug>
11: 0x7f826d239df1 - <rustc_errors[93e6452cd29fe3a8]::diagnostic::BugAbort as rustc_errors[93e6452cd29fe3a8]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7f826d7cc0ca - rustc_middle[168a57e624ed4250]::util::bug::opt_span_bug_fmt::<rustc_span[150c1f29595c3fc1]::span_encoding::Span>::{closure#0}
13: 0x7f826d7cc12a - rustc_middle[168a57e624ed4250]::ty::context::tls::with_opt::<rustc_middle[168a57e624ed4250]::util::bug::opt_span_bug_fmt<rustc_span[150c1f29595c3fc1]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7f826d7ba90b - rustc_middle[168a57e624ed4250]::ty::context::tls::with_context_opt::<rustc_middle[168a57e624ed4250]::ty::context::tls::with_opt<rustc_middle[168a57e624ed4250]::util::bug::opt_span_bug_fmt<rustc_span[150c1f29595c3fc1]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7f826bfd83f0 - rustc_middle[168a57e624ed4250]::util::bug::bug_fmt
16: 0x7f82705eb970 - rustc_ty_utils[3896a6e1d26d46a]::layout::extract_const_value.cold
17: 0x7f826f28b8ee - rustc_ty_utils[3896a6e1d26d46a]::layout::layout_of_uncached
18: 0x7f826f27fa89 - rustc_ty_utils[3896a6e1d26d46a]::layout::layout_of
19: 0x7f826f27f9ee - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 16usize]>>
20: 0x7f826f27e8fd - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::DefaultCache<rustc_middle[168a57e624ed4250]::ty::PseudoCanonicalInput<rustc_middle[168a57e624ed4250]::ty::Ty>, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
21: 0x7f826f27e528 - rustc_query_impl[e799cb834319d50f]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
22: 0x7f826f3c934a - <core[524b22d1fd644b30]::iter::adapters::enumerate::Enumerate<_> as core[524b22d1fd644b30]::iter::traits::iterator::Iterator>::try_fold::enumerate::<rustc_middle[168a57e624ed4250]::ty::Ty, (), core[524b22d1fd644b30]::ops::control_flow::ControlFlow<core[524b22d1fd644b30]::ops::control_flow::ControlFlow<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>>>, core[524b22d1fd644b30]::iter::adapters::map::map_try_fold<(usize, rustc_middle[168a57e624ed4250]::ty::Ty), core[524b22d1fd644b30]::result::Result<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>, &rustc_middle[168a57e624ed4250]::ty::layout::FnAbiError>, (), core[524b22d1fd644b30]::ops::control_flow::ControlFlow<core[524b22d1fd644b30]::ops::control_flow::ControlFlow<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>>>, rustc_ty_utils[3896a6e1d26d46a]::abi::fn_abi_new_uncached::{closure#3}, <core[524b22d1fd644b30]::iter::adapters::GenericShunt<core[524b22d1fd644b30]::iter::adapters::map::Map<core[524b22d1fd644b30]::iter::adapters::enumerate::Enumerate<core[524b22d1fd644b30]::iter::adapters::chain::Chain<core[524b22d1fd644b30]::iter::adapters::chain::Chain<core[524b22d1fd644b30]::iter::adapters::copied::Copied<core[524b22d1fd644b30]::slice::iter::Iter<rustc_middle[168a57e624ed4250]::ty::Ty>>, core[524b22d1fd644b30]::iter::adapters::copied::Copied<core[524b22d1fd644b30]::slice::iter::Iter<rustc_middle[168a57e624ed4250]::ty::Ty>>>, core[524b22d1fd644b30]::option::IntoIter<rustc_middle[168a57e624ed4250]::ty::Ty>>>, rustc_ty_utils[3896a6e1d26d46a]::abi::fn_abi_new_uncached::{closure#3}>, core[524b22d1fd644b30]::result::Result<core[524b22d1fd644b30]::convert::Infallible, &rustc_middle[168a57e624ed4250]::ty::layout::FnAbiError>> as core[524b22d1fd644b30]::iter::traits::iterator::Iterator>::try_fold<(), core[524b22d1fd644b30]::iter::traits::iterator::Iterator::try_for_each::call<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>, core[524b22d1fd644b30]::ops::control_flow::ControlFlow<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>>, core[524b22d1fd644b30]::ops::control_flow::ControlFlow<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>>::Break>::{closure#0}, core[524b22d1fd644b30]::ops::control_flow::ControlFlow<rustc_target[1989c676991791d8]::callconv::ArgAbi<rustc_middle[168a57e624ed4250]::ty::Ty>>>::{closure#0}>::{closure#0}>::{closure#0}
23: 0x7f826f5b2d64 - rustc_ty_utils[3896a6e1d26d46a]::abi::fn_abi_new_uncached
24: 0x7f826f5ad710 - rustc_ty_utils[3896a6e1d26d46a]::abi::fn_abi_of_instance
25: 0x7f826f5acdbc - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 16usize]>>
26: 0x7f826f79debc - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::DefaultCache<rustc_middle[168a57e624ed4250]::ty::PseudoCanonicalInput<(rustc_middle[168a57e624ed4250]::ty::instance::Instance, &rustc_middle[168a57e624ed4250]::ty::list::RawList<(), rustc_middle[168a57e624ed4250]::ty::Ty>)>, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
27: 0x7f826f79da4f - rustc_query_impl[e799cb834319d50f]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace
28: 0x7f826bdad552 - rustc_monomorphize[2c4283d798154e0c]::mono_checks::check_mono_item
29: 0x7f826ea0d8a0 - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::check_mono_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 0usize]>>
30: 0x7f826f600c92 - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::DefaultCache<rustc_middle[168a57e624ed4250]::ty::instance::Instance, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
31: 0x7f826f600911 - rustc_query_impl[e799cb834319d50f]::query_impl::check_mono_item::get_query_non_incr::__rust_end_short_backtrace
32: 0x7f826bd961c7 - rustc_monomorphize[2c4283d798154e0c]::collector::items_of_instance
33: 0x7f826ebf0732 - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::items_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 32usize]>>
34: 0x7f826f4524d5 - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::DefaultCache<(rustc_middle[168a57e624ed4250]::ty::instance::Instance, rustc_middle[168a57e624ed4250]::mir::mono::CollectionMode), rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 32usize]>>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
35: 0x7f826f4520e9 - rustc_query_impl[e799cb834319d50f]::query_impl::items_of_instance::get_query_non_incr::__rust_end_short_backtrace
36: 0x7f826f45534e - rustc_monomorphize[2c4283d798154e0c]::collector::collect_items_rec::{closure#0}
37: 0x7f826f45646c - rustc_monomorphize[2c4283d798154e0c]::collector::collect_items_rec
38: 0x7f826f4570f0 - rustc_monomorphize[2c4283d798154e0c]::collector::collect_items_rec
39: 0x7f826f4570f0 - rustc_monomorphize[2c4283d798154e0c]::collector::collect_items_rec
40: 0x7f826ef557e1 - rustc_monomorphize[2c4283d798154e0c]::collector::collect_crate_mono_items::{closure#1}::{closure#0}
41: 0x7f826f0bb138 - rustc_monomorphize[2c4283d798154e0c]::partitioning::collect_and_partition_mono_items
42: 0x7f826f0badd6 - rustc_query_impl[e799cb834319d50f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e799cb834319d50f]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 24usize]>>
43: 0x7f826f0badb9 - <rustc_query_impl[e799cb834319d50f]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[524b22d1fd644b30]::ops::function::FnOnce<(rustc_middle[168a57e624ed4250]::ty::context::TyCtxt, ())>>::call_once
44: 0x7f826feb2b5e - rustc_query_system[fc44913d20ec5c31]::query::plumbing::try_execute_query::<rustc_query_impl[e799cb834319d50f]::DynamicConfig<rustc_query_system[fc44913d20ec5c31]::query::caches::SingleCache<rustc_middle[168a57e624ed4250]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[e799cb834319d50f]::plumbing::QueryCtxt, false>
45: 0x7f826feb2903 - rustc_query_impl[e799cb834319d50f]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
46: 0x7f826fbaafee - <rustc_codegen_llvm[d0043158dff2f39a]::LlvmCodegenBackend as rustc_codegen_ssa[ac50efdacbb25cbe]::traits::backend::CodegenBackend>::codegen_crate
47: 0x7f826fc77070 - <rustc_interface[60bc46e8fdb58ac8]::queries::Linker>::codegen_and_build_linker
48: 0x7f826fc74bc0 - rustc_interface[60bc46e8fdb58ac8]::passes::create_and_enter_global_ctxt::<core[524b22d1fd644b30]::option::Option<rustc_interface[60bc46e8fdb58ac8]::queries::Linker>, rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
49: 0x7f826fc121be - rustc_interface[60bc46e8fdb58ac8]::interface::run_compiler::<(), rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}>::{closure#1}
50: 0x7f826fb74778 - std[18d792bd9b3d078a]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_with_globals<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_pool_with_globals<rustc_interface[60bc46e8fdb58ac8]::interface::run_compiler<(), rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
51: 0x7f826fb7445c - <<std[18d792bd9b3d078a]::thread::Builder>::spawn_unchecked_<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_with_globals<rustc_interface[60bc46e8fdb58ac8]::util::run_in_thread_pool_with_globals<rustc_interface[60bc46e8fdb58ac8]::interface::run_compiler<(), rustc_driver_impl[477d964a0f4cf97e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[524b22d1fd644b30]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
52: 0x7f826fb7a34d - std::sys::thread::unix::Thread::new::thread_start::hd35e43a00d992682
53: 0x7f82692969cb - <unknown>
54: 0x7f826931aa0c - <unknown>
55: 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.92.0-nightly (ce4beebec 2025-09-22) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [layout_of] computing layout of `[(); ValTree(Leaf(0x0000000000000001): usize) + ValTree(Leaf(0x0000000000000001): usize)]`
#1 [fn_abi_of_instance] computing call ABI of `can_double::<ValTree(Leaf(0x0000000000000001): usize) + ValTree(Leaf(0x0000000000000001): usize)>`
#2 [check_mono_item] monomorphization-time checking
#3 [items_of_instance] collecting items used by `can_double::<ValTree(Leaf(0x0000000000000001): usize) + ValTree(Leaf(0x0000000000000001): usize)>`
#4 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to 1 previous error; 1 warning emitted
@rustbot label +F-generic_const_exprs
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`I-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.