1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
pub enum EFoo { A, B, C, D }
pub trait Foo {
const X: EFoo;
}
struct Abc;
impl Foo for Abc {
const X: EFoo = EFoo::B;
}
struct Def;
impl Foo for Def {
const X: EFoo = EFoo::D;
}
pub fn test<A: Foo, B: Foo>(arg: EFoo) {
match arg {
A::X => println!("A::X"),
//~^ ERROR constant pattern cannot depend on generic parameters
B::X => println!("B::X"),
//~^ ERROR constant pattern cannot depend on generic parameters
_ => (),
}
}
pub fn test_let_pat<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
//~^ ERROR constant pattern cannot depend on generic parameters
let A::X = arg;
//~^ ERROR constant pattern cannot depend on generic parameters
}
fn main() {
}
|