rust/tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
431 B
Rust
Raw Normal View History

2020-04-07 14:11:29 -05:00
//@ run-pass
struct CustomEq;
impl Eq for CustomEq {}
impl PartialEq for CustomEq {
fn eq(&self, _: &Self) -> bool {
false
}
}
#[derive(PartialEq, Eq)]
#[allow(unused)]
2020-04-07 14:11:29 -05:00
enum Foo {
Bar,
Baz,
Qux(CustomEq),
}
const BAR_BAZ: Foo = if 42 == 42 {
Foo::Bar
} else {
Foo::Qux(CustomEq) // dead arm
2020-04-07 14:11:29 -05:00
};
fn main() {
match Foo::Qux(CustomEq) {
BAR_BAZ => panic!(),
_ => {}
}
}