Closed
Description
Code
fn main() {}
trait Trait {
const X: u32;
}
impl Trait for () {
const X: u32 = 0;
}
impl<T: Trait> Trait for [T] {
const X: u32 = {
const TEMP: u32 = T::X + 1;
TEMP
};
}
Current output
error[E0401]: can't use generic parameters from outer function
--> src/main.rs:13:27
|
11 | impl<T: Trait> Trait for [T] {
| - type parameter from outer function
12 | const X: u32 = {
13 | const TEMP: u32 = T::X + 1;
| - ^^^^ use of generic parameter from outer function
| |
| help: try using a local generic parameter instead: `<T>`
For more information about this error, try `rustc --explain E0401`.
Desired output
I'm not sure what the output should be (I'm not even sure why this does not compile), but using a local generic parameter does not make sense for me. It seems like the error message thinks this code is inside a function.