//rustc
enum A {
V1(isize) = 1..=10,
V0 = 1..=10,
}
const B: &'static [A] = &[A::V0, A::V1(111)];
fn main() {}
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[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)];
| ^^^^^^^^^^^^^^^^^^^^
Code
Meta
rustc --version --verbose:Error output
Backtrace