Closed as duplicate of#131406
Closed as duplicate of#131406
Description
Code
#![feature(generic_const_exprs)]
#![feature(min_generic_const_args)]
struct A {
arr: usize,
}
struct B<const N: A> {
arr: [u8; N.arr],
}
struct Struct(u32);
const C: Struct = Struct(42);
fn main() {
let b = B::<C> {};
assert_eq!(b.arr.len(), 5);
}
Meta
rustc --version --verbose
:
binary: rustc
commit-hash: e2014e876e3efaa69bf51c19579adb16c3df5f81
commit-date: 2025-04-01
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.1
Error output
error: overly complex generic constant
--> ./ttt/test.rs:204:15
|
204 | arr: [u8; N.arr],
| ^^^^^ field access is not supported in generic constants
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future
error: `A` is forbidden as the type of a const generic parameter
--> ./ttt/test.rs:202:19
|
202 | struct B<const N: A> {
| ^
|
= note: the only supported types are integers, `bool`, and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
|
199 + #![feature(adt_const_params)]
|
error[E0063]: missing field `arr` in initializer of `B<C>`
--> ./ttt/test.rs:209:13
|
209 | let b = B::<C> {};
| ^^^^^^ missing `arr`
error: the constant `C` is not of type `A`
--> ./ttt/test.rs:209:17
|
209 | let b = B::<C> {};
| ^ expected `A`, found `Struct`
Backtrace
thread 'rustc' panicked at compiler\rustc_const_eval\src\interpret\operand.rs:120:17:
assertion `left == right` failed: invalid field type in Immediate::offset: scalar value has wrong size
left: Size(4 bytes)
right: Size(8 bytes)
stack backtrace:
0: 0x7ff8ceb402f2 - std::backtrace_rs::backtrace::win64::trace
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
1: 0x7ff8ceb402f2 - std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: 0x7ff8ceb402f2 - std::sys::backtrace::_print_fmt
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\sys\backtrace.rs:66
3: 0x7ff8ceb402f2 - std::sys::backtrace::impl$0::print::impl$0::fmt
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\sys\backtrace.rs:39
4: 0x7ff8ceb7364b - core::fmt::rt::Argument::fmt
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\core\src\fmt\rt.rs:178
5: 0x7ff8ceb7364b - core::fmt::write
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\core\src\fmt\mod.rs:1480
6: 0x7ff8ceb36777 - std::io::default_write_fmt
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\io\mod.rs:639
7: 0x7ff8ceb36777 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\io\mod.rs:1914
8: 0x7ff8ceb40135 - std::sys::backtrace::BacktraceLock::print
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\sys\backtrace.rs:42
9: 0x7ff8ceb46ffa - std::panicking::default_hook::closure$0
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\panicking.rs:300
10: 0x7ff8ceb46d90 - std::panicking::default_hook
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\panicking.rs:327
11: 0x7ff8d0210d67 - core[6d088d7b265a6e22]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[2e317b48e3d2ebdb]::Level, &str), usize), <((rustc_lint_defs[2e317b48e3d2ebdb]::Level, &str), usize) as core[6d088d7b265a6e22]::cmp::PartialOrd>::lt>
12: 0x7ff8ceb47c8e - std::panicking::rust_panic_with_hook
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\panicking.rs:841
13: 0x7ff8ceb479e9 - std::panicking::begin_panic_handler::closure$0
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\panicking.rs:706
14: 0x7ff8ceb410bf - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\sys\backtrace.rs:168
15: 0x7ff8ceb475ee - std::panicking::begin_panic_handler
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\panicking.rs:697
16: 0x7ff8d1c1fc01 - core::panicking::panic_fmt
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\core\src\panicking.rs:75
17: 0x7ff8d1c20134 - core::panicking::assert_failed_inner
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\core\src\panicking.rs:420
18: 0x7ff8d18d1407 - core[6d088d7b265a6e22]::panicking::assert_failed::<rustc_abi[dbace1480e496c02]::Size, rustc_abi[dbace1480e496c02]::Size>
19: 0x7ff8cf44527e - <rustc_const_eval[cdeb1530e4b9f185]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
20: 0x7ff8cf563c6e - rustc_const_eval[cdeb1530e4b9f185]::const_eval::eval_queries::eval_to_allocation_raw_provider
21: 0x7ff8cfa276d8 - rustc_query_impl[56f20a7905ba520b]::plumbing::query_key_hash_verify_all
22: 0x7ff8cf91f4b8 - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCseF7WPnEfXL6_12rustc_middle2ty20PseudoCanonicalInputNtNtNtB2y_3mir9interpret8GlobalIdEINtNtNtB2
23: 0x7ff8cfa31093 - rustc_query_impl[56f20a7905ba520b]::plumbing::query_key_hash_verify_all
24: 0x7ff8ce4a1783 - rustc_const_eval[cdeb1530e4b9f185]::const_eval::valtrees::eval_to_valtree
25: 0x7ff8cb4a2ae7 - <alloc[74ed9035c15269e1]::sync::Arc<std[2b19152666764cb3]::sync::poison::mutex::Mutex<core[6d088d7b265a6e22]::option::Option<()>>>>::drop_slow
26: 0x7ff8ce6c6dc8 - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtCs6OLjYz5jF8a_21rustc_data_structures9vec_cache8VecCacheNtNtCsi8XTrxUbIbW_10rustc_span6def_id8CrateNumINtNtNtCseF7WPnEfXL6_12
27: 0x7ff8ce69d0ab - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtCs6OLjYz5jF8a_21rustc_data_structures9vec_cache8VecCacheNtNtCsi8XTrxUbIbW_10rustc_span6def_id8CrateNumINtNtNtCseF7WPnEfXL6_12
28: 0x7ff8cf91f5f6 - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCseF7WPnEfXL6_12rustc_middle2ty20PseudoCanonicalInputNtNtNtB2y_3mir9interpret8GlobalIdEINtNtNtB2
29: 0x7ff8ce6ddc23 - rustc_query_impl[56f20a7905ba520b]::query_system
30: 0x7ff8ce9cd5db - <rustc_middle[aacb0f4b714b863e]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
31: 0x7ff8ce9c9d6f - <rustc_middle[aacb0f4b714b863e]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
32: 0x7ff8ce7e43bf - rustc_trait_selection[3fe63704279140bd]::traits::try_evaluate_const
33: 0x7ff8ce7bff50 - <rustc_trait_selection[3fe63704279140bd]::traits::query::normalize::QueryNormalizer as rustc_type_ir[9d33fc60d68d2dcf]::fold::FallibleTypeFolder<rustc_middle[aacb0f4b714b863e]::ty::context::TyCtxt>>::try_fold_const
34: 0x7ff8ceba6ede - <tracing_subscriber[1d72ba99e274072e]::registry::sharded::Registry as core[6d088d7b265a6e22]::default::Default>::default
35: 0x7ff8cfa282f5 - rustc_query_impl[56f20a7905ba520b]::plumbing::query_key_hash_verify_all
36: 0x7ff8cf91a783 - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCseF7WPnEfXL6_12rustc_middle2ty20PseudoCanonicalInputNtNtB2w_12generic_args10GenericArgEINtNtNtB
37: 0x7ff8cfa39113 - rustc_query_impl[56f20a7905ba520b]::plumbing::query_key_hash_verify_all
38: 0x7ff8ce9985de - <rustc_middle[aacb0f4b714b863e]::ty::normalize_erasing_regions::TryNormalizeAfterErasingRegionsFolder as rustc_type_ir[9d33fc60d68d2dcf]::fold::FallibleTypeFolder<rustc_middle[aacb0f4b714b863e]::ty::context::TyCtxt>>::try_fold_const
39: 0x7ff8d066066b - <rustc_hir_typeck[9044826a83b93224]::writeback::EagerlyNormalizeConsts as rustc_type_ir[9d33fc60d68d2dcf]::fold::TypeFolder<rustc_middle[aacb0f4b714b863e]::ty::context::TyCtxt>>::fold_const
40: 0x7ff8d051353f - RINvNtNtNtNtCs9mnHtfphvnG_4core5slice4sort8unstable8heapsort8heapsortTRNtNtCsi8XTrxUbIbW_10rustc_span6def_id10LocalDefIdRINtNtCsNjHbSUiwjI_8indexmap3map8IndexMapNtNtCsdoLqZK1Fple_9rustc_hir6hir_id5HirIdINtNtCsa2p6rIrRCRF_5alloc3vec3VecNtNtNtCseF7WPnEfXL6_1
41: 0x7ff8d051359b - RINvNtNtNtNtCs9mnHtfphvnG_4core5slice4sort8unstable8heapsort8heapsortTRNtNtCsi8XTrxUbIbW_10rustc_span6def_id10LocalDefIdRINtNtCsNjHbSUiwjI_8indexmap3map8IndexMapNtNtCsdoLqZK1Fple_9rustc_hir6hir_id5HirIdINtNtCsa2p6rIrRCRF_5alloc3vec3VecNtNtNtCseF7WPnEfXL6_1
42: 0x7ff8cede2597 - <rustc_hir_typeck[9044826a83b93224]::upvar::InferBorrowKind as rustc_hir_typeck[9044826a83b93224]::expr_use_visitor::Delegate>::borrow
43: 0x7ff8ced8fe3f - <rustc_hir_typeck[9044826a83b93224]::writeback::WritebackCx as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
44: 0x7ff8ced9025c - <rustc_hir_typeck[9044826a83b93224]::writeback::WritebackCx as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
45: 0x7ff8ced8ff1e - <rustc_hir_typeck[9044826a83b93224]::writeback::WritebackCx as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
46: 0x7ff8ced8ff04 - <rustc_hir_typeck[9044826a83b93224]::writeback::WritebackCx as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
47: 0x7ff8ced904e9 - <rustc_hir_typeck[9044826a83b93224]::writeback::WritebackCx as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
48: 0x7ff8ced90201 - <rustc_hir_typeck[9044826a83b93224]::writeback::WritebackCx as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
49: 0x7ff8ced8578a - <rustc_hir_typeck[9044826a83b93224]::upvar::InferBorrowKindVisitor as rustc_hir[9c124fbbc18ac5d2]::intravisit::Visitor>::visit_expr
50: 0x7ff8cede7386 - <rustc_hir_typeck[9044826a83b93224]::upvar::InferBorrowKind as rustc_hir_typeck[9044826a83b93224]::expr_use_visitor::Delegate>::borrow
51: 0x7ff8ced9512f - rustc_hir_typeck[9044826a83b93224]::typeck
52: 0x7ff8cfa283fb - rustc_query_impl[56f20a7905ba520b]::plumbing::query_key_hash_verify_all
53: 0x7ff8cf96a4bb - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtCs6OLjYz5jF8a_21rustc_data_structures9vec_cache8VecCacheNtNtCsi8XTrxUbIbW_10rustc_span6def_id10LocalDefIdINtNtNtCseF7WPnEfXL6
54: 0x7ff8cfa30942 - rustc_query_impl[56f20a7905ba520b]::plumbing::query_key_hash_verify_all
55: 0x7ff8cee1eb3d - RINvMs6_NtCs9GUOe0vHTal_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCsNjHbSUiwjI_8indexmap3map4core8get_hashTNtNtNtCseF7WPnEfXL6_12rustc_middle2ty9predicate6ClauseNtNtCsi8XTrxUbIbW_10rustc_span13span_encoding4SpanEuE0ECs7279yv5bpcP_18rustc_hir_
56: 0x7ff8ceeb8ce7 - rustc_hir_analysis[51ee44c3c3f46e99]::check_crate
57: 0x7ff8cebb0abf - rustc_interface[75012607f30e9760]::passes::resolver_for_lowering_raw
58: 0x7ff8cb4b6237 - rustc_interface[75012607f30e9760]::passes::analysis
59: 0x7ff8ce6ca91a - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtCs6OLjYz5jF8a_21rustc_data_structures9vec_cache8VecCacheNtNtCsi8XTrxUbIbW_10rustc_span6def_id8CrateNumINtNtNtCseF7WPnEfXL6_12
60: 0x7ff8ce5d42ce - RINvNtNtCsd292uDN0rBR_18rustc_query_system5query8plumbing17try_execute_queryINtCs7sO8FYcisaZ_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCseF7WPnEfXL6_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
61: 0x7ff8ce6d0b43 - rustc_query_impl[56f20a7905ba520b]::query_system
62: 0x7ff8cb479eef - RINvNtNtCs3HpoeEqdUFH_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsa2p6rIrRCRF_5alloc5boxed3BoxDINtNtNtCs9mnHtfphvnG_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECskVE
63: 0x7ff8cb473e23 - RINvNtNtCs3HpoeEqdUFH_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsa2p6rIrRCRF_5alloc5boxed3BoxDINtNtNtCs9mnHtfphvnG_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECskVE
64: 0x7ff8cb46ebd3 - RINvNtNtCs3HpoeEqdUFH_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsa2OlQQRayV8_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCskVEWmdzkxyR_17rustc_driver_i
65: 0x7ff8cb47e4d0 - RINvNtNtCs3HpoeEqdUFH_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCsa2p6rIrRCRF_5alloc5boxed3BoxDINtNtNtCs9mnHtfphvnG_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECskVE
66: 0x7ff8ceb4c9ad - alloc::boxed::impl$28::call_once
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\alloc\src\boxed.rs:1966
67: 0x7ff8ceb4c9ad - alloc::boxed::impl$28::call_once
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\alloc\src\boxed.rs:1966
68: 0x7ff8ceb4c9ad - std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/e2014e876e3efaa69bf51c19579adb16c3df5f81/library\std\src\sys\pal\windows\thread.rs:56
69: 0x7ff9ae2d7374 - BaseThreadInitThunk
70: 0x7ff9ae7bcc91 - RtlUserThreadStart
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: please attach the file at `D:\rust_test\test1\src\rustc-ice-2025-04-02T11_31_48-35012.txt` to your bug report
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `B::arr::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
... and 3 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 4 previous errors; 2 warnings emitted