Closed
Description
trait X {
const X: usize;
}
struct A;
struct B;
impl X for A {
const X: usize = 0;
}
impl X for B {
const X: usize = 1;
}
fn do_match<T1: X, T2: X>(x: usize) {
let r = match x {
T1::X => "T1",
T2::X => "T2",
_ => "?",
};
println!("{}", r);
}
fn main() {
do_match::<A, B>(1);
do_match::<A, A>(1);
do_match::<B, B>(1);
}
λ rustc main.rs ~/trash
error[E0158]: statics cannot be referenced in patterns
--> main.rs:18:6
|
18 | T1::X => "T1",
| ^^^^^
error[E0158]: statics cannot be referenced in patterns
--> main.rs:19:6
|
19 | T2::X => "T2",
| ^^^^^
error: aborting due to 2 previous errors
Looks like the error message is slightly off-base? Should it be something along the lines of "can't match on generic constants"?