1 // RFC 1445 introduced `#[structural_match]`; this attribute must
2 // appear on the `struct`/`enum` definition for any `const` used in a
5 // This is our (forever-unstable) way to mark a datatype as having a
6 // `PartialEq` implementation that is equivalent to recursion over its
7 // substructure. This avoids (at least in the short term) any need to
8 // resolve the question of what semantics is used for such matching.
9 // (See RFC 1445 for more details and discussion.)
11 // Issue 62307 pointed out a case where the structural-match checking
13 #![warn(indirect_structural_match, nontrivial_structural_match)]
19 // Overriding `PartialEq` to use this strange notion of "equality" exposes
20 // whether `match` is using structural-equality or method-dispatch
21 // under the hood, which is the antithesis of rust-lang/rfcs#1445
22 impl PartialEq for B {
23 fn eq(&self, other: &B) -> bool { std::cmp::min(self.0, other.0) == 0 }
27 const RR_B0: & & B = & & B(0);
28 const RR_B1: & & B = & & B(1);
31 RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); }
32 //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
33 //~| WARN this was previously accepted
38 RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); }
39 //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
40 //~| WARN this was previously accepted