Closed as duplicate of#89236
Description
I tried this code:
struct Foo<'a, T>(&'a T);
impl<'a, T> Foo<'a, T> {
const X: usize = 100;
fn what() {
let a = [0; Self::X];
}
}
I expected to see this happen: There should not be an error, the constant should have been evaluated as a literal. Using a literal does not raise the error.
Instead, this happened: Compile time error stating there is a lifetime issue. It requests a bound that shouldn't be neccessary. The error is misleading.
Meta
The bug occurs in my version and the latest stable.
rustc --version --verbose
:
rustc 1.81.0-nightly (bcf94dec5 2024-06-23)
binary: rustc
commit-hash: bcf94dec5ba6838e435902120c0384c360126a26
commit-date: 2024-06-23
host: x86_64-pc-windows-msvc
release: 1.81.0-nightly
LLVM version: 18.1.7