Closed
Description
For this code:
trait Foo {
const BAR: i32;
}
impl Foo for i32 {
const BAR: i32 = 42;
}
fn baz<F: Foo>(a: F) {
const QUX: i32 = F::BAR;
println!("{}", QUX);
}
fn main() {
baz(1i32);
}
I get the error message:
| fn baz<F: Foo>(a: F) {
| --- - type variable from outer function
| |
| try adding a local type parameter in this method instead
| const QUX: i32 = F::BAR;
| ^^^^^^ use of type variable from outer function
QUX
is not a method and cannot have local type parameters; I don't think constants can be generic. So the error message is confusing.