Open
Description
Code
//rustc
enum A {
V1(isize) = 1..=10,
V0 = 1..=10,
}
const B: &'static [A] = &[A::V0, A::V1(111)];
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.87.0-nightly (43a2e9d2c 2025-03-17)
binary: rustc
commit-hash: 43a2e9d2c72db101f5fedac8b3acb78981b06bf2
commit-date: 2025-03-17
host: x86_64-pc-windows-msvc
release: 1.87.0-nightly
LLVM version: 20.1.0
Error output
error[E0308]: mismatched types
--> .\ttt\test.rs:200:17
|
200 | V1(isize) = 1..=10,
| ^^^^^^ expected `isize`, found `RangeInclusive<{integer}>`
|
= note: expected type `isize`
found struct `std::ops::RangeInclusive<{integer}>`
error[E0308]: mismatched types
--> .\ttt\test.rs:201:10
|
201 | V0 = 1..=10,
| ^^^^^^ expected `isize`, found `RangeInclusive<{integer}>`
|
= note: expected type `isize`
found struct `std::ops::RangeInclusive<{integer}>`
error[E0732]: `#[repr(inttype)]` must be specified
--> .\ttt\test.rs:199:1
|
199 | enum A {
| ^^^^^^
error[E0080]: it is undefined behavior to use this value
--> .\ttt\test.rs:203:1
|
203 | const B: &'static [A] = &[A::V0, A::V1(111)];
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0].<enum-variant(V1)>.0: encountered uninitialized memory, but expected an integer
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
= note: the raw bytes of the constant (size: 8, align: 8) {
╾─────alloc5<imm>─────╼ │ ╾──────╼
}
error: internal compiler error: compiler\rustc_const_eval\src\interpret\eval_context.rs:555:33: interpret const eval failure of Unevaluated(UnevaluatedConst { def: DefId(0:11 ~ test[ad76]::B), args: [], promoted: Some(promoted[0]) }, &'{erased} [A; 2_usize]) which is not in required_consts
--> .\ttt\test.rs:203:25
|
203 | const B: &'static [A] = &[A::V0, A::V1(111)];
| ^^^^^^^^^^^^^^^^^^^^
Backtrace
thread 'rustc' panicked at compiler\rustc_const_eval\src\interpret\eval_context.rs:555:33:
Box<dyn Any>
stack backtrace:
0: 0x7fffd881c302 - std::backtrace_rs::backtrace::win64::trace
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
1: 0x7fffd881c302 - std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: 0x7fffd881c302 - std::sys::backtrace::_print_fmt
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\sys\backtrace.rs:66
3: 0x7fffd881c302 - std::sys::backtrace::impl$0::print::impl$0::fmt
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\sys\backtrace.rs:39
4: 0x7fffd884f8da - core::fmt::rt::Argument::fmt
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\core\src\fmt\rt.rs:185
5: 0x7fffd884f8da - core::fmt::write
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\core\src\fmt\mod.rs:1449
6: 0x7fffd8812037 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\io\mod.rs:1890
7: 0x7fffd881c145 - std::sys::backtrace::BacktraceLock::print
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\sys\backtrace.rs:42
8: 0x7fffd882074a - std::panicking::default_hook::closure$0
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\panicking.rs:298
9: 0x7fffd88204e0 - std::panicking::default_hook
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\panicking.rs:325
10: 0x7fffd9ec5eb0 - core[81b4d95b7461f626]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[7b15a52ace4ee608]::Level, &str), usize), <((rustc_lint_defs[7b15a52ace4ee608]::Level, &str), usize) as core[81b4d95b7461f626]::cmp::PartialOrd>::lt>
11: 0x7fffd88213de - std::panicking::rust_panic_with_hook
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\panicking.rs:839
12: 0x7fffdb6e0053 - RINvNtNtNtNtCsb8qjbk3i1QE_4core5slice4sort6stable9quicksort9quicksortTjRNtNtCs7Ouf5ymbUgU_12rustc_errors7snippet10AnnotationENCINvMNtCskpOKmTZGxx0_5alloc5sliceSB15_11sort_by_keyTINtNtBa_3cmp7ReversejEbENCNCNvMs5_NtB1c_7emitterNtB3o_12HumanEmitter18render_s
13: 0x7fffdb6d3829 - std[7347f823e08f5e5b]::sys::backtrace::__rust_end_short_backtrace::<std[7347f823e08f5e5b]::panicking::begin_panic<rustc_errors[5b04a96a457e3282]::ExplicitBug>::{closure#0}, !>
14: 0x7fffdb6ce573 - std[7347f823e08f5e5b]::panicking::begin_panic::<rustc_errors[5b04a96a457e3282]::ExplicitBug>
15: 0x7fffdb6ed095 - <rustc_errors[5b04a96a457e3282]::diagnostic::BugAbort as rustc_errors[5b04a96a457e3282]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
16: 0x7fffdb57c7ff - RINvMs6_NtCscaWESsnfg0D_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCs2xJQA1FCCMM_8indexmap3map4core8get_hashTINtNtCs6Qox5OpYOX6_13rustc_type_ir6binder6BinderNtNtNtCs3OSTMt0E1aO_12rustc_middle2ty7context6TyCtxtTRINtNtB2M_4list7RawListuNtB2M_2Ty
17: 0x7fffdb62db46 - rustc_middle[2c80a05783372744]::util::bug::span_bug_fmt::<rustc_span[a3ce9f68409c76e1]::span_encoding::Span>
18: 0x7fffdb6024fd - <rustc_middle[2c80a05783372744]::ty::consts::Const>::to_value
19: 0x7fffdb6022c6 - <rustc_middle[2c80a05783372744]::ty::consts::Const>::to_value
20: 0x7fffdb62daa9 - rustc_middle[2c80a05783372744]::util::bug::span_bug_fmt::<rustc_span[a3ce9f68409c76e1]::span_encoding::Span>
21: 0x7fffd9150371 - <rustc_const_eval[85068a4301714c02]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
22: 0x7fffd924690e - rustc_const_eval[85068a4301714c02]::const_eval::eval_queries::eval_to_allocation_raw_provider
23: 0x7fffd968efa8 - rustc_query_impl[109d9539a846fbf2]::plumbing::query_key_hash_verify_all
24: 0x7fffd95834a0 - RINvNtNtCsl2l0vuiLj5X_18rustc_query_system5query8plumbing17try_execute_queryINtCs1qrxBEorYre_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs3OSTMt0E1aO_12rustc_middle2ty20PseudoCanonicalInputNtNtNtB2y_3mir9interpret8GlobalIdEINtNtNtB2
25: 0x7fffd9698893 - rustc_query_impl[109d9539a846fbf2]::plumbing::query_key_hash_verify_all
26: 0x7fffd9242406 - rustc_const_eval[85068a4301714c02]::const_eval::eval_queries::eval_to_const_value_raw_provider
27: 0x7fffd968f368 - rustc_query_impl[109d9539a846fbf2]::plumbing::query_key_hash_verify_all
28: 0x7fffd9584d93 - RINvNtNtCsl2l0vuiLj5X_18rustc_query_system5query8plumbing17try_execute_queryINtCs1qrxBEorYre_16rustc_query_impl13DynamicConfigINtNtB4_6caches12DefaultCacheINtNtCs3OSTMt0E1aO_12rustc_middle2ty20PseudoCanonicalInputNtNtNtB2y_3mir9interpret8GlobalIdEINtNtNtB2
29: 0x7fffd96989e3 - rustc_query_impl[109d9539a846fbf2]::plumbing::query_key_hash_verify_all
30: 0x7fffd8b047bc - RINvMs6_NtCscaWESsnfg0D_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCs2xJQA1FCCMM_8indexmap3map4core8get_hashTNtNtNtCs3OSTMt0E1aO_12rustc_middle2ty9predicate6ClauseNtNtCse3WmX9EcZFZ_10rustc_span13span_encoding4SpanEuE0ECsejt9BwLGDhc_18rustc_hir
31: 0x7fffd8ba0e77 - rustc_hir_analysis[a6b9746472c88528]::check_crate
32: 0x7fffd889951f - rustc_interface[d41c0f07756b51ae]::passes::resolver_for_lowering_raw
33: 0x7fffd5195d47 - rustc_interface[d41c0f07756b51ae]::passes::analysis
34: 0x7fffd83774da - <alloc[edcd81b74c9613a4]::sync::Arc<rustc_session[49772ba8c1cafbe8]::cstore::CrateSource>>::drop_slow
35: 0x7fffd8288ce4 - RINvNtNtCsl2l0vuiLj5X_18rustc_query_system5query8plumbing17try_execute_queryINtCs1qrxBEorYre_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCs3OSTMt0E1aO_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
36: 0x7fffd837cfd3 - rustc_query_impl[109d9539a846fbf2]::query_system
37: 0x7fffd515d022 - RINvNtNtCs9TDBm4L53x7_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCskpOKmTZGxx0_5alloc5boxed3BoxDINtNtNtCsb8qjbk3i1QE_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsFW2
38: 0x7fffd5155750 - RINvNtNtCs9TDBm4L53x7_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCskpOKmTZGxx0_5alloc5boxed3BoxDINtNtNtCsb8qjbk3i1QE_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsFW2
39: 0x7fffd514df33 - RINvNtNtCs9TDBm4L53x7_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCsid3niany0aw_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCsFW2OdxfghE_17rustc_driver_im
40: 0x7fffd5162220 - RINvNtNtCs9TDBm4L53x7_3std3sys9backtrace28___rust_begin_short_backtraceNCNCNCINvMNtB6_6threadNtB1h_7Builder16spawn_unchecked_INtNtCskpOKmTZGxx0_5alloc5boxed3BoxDINtNtNtCsb8qjbk3i1QE_4core3ops8function6FnOnceuEp6OutputuNtNtB2G_6marker4SendEL_EuEs_000uECsFW2
41: 0x7fffd882cb6d - alloc::boxed::impl$28::call_once
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\alloc\src\boxed.rs:1970
42: 0x7fffd882cb6d - alloc::boxed::impl$28::call_once
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\alloc\src\boxed.rs:1970
43: 0x7fffd882cb6d - std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/43a2e9d2c72db101f5fedac8b3acb78981b06bf2/library\std\src\sys\pal\windows\thread.rs:56
44: 0x7ff88cc67374 - BaseThreadInitThunk
45: 0x7ff88e63cc91 - RtlUserThreadStart
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-03-18T11_49_46-35728.txt` to your bug report
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `B`
#1 [eval_to_const_value_raw] simplifying constant for the type system `B`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
error: aborting due to 5 previous errors