Fix unreachable sub-branch detection

This fixes https://github.com/rust-lang/rust/issues/76836
This commit is contained in:
Nadrieril 2020-10-20 22:08:19 +01:00
parent 03f0ca0cf4
commit 25e272e388
4 changed files with 107 additions and 43 deletions

View file

@ -85,7 +85,7 @@ fn main() {
match None {
Some(false) => {}
None | Some(true
| false) => {} // expected unreachable warning here
| false) => {} //~ ERROR unreachable
}
// A subpattern that is unreachable in all branches is overall unreachable.

View file

@ -76,18 +76,18 @@ error: unreachable pattern
LL | (1 | 1,) => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
|
LL | | 0
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:55:15
|
LL | | 0] => {}
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:53:15
|
LL | | 0
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:63:10
|
@ -100,6 +100,12 @@ error: unreachable pattern
LL | Some(0
| ^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:88:19
|
LL | | false) => {}
| ^^^^^
error: unreachable pattern
--> $DIR/exhaustiveness-unreachable-pattern.rs:96:15
|
@ -112,5 +118,5 @@ error: unreachable pattern
LL | | true,
| ^^^^
error: aborting due to 18 previous errors
error: aborting due to 19 previous errors