about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs9
-rw-r--r--src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr8
2 files changed, 16 insertions, 1 deletions
diff --git a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs
index 59f74919897..e52c6936f12 100644
--- a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs
+++ b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs
@@ -154,4 +154,13 @@ fn main() {
     match 0u128 { //~ ERROR non-exhaustive patterns
         4 ..= u128::MAX => {}
     }
+
+    const FOO: i32 = 42;
+    const BAR: &i32 = &42;
+    match &0 {
+        &42 => {}
+        &FOO => {} //~ ERROR unreachable pattern
+        BAR => {} // not detected as unreachable because `try_eval_bits` fails on BAR
+        _ => {}
+    }
 }
diff --git a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr
index 7a3a36a820c..0fbeb981ea0 100644
--- a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr
+++ b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr
@@ -118,6 +118,12 @@ LL |     match 0u128 {
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error: aborting due to 14 previous errors
+error: unreachable pattern
+  --> $DIR/exhaustive_integer_patterns.rs:162:9
+   |
+LL |         &FOO => {}
+   |         ^^^^
+
+error: aborting due to 15 previous errors
 
 For more information about this error, try `rustc --explain E0004`.