diff options
| author | Nadrieril <nadrieril+git@gmail.com> | 2024-07-24 08:40:04 +0200 |
|---|---|---|
| committer | Nadrieril <nadrieril+git@gmail.com> | 2024-07-24 08:46:52 +0200 |
| commit | 940769a79b3c71915533d6eddc001a9b71bf5402 (patch) | |
| tree | f5255dd356c12ce0531eec71123dc1fd58f4276b /tests/ui/pattern | |
| parent | 64ac2b80822c33d69e6e61ea1eaf8a043bc35aad (diff) | |
| download | rust-940769a79b3c71915533d6eddc001a9b71bf5402.tar.gz rust-940769a79b3c71915533d6eddc001a9b71bf5402.zip | |
Improve "covered_by_many" error
Diffstat (limited to 'tests/ui/pattern')
8 files changed, 102 insertions, 21 deletions
diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index fdec3683c4a..9d3a35321ca 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -122,12 +122,18 @@ LL | BAZ => {} error: unreachable pattern --> $DIR/consts-opaque.rs:87:9 | +LL | _ => {} // should not be emitting unreachable warning + | ^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/consts-opaque.rs:87:9 + | LL | BAZ => {} | --- matches some of the same values LL | Baz::Baz2 => {} | --------- matches some of the same values LL | _ => {} // should not be emitting unreachable warning - | ^ unreachable pattern + | ^ collectively making this unreachable error: aborting due to 17 previous errors diff --git a/tests/ui/pattern/usefulness/explain-unreachable-pats.rs b/tests/ui/pattern/usefulness/explain-unreachable-pats.rs index 6a27f7d4a82..98f781b6a09 100644 --- a/tests/ui/pattern/usefulness/explain-unreachable-pats.rs +++ b/tests/ui/pattern/usefulness/explain-unreachable-pats.rs @@ -22,6 +22,8 @@ fn main() { (1 | 2,) => {} //~^ ERROR unreachable pattern //~| NOTE unreachable pattern + //~| NOTE these patterns collectively make the last one unreachable + //~| NOTE collectively making this unreachable _ => {} } @@ -69,6 +71,8 @@ fn main() { (_, true) => {} //~^ ERROR unreachable pattern //~| NOTE unreachable pattern + //~| NOTE these patterns collectively make the last one unreachable + //~| NOTE collectively making this unreachable } match (true, true) { diff --git a/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr b/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr index 7c2382c26b8..e2eecf4a9f3 100644 --- a/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr +++ b/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr @@ -16,6 +16,12 @@ LL | #![deny(unreachable_patterns)] error: unreachable pattern --> $DIR/explain-unreachable-pats.rs:22:9 | +LL | (1 | 2,) => {} + | ^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/explain-unreachable-pats.rs:22:9 + | LL | (1,) => {} | ---- matches some of the same values LL | @@ -23,10 +29,10 @@ LL | (2,) => {} | ---- matches some of the same values LL | LL | (1 | 2,) => {} - | ^^^^^^^^ unreachable pattern + | ^^^^^^^^ collectively making this unreachable error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:31:9 + --> $DIR/explain-unreachable-pats.rs:33:9 | LL | Err(_) => {} | ^^^^^^ @@ -34,7 +40,7 @@ LL | Err(_) => {} = note: this pattern matches no values because `!` is uninhabited error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:44:9 + --> $DIR/explain-unreachable-pats.rs:46:9 | LL | (Err(_), Err(_)) => {} | ^^^^^^^^^^^^^^^^ @@ -42,7 +48,7 @@ LL | (Err(_), Err(_)) => {} = note: this pattern matches no values because `Void2` is uninhabited error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:50:9 + --> $DIR/explain-unreachable-pats.rs:52:9 | LL | (Err(_), Err(_)) => {} | ^^^^^^^^^^^^^^^^ @@ -50,7 +56,7 @@ LL | (Err(_), Err(_)) => {} = note: this pattern matches no values because `Void1` is uninhabited error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:59:11 + --> $DIR/explain-unreachable-pats.rs:61:11 | LL | if let (0 | - matches all the values already @@ -59,7 +65,13 @@ LL | | 0, _) = (0, 0) {} | ^ unreachable pattern error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:69:9 + --> $DIR/explain-unreachable-pats.rs:71:9 + | +LL | (_, true) => {} + | ^^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/explain-unreachable-pats.rs:71:9 | LL | (true, _) => {} | --------- matches some of the same values @@ -68,10 +80,10 @@ LL | (false, _) => {} | ---------- matches some of the same values LL | LL | (_, true) => {} - | ^^^^^^^^^ unreachable pattern + | ^^^^^^^^^ collectively making this unreachable error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:80:9 + --> $DIR/explain-unreachable-pats.rs:84:9 | LL | (true, _) => {} | --------- matches all the values already @@ -80,7 +92,7 @@ LL | (true, true) => {} | ^^^^^^^^^^^^ unreachable pattern error: unreachable pattern - --> $DIR/explain-unreachable-pats.rs:92:9 + --> $DIR/explain-unreachable-pats.rs:96:9 | LL | (_, true, 0..10) => {} | ---------------- matches all the values already diff --git a/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr b/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr index 8cf81822659..5d86007a853 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/reachability.stderr @@ -135,6 +135,12 @@ LL | m!('a', 'A'..='z', 'a'..='z'); error: unreachable pattern --> $DIR/reachability.rs:50:9 | +LL | 5..=8 => {}, + | ^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/reachability.rs:50:9 + | LL | 5 => {}, | - matches some of the same values LL | 6 => {}, @@ -144,21 +150,33 @@ LL | 7 => {}, LL | 8 => {}, | - matches some of the same values LL | 5..=8 => {}, - | ^^^^^ unreachable pattern + | ^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/reachability.rs:56:9 | +LL | 5..15 => {}, + | ^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/reachability.rs:56:9 + | LL | 0..10 => {}, | ----- matches some of the same values LL | 10..20 => {}, | ------ matches some of the same values LL | 5..15 => {}, - | ^^^^^ unreachable pattern + | ^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/reachability.rs:63:9 | +LL | 5..25 => {}, + | ^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/reachability.rs:63:9 + | LL | 0..10 => {}, | ----- matches some of the same values LL | 10..20 => {}, @@ -166,11 +184,17 @@ LL | 10..20 => {}, LL | 20..30 => {}, | ------ matches some of the same values LL | 5..25 => {}, - | ^^^^^ unreachable pattern + | ^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/reachability.rs:71:9 | +LL | 5..25 => {}, + | ^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/reachability.rs:71:9 + | LL | 0..10 => {}, | ----- matches some of the same values LL | 10 => {}, @@ -180,17 +204,23 @@ LL | 11..=23 => {}, LL | 19..30 => {}, | ------ matches some of the same values LL | 5..25 => {}, - | ^^^^^ unreachable pattern + | ^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/reachability.rs:77:9 | +LL | 5..15 => {}, + | ^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/reachability.rs:77:9 + | LL | 0..10 => {}, | ----- matches some of the same values LL | 10..20 => {}, | ------ matches some of the same values LL | 5..15 => {}, - | ^^^^^ unreachable pattern + | ^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/reachability.rs:84:9 @@ -203,12 +233,18 @@ LL | '\u{D7FF}'..='\u{E000}' => {}, error: unreachable pattern --> $DIR/reachability.rs:89:9 | +LL | '\u{D7FF}'..='\u{E000}' => {}, + | ^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/reachability.rs:89:9 + | LL | '\u{0}'..='\u{D7FF}' => {}, | -------------------- matches some of the same values LL | '\u{E000}'..='\u{10_FFFF}' => {}, | -------------------------- matches some of the same values LL | '\u{D7FF}'..='\u{E000}' => {}, - | ^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern + | ^^^^^^^^^^^^^^^^^^^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/reachability.rs:105:9 diff --git a/tests/ui/pattern/usefulness/issue-12369.stderr b/tests/ui/pattern/usefulness/issue-12369.stderr index dbd6bab6aeb..7754cbc2484 100644 --- a/tests/ui/pattern/usefulness/issue-12369.stderr +++ b/tests/ui/pattern/usefulness/issue-12369.stderr @@ -1,13 +1,18 @@ error: unreachable pattern --> $DIR/issue-12369.rs:9:9 | +LL | &[10,a, ref rest @ ..] => 10 + | ^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/issue-12369.rs:9:9 + | LL | &[a,b,c] => 3, | -------- matches some of the same values LL | &[a, ref rest @ ..] => a, | ------------------- matches some of the same values LL | &[10,a, ref rest @ ..] => 10 - | ^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern - | + | ^^^^^^^^^^^^^^^^^^^^^^ collectively making this unreachable note: the lint level is defined here --> $DIR/issue-12369.rs:1:9 | diff --git a/tests/ui/pattern/usefulness/issue-31221.stderr b/tests/ui/pattern/usefulness/issue-31221.stderr index f564422faae..596f4d8096d 100644 --- a/tests/ui/pattern/usefulness/issue-31221.stderr +++ b/tests/ui/pattern/usefulness/issue-31221.stderr @@ -23,12 +23,18 @@ LL | &Var2 => (), error: unreachable pattern --> $DIR/issue-31221.rs:31:9 | +LL | anything => () + | ^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/issue-31221.rs:31:9 + | LL | (Var1, b) => (), | --------- matches some of the same values LL | (c, d) => (), | ------ matches some of the same values LL | anything => () - | ^^^^^^^^ unreachable pattern + | ^^^^^^^^ collectively making this unreachable error: aborting due to 3 previous errors diff --git a/tests/ui/pattern/usefulness/match-arm-statics.stderr b/tests/ui/pattern/usefulness/match-arm-statics.stderr index 37f1ac58a16..b6f2b47047d 100644 --- a/tests/ui/pattern/usefulness/match-arm-statics.stderr +++ b/tests/ui/pattern/usefulness/match-arm-statics.stderr @@ -25,6 +25,12 @@ LL | Some(Some(East)) => (), error: unreachable pattern --> $DIR/match-arm-statics.rs:60:9 | +LL | Foo { bar: Some(EAST), baz: NewBool(false) } => () + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/match-arm-statics.rs:60:9 + | LL | Foo { bar: _, baz: NEW_FALSE } => (), | ------------------------------ matches some of the same values ... @@ -32,7 +38,7 @@ LL | Foo { bar: Some(EAST), .. } => (), | --------------------------- matches some of the same values LL | Foo { bar: Some(North), baz: NewBool(true) } => (), LL | Foo { bar: Some(EAST), baz: NewBool(false) } => () - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable pattern + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ collectively making this unreachable error: aborting due to 3 previous errors diff --git a/tests/ui/pattern/usefulness/top-level-alternation.stderr b/tests/ui/pattern/usefulness/top-level-alternation.stderr index 0e7e7d4969d..ad846f23155 100644 --- a/tests/ui/pattern/usefulness/top-level-alternation.stderr +++ b/tests/ui/pattern/usefulness/top-level-alternation.stderr @@ -72,12 +72,18 @@ LL | None => {} error: unreachable pattern --> $DIR/top-level-alternation.rs:49:9 | +LL | None | Some(_) => {} + | ^^^^^^^^^^^^^^ unreachable pattern + | +note: these patterns collectively make the last one unreachable + --> $DIR/top-level-alternation.rs:49:9 + | LL | Some(_) => {} | ------- matches some of the same values LL | None => {} | ---- matches some of the same values LL | None | Some(_) => {} - | ^^^^^^^^^^^^^^ unreachable pattern + | ^^^^^^^^^^^^^^ collectively making this unreachable error: unreachable pattern --> $DIR/top-level-alternation.rs:53:9 |
