-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
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"?
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.