about summary refs log tree commit diff
path: root/tests/ui/error-codes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-26 10:51:04 +0000
committerbors <bors@rust-lang.org>2024-07-26 10:51:04 +0000
commit355efacf0d430331c962a38af39049b76bb6266b (patch)
tree93b3896181a79c48fa9b48229e9f91d6306fbbb3 /tests/ui/error-codes
parent83d67685acb520fe68d5d5adde4b25fb725490de (diff)
parent940769a79b3c71915533d6eddc001a9b71bf5402 (diff)
downloadrust-355efacf0d430331c962a38af39049b76bb6266b.tar.gz
rust-355efacf0d430331c962a38af39049b76bb6266b.zip
Auto merge of #128034 - Nadrieril:explain-unreachable, r=compiler-errors
exhaustiveness: Explain why a given pattern is considered unreachable

This PR tells the user why a given pattern is considered unreachable. I reused the intersection information we were already computing; even though it's incomplete I convinced myself that it is sufficient to always get a set of patterns that cover the unreachable one.

I'm not a fan of the diagnostic messages I came up with, I'm open to suggestions.

Fixes https://github.com/rust-lang/rust/issues/127870. This is also the other one of the two diagnostic improvements I wanted to do before https://github.com/rust-lang/rust/pull/122792.

Note: the first commit is an unrelated drive-by tweak.

r? `@compiler-errors`
Diffstat (limited to 'tests/ui/error-codes')
-rw-r--r--tests/ui/error-codes/E0001.stderr11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/ui/error-codes/E0001.stderr b/tests/ui/error-codes/E0001.stderr
index 49bb73e7ba8..40008230ec8 100644
--- a/tests/ui/error-codes/E0001.stderr
+++ b/tests/ui/error-codes/E0001.stderr
@@ -2,8 +2,17 @@ error: unreachable pattern
   --> $DIR/E0001.rs:8:9
    |
 LL |         _ => {/* ... */}
-   |         ^
+   |         ^ unreachable pattern
    |
+note: these patterns collectively make the last one unreachable
+  --> $DIR/E0001.rs:8:9
+   |
+LL |         Some(_) => {/* ... */}
+   |         ------- matches some of the same values
+LL |         None => {/* ... */}
+   |         ---- matches some of the same values
+LL |         _ => {/* ... */}
+   |         ^ collectively making this unreachable
 note: the lint level is defined here
   --> $DIR/E0001.rs:1:9
    |