Open
Description
auto-reduced (treereduce-rust):
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
fn foo<const N: u32>(a: [(); N as usize]) {}
const C: f32 = 1.0;
fn main() {
foo::<C>();
}
original:
//@ revisions: simple adt_const_params full
#![cfg_attr(full, feature(adt_const_params, ))]
#[cfg_attr(full, allow(incomplete_features))]
#![deny(const_evaluatable_unchecked)]
#![cfg_attr(adt_const_params, allow(incomplete_features))]
fn foo<const N: u32>(a: [(); N as usize]) {
[(); braced_braced_expr!{}];
//~^ error: unconstrained generic constant
}
//[adt_const_params]~^^ ERROR `&'static ()` can't be used as a const parameter type
const C: f32 = 1.0;
fn main() {
foo::<C>();
}
Version information
rustc 1.90.0-nightly (fd9ca711a 2025-07-05)
binary: rustc
commit-hash: fd9ca711a3a0e2bd5bd33a345fa4439348111006
commit-date: 2025-07-05
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.7
Possibly related line of code:
rust/compiler/rustc_const_eval/src/interpret/cast.rs
Lines 149 to 161 in fd9ca71
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_exprs) -Zcrate-attr=feature(min_generic_const_args)
Program output
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> <crate attribute>: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
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> <crate attribute>:1:12
|
1 | #![feature(min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/cast.rs:155:9:
assertion failed: src.layout.ty.is_integral() || src.layout.ty.is_char() ||
src.layout.ty.is_bool()
stack backtrace:
0: 0x769bcc329c03 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdcaf038ccc22af60
1: 0x769bcca02bbf - core::fmt::write::h6a2dc0c1e0319253
2: 0x769bcc31f843 - std::io::Write::write_fmt::hf80ee03682e93b18
3: 0x769bcc329a62 - std::sys::backtrace::BacktraceLock::print::hb64b84ed3955e559
4: 0x769bcc32d4fa - std::panicking::default_hook::{{closure}}::h054930d99c890fe0
5: 0x769bcc32d07f - std::panicking::default_hook::h45a7dd1d52c6f734
6: 0x769bcb3fa983 - std[97ade9a0245a6b27]::panicking::update_hook::<alloc[b9dae7385774dacd]::boxed::Box<rustc_driver_impl[9e5e8cd112afe598]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x769bcc32dd4b - std::panicking::rust_panic_with_hook::h3b65872abefdcb8f
8: 0x769bcc32da16 - std::panicking::begin_panic_handler::{{closure}}::hb1f6277d296c3bf1
9: 0x769bcc32a0d9 - std::sys::backtrace::__rust_end_short_backtrace::haea44604407e5a79
10: 0x769bcc32d72d - __rustc[40318619b3c9f340]::rust_begin_unwind
11: 0x769bc8aa7ee0 - core::panicking::panic_fmt::h6566078d388a5fbd
12: 0x769bc8dfe79c - core::panicking::panic::h4c68868fa581b4af
13: 0x769bcd850117 - <rustc_const_eval[6dd836cff3abf228]::interpret::eval_context::InterpCx<rustc_const_eval[6dd836cff3abf228]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
14: 0x769bcd82e13c - rustc_const_eval[6dd836cff3abf228]::const_eval::eval_queries::eval_to_allocation_raw_provider
15: 0x769bcd82d57e - rustc_query_impl[fb780613ca4d2a4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fb780613ca4d2a4e]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 24usize]>>
16: 0x769bcd820627 - rustc_query_system[f1707db06e6fa3b0]::query::plumbing::try_execute_query::<rustc_query_impl[fb780613ca4d2a4e]::DynamicConfig<rustc_query_system[f1707db06e6fa3b0]::query::caches::DefaultCache<rustc_middle[ff99e1b4bd010738]::ty::PseudoCanonicalInput<rustc_middle[ff99e1b4bd010738]::mir::interpret::GlobalId>, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[fb780613ca4d2a4e]::plumbing::QueryCtxt, false>
17: 0x769bcd8201dd - rustc_query_impl[fb780613ca4d2a4e]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
18: 0x769bcd821e9e - rustc_const_eval[6dd836cff3abf228]::const_eval::valtrees::eval_to_valtree
19: 0x769bcd821c4f - rustc_query_impl[fb780613ca4d2a4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fb780613ca4d2a4e]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 16usize]>>
20: 0x769bccdcb455 - rustc_query_system[f1707db06e6fa3b0]::query::plumbing::try_execute_query::<rustc_query_impl[fb780613ca4d2a4e]::DynamicConfig<rustc_query_system[f1707db06e6fa3b0]::query::caches::DefaultCache<rustc_middle[ff99e1b4bd010738]::ty::PseudoCanonicalInput<rustc_middle[ff99e1b4bd010738]::mir::interpret::GlobalId>, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[fb780613ca4d2a4e]::plumbing::QueryCtxt, false>
21: 0x769bccdcb004 - rustc_query_impl[fb780613ca4d2a4e]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
22: 0x769bccdc9eaa - <rustc_middle[ff99e1b4bd010738]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
23: 0x769bccdc8a05 - rustc_trait_selection[4e9fe4a9859c8b31]::traits::try_evaluate_const
24: 0x769bce4936c4 - rustc_trait_selection[4e9fe4a9859c8b31]::traits::const_evaluatable::is_const_evaluatable.cold
25: 0x769bcd3b0208 - <rustc_trait_selection[4e9fe4a9859c8b31]::traits::fulfill::FulfillProcessor as rustc_data_structures[2cc1fac43b691bbd]::obligation_forest::ObligationProcessor>::process_obligation
26: 0x769bcca05882 - <rustc_data_structures[2cc1fac43b691bbd]::obligation_forest::ObligationForest<rustc_trait_selection[4e9fe4a9859c8b31]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[4e9fe4a9859c8b31]::traits::fulfill::FulfillProcessor>
27: 0x769bcccc0a8b - <rustc_hir_typeck[ce2a1fa2b9119d4e]::fn_ctxt::FnCtxt>::check_expr_call
28: 0x769bcd757807 - <rustc_hir_typeck[ce2a1fa2b9119d4e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
29: 0x769bcd73e3ad - <rustc_hir_typeck[ce2a1fa2b9119d4e]::fn_ctxt::FnCtxt>::check_expr_block
30: 0x769bcd757d60 - <rustc_hir_typeck[ce2a1fa2b9119d4e]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
31: 0x769bcd7481ba - rustc_hir_typeck[ce2a1fa2b9119d4e]::check::check_fn
32: 0x769bcdbddac9 - rustc_hir_typeck[ce2a1fa2b9119d4e]::typeck_with_inspect::{closure#0}
33: 0x769bcdbca570 - rustc_query_impl[fb780613ca4d2a4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fb780613ca4d2a4e]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 8usize]>>
34: 0x769bccbbdcee - rustc_query_system[f1707db06e6fa3b0]::query::plumbing::try_execute_query::<rustc_query_impl[fb780613ca4d2a4e]::DynamicConfig<rustc_data_structures[2cc1fac43b691bbd]::vec_cache::VecCache<rustc_span[352e7d0a703a4e7e]::def_id::LocalDefId, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[f1707db06e6fa3b0]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[fb780613ca4d2a4e]::plumbing::QueryCtxt, false>
35: 0x769bccbbd689 - rustc_query_impl[fb780613ca4d2a4e]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
36: 0x769bcd19379c - rustc_hir_analysis[6759024d2effcf7c]::check_crate
37: 0x769bcd3624e3 - rustc_interface[cb6a4d0f1d73c708]::passes::analysis
38: 0x769bcd3620eb - rustc_query_impl[fb780613ca4d2a4e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[fb780613ca4d2a4e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 0usize]>>
39: 0x769bcdaadb7c - rustc_query_system[f1707db06e6fa3b0]::query::plumbing::try_execute_query::<rustc_query_impl[fb780613ca4d2a4e]::DynamicConfig<rustc_query_system[f1707db06e6fa3b0]::query::caches::SingleCache<rustc_middle[ff99e1b4bd010738]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[fb780613ca4d2a4e]::plumbing::QueryCtxt, false>
40: 0x769bcdaad852 - rustc_query_impl[fb780613ca4d2a4e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
41: 0x769bcdcf0796 - rustc_interface[cb6a4d0f1d73c708]::passes::create_and_enter_global_ctxt::<core[74ad8051f0bf9a77]::option::Option<rustc_interface[cb6a4d0f1d73c708]::queries::Linker>, rustc_driver_impl[9e5e8cd112afe598]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
42: 0x769bcdcca2c3 - rustc_interface[cb6a4d0f1d73c708]::interface::run_compiler::<(), rustc_driver_impl[9e5e8cd112afe598]::run_compiler::{closure#0}>::{closure#1}
43: 0x769bcdc8fc38 - std[97ade9a0245a6b27]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[cb6a4d0f1d73c708]::util::run_in_thread_with_globals<rustc_interface[cb6a4d0f1d73c708]::util::run_in_thread_pool_with_globals<rustc_interface[cb6a4d0f1d73c708]::interface::run_compiler<(), rustc_driver_impl[9e5e8cd112afe598]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
44: 0x769bcdc8f916 - <<std[97ade9a0245a6b27]::thread::Builder>::spawn_unchecked_<rustc_interface[cb6a4d0f1d73c708]::util::run_in_thread_with_globals<rustc_interface[cb6a4d0f1d73c708]::util::run_in_thread_pool_with_globals<rustc_interface[cb6a4d0f1d73c708]::interface::run_compiler<(), rustc_driver_impl[9e5e8cd112afe598]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[74ad8051f0bf9a77]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
45: 0x769bcdc8df3d - std::sys::pal::unix::thread::Thread::new::thread_start::h34e83f2a2995614d
46: 0x769bc765f7eb - <unknown>
47: 0x769bc76e318c - <unknown>
48: 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: please make sure that you have updated to the latest nightly
note: rustc 1.90.0-nightly (fd9ca711a 2025-07-05) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z crate-attr=feature(min_generic_const_args) -Z dump-mir-dir=dir
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `foo::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck] type-checking `main`
#3 [analysis] running analysis passes on this crate
end of query stack
warning: 2 warnings emitted
@rustbot label +F-generic_const_exprs +F-min_generic_const_args
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(generic_const_exprs)]``#![feature(min_generic_const_args)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.This issue may need triage. Remove it if it has been sufficiently triaged.