summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs')
-rw-r--r--tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs b/tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs
new file mode 100644
index 000000000..a38731ceb
--- /dev/null
+++ b/tests/ui/consts/const_in_pattern/custom-eq-branch-pass.rs
@@ -0,0 +1,32 @@
+// run-pass
+
+#![warn(indirect_structural_match)]
+
+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),
+}
+
+const BAR_BAZ: Foo = if 42 == 42 {
+ Foo::Bar
+} else {
+ Foo::Baz
+};
+
+fn main() {
+ match Foo::Qux(CustomEq) {
+ BAR_BAZ => panic!(),
+ _ => {}
+ }
+}