2020-04-07 14:11:29 -05:00
|
|
|
// check-pass
|
|
|
|
|
|
|
|
struct CustomEq;
|
|
|
|
|
|
|
|
impl Eq for CustomEq {}
|
|
|
|
impl PartialEq for CustomEq {
|
|
|
|
fn eq(&self, _: &Self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq)]
|
|
|
|
enum Foo {
|
|
|
|
Bar,
|
|
|
|
Baz,
|
|
|
|
Qux(CustomEq),
|
|
|
|
}
|
|
|
|
|
|
|
|
// We know that `BAR_BAZ` will always be `Foo::Bar` and thus eligible for structural matching, but
|
|
|
|
// dataflow will be more conservative.
|
|
|
|
const BAR_BAZ: Foo = if 42 == 42 {
|
|
|
|
Foo::Bar
|
|
|
|
} else {
|
|
|
|
Foo::Qux(CustomEq)
|
|
|
|
};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match Foo::Qux(CustomEq) {
|
|
|
|
BAR_BAZ => panic!(),
|
|
|
|
//~^ WARN must be annotated with `#[derive(PartialEq, Eq)]`
|
2023-03-27 09:14:08 -05:00
|
|
|
//~| NOTE the traits must be derived
|
|
|
|
//~| NOTE StructuralEq.html for details
|
2020-04-07 14:11:29 -05:00
|
|
|
//~| WARN this was previously accepted
|
2020-09-20 10:22:33 -05:00
|
|
|
//~| NOTE see issue #73448
|
|
|
|
//~| NOTE `#[warn(nontrivial_structural_match)]` on by default
|
2020-04-07 14:11:29 -05:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|