1 // rust-lang/rust#62614: we want to allow matching on constants of types that
2 // have non-structural-match variants, *if* the constant itself does not use
5 // NOTE: for now, deliberately leaving the lint `indirect_structural_match` set
6 // to its default, so that we will not issue a diangostic even if
7 // rust-lang/rust#62614 remains an open issue.
13 impl PartialEq for Sum {
14 fn eq(&self, other: &Self) -> bool { self.0 + self.1 == other.0 + other.1 }
19 #[derive(PartialEq, Eq)]
25 const THE_CONST: Eek = Eek::TheConst;
26 const SUM_THREE: Eek = Eek::UnusedByTheConst(Sum(3,0));
28 const EEK_ZERO: &[Eek] = &[];
29 const EEK_ONE: &[Eek] = &[THE_CONST];
32 match Eek::UnusedByTheConst(Sum(1,2)) {
33 ref sum if sum == &SUM_THREE => { println!("Hello 0"); }
34 _ => { println!("Gbye"); }
38 THE_CONST => { println!("Hello 1"); }
39 _ => { println!("Gbye"); }
43 match & &Eek::TheConst {
44 & & THE_CONST => { println!("Hello 2"); }
45 _ => { println!("Gbye"); }
49 & & EEK_ZERO => { println!("Hello 3"); }
50 & & EEK_ONE => { println!("Gbye"); }
51 _ => { println!("Gbye"); }
54 match & & &[Eek::TheConst][..] {
55 & & EEK_ZERO => { println!("Gby"); }
56 & & EEK_ONE => { println!("Hello 4"); }
57 _ => { println!("Gbye"); }