diff options
| author | bors <bors@rust-lang.org> | 2024-09-14 07:04:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-14 07:04:57 +0000 |
| commit | f9567d0f2bc8f6f7f45c42d432a5dbbd161a6104 (patch) | |
| tree | f9fdc646af42889ab9d89f13694e1a6d96a21cdf /tests | |
| parent | 4a47e8e449da0d4b8252483ecb831c842ff59aa2 (diff) | |
| parent | 1f696384005c27c49ee0e31b1b9031d61b89be6b (diff) | |
| download | rust-f9567d0f2bc8f6f7f45c42d432a5dbbd161a6104.tar.gz rust-f9567d0f2bc8f6f7f45c42d432a5dbbd161a6104.zip | |
Auto merge of #128991 - Nadrieril:rustfix-unreachable-pattern, r=compiler-errors
Add a machine-applicable suggestion to "unreachable pattern"
Diffstat (limited to 'tests')
16 files changed, 469 insertions, 93 deletions
diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr index 60ab4d52c30..ec08e22e2ca 100644 --- a/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-match-check-notes.exhaustive_patterns.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:17:9 | LL | _ => {} - | ^ matches no values because `EmptyEnum` is uninhabited + | ^------ + | | + | matches no values because `EmptyEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:22:9 | LL | _ if false => {} - | ^ matches no values because `EmptyEnum` is uninhabited + | ^--------------- + | | + | matches no values because `EmptyEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -23,7 +29,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:31:9 | LL | _ => {} - | ^ matches no values because `EmptyForeignEnum` is uninhabited + | ^------ + | | + | matches no values because `EmptyForeignEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -31,7 +40,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:36:9 | LL | _ if false => {} - | ^ matches no values because `EmptyForeignEnum` is uninhabited + | ^--------------- + | | + | matches no values because `EmptyForeignEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr b/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr index 60ab4d52c30..ec08e22e2ca 100644 --- a/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-match-check-notes.normal.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:17:9 | LL | _ => {} - | ^ matches no values because `EmptyEnum` is uninhabited + | ^------ + | | + | matches no values because `EmptyEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:22:9 | LL | _ if false => {} - | ^ matches no values because `EmptyEnum` is uninhabited + | ^--------------- + | | + | matches no values because `EmptyEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -23,7 +29,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:31:9 | LL | _ => {} - | ^ matches no values because `EmptyForeignEnum` is uninhabited + | ^------ + | | + | matches no values because `EmptyForeignEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -31,7 +40,10 @@ error: unreachable pattern --> $DIR/empty-match-check-notes.rs:36:9 | LL | _ if false => {} - | ^ matches no values because `EmptyForeignEnum` is uninhabited + | ^--------------- + | | + | matches no values because `EmptyForeignEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index 9decddfe5de..c6e41c1875f 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:49:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:52:9 | LL | _x => {} - | ^^ matches no values because `!` is uninhabited + | ^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -38,7 +44,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:70:9 | LL | (_, _) => {} - | ^^^^^^ matches no values because `(u32, !)` is uninhabited + | ^^^^^^------ + | | + | matches no values because `(u32, !)` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -46,7 +55,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:76:9 | LL | _ => {} - | ^ matches no values because `(!, !)` is uninhabited + | ^------ + | | + | matches no values because `(!, !)` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -54,7 +66,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:79:9 | LL | (_, _) => {} - | ^^^^^^ matches no values because `(!, !)` is uninhabited + | ^^^^^^------ + | | + | matches no values because `(!, !)` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -62,7 +77,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:83:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -89,7 +107,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:94:9 | LL | Err(_) => {} - | ^^^^^^ matches no values because `!` is uninhabited + | ^^^^^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -97,7 +118,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:99:9 | LL | Err(_) => {} - | ^^^^^^ matches no values because `!` is uninhabited + | ^^^^^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -137,7 +161,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:112:9 | LL | _ => {} - | ^ matches no values because `Result<!, !>` is uninhabited + | ^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -145,7 +172,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:115:9 | LL | Ok(_) => {} - | ^^^^^ matches no values because `Result<!, !>` is uninhabited + | ^^^^^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -153,7 +183,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:118:9 | LL | Ok(_) => {} - | ^^^^^ matches no values because `Result<!, !>` is uninhabited + | ^^^^^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -161,7 +194,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:119:9 | LL | _ => {} - | ^ matches no values because `Result<!, !>` is uninhabited + | ^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -169,7 +205,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:122:9 | LL | Ok(_) => {} - | ^^^^^ matches no values because `Result<!, !>` is uninhabited + | ^^^^^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -177,7 +216,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:123:9 | LL | Err(_) => {} - | ^^^^^^ matches no values because `Result<!, !>` is uninhabited + | ^^^^^^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -185,7 +227,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:132:13 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -193,7 +238,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:135:13 | LL | _ if false => {} - | ^ matches no values because `Void` is uninhabited + | ^--------------- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -201,7 +249,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:143:13 | LL | Some(_) => {} - | ^^^^^^^ matches no values because `Void` is uninhabited + | ^^^^^^^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -217,7 +268,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:199:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -225,7 +279,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:204:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -233,7 +290,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:209:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -241,7 +301,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:214:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -249,7 +312,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:220:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -257,7 +323,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:281:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -265,7 +334,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:284:9 | LL | (_, _) => {} - | ^^^^^^ matches no values because `(!, !)` is uninhabited + | ^^^^^^------ + | | + | matches no values because `(!, !)` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -273,7 +345,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:287:9 | LL | Ok(_) => {} - | ^^^^^ matches no values because `Result<!, !>` is uninhabited + | ^^^^^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -281,7 +356,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:288:9 | LL | Err(_) => {} - | ^^^^^^ matches no values because `Result<!, !>` is uninhabited + | ^^^^^^------ + | | + | matches no values because `Result<!, !>` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -344,7 +422,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:368:9 | LL | _ => {} - | ^ matches no values because `[!; 3]` is uninhabited + | ^------ + | | + | matches no values because `[!; 3]` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -352,7 +433,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:371:9 | LL | [_, _, _] => {} - | ^^^^^^^^^ matches no values because `[!; 3]` is uninhabited + | ^^^^^^^^^------ + | | + | matches no values because `[!; 3]` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -360,7 +444,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:374:9 | LL | [_, ..] => {} - | ^^^^^^^ matches no values because `[!; 3]` is uninhabited + | ^^^^^^^------ + | | + | matches no values because `[!; 3]` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -404,7 +491,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:416:9 | LL | Some(_) => {} - | ^^^^^^^ matches no values because `!` is uninhabited + | ^^^^^^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -412,7 +502,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:421:9 | LL | Some(_a) => {} - | ^^^^^^^^ matches no values because `!` is uninhabited + | ^^^^^^^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -438,7 +531,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:603:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -446,7 +542,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:606:9 | LL | _x => {} - | ^^ matches no values because `!` is uninhabited + | ^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -454,7 +553,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:609:9 | LL | _ if false => {} - | ^ matches no values because `!` is uninhabited + | ^--------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -462,7 +564,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:612:9 | LL | _x if false => {} - | ^^ matches no values because `!` is uninhabited + | ^^--------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index fe9c4319820..3f312d46c7e 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -11,7 +11,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:49:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -24,7 +27,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:52:9 | LL | _x => {} - | ^^ matches no values because `!` is uninhabited + | ^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -47,7 +53,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:83:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -120,7 +129,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:132:13 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -128,7 +140,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:135:13 | LL | _ if false => {} - | ^ matches no values because `Void` is uninhabited + | ^--------------- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -155,7 +170,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:199:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -163,7 +181,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:204:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -171,7 +192,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:209:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -179,7 +203,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:214:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -187,7 +214,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:220:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -195,7 +225,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:281:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -476,7 +509,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:603:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -484,7 +520,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:606:9 | LL | _x => {} - | ^^ matches no values because `!` is uninhabited + | ^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -492,7 +531,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:609:9 | LL | _ if false => {} - | ^ matches no values because `!` is uninhabited + | ^--------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -500,7 +542,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:612:9 | LL | _x if false => {} - | ^^ matches no values because `!` is uninhabited + | ^^--------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index 201b0b5c3fd..bba50dab27b 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:49:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:52:9 | LL | _x => {} - | ^^ matches no values because `!` is uninhabited + | ^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -38,7 +44,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:83:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -111,7 +120,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:132:13 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -119,7 +131,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:135:13 | LL | _ if false => {} - | ^ matches no values because `Void` is uninhabited + | ^--------------- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -146,7 +161,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:199:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -154,7 +172,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:204:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -162,7 +183,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:209:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -170,7 +194,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:214:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -178,7 +205,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:220:13 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -186,7 +216,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:281:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -467,7 +500,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:603:9 | LL | _ => {} - | ^ matches no values because `!` is uninhabited + | ^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -475,7 +511,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:606:9 | LL | _x => {} - | ^^ matches no values because `!` is uninhabited + | ^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -483,7 +522,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:609:9 | LL | _ if false => {} - | ^ matches no values because `!` is uninhabited + | ^--------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -491,7 +533,10 @@ error: unreachable pattern --> $DIR/empty-types.rs:612:9 | LL | _x if false => {} - | ^^ matches no values because `!` is uninhabited + | ^^--------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr b/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr index 67f83a85175..8651be2055f 100644 --- a/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr +++ b/tests/ui/pattern/usefulness/explain-unreachable-pats.stderr @@ -59,7 +59,10 @@ error: unreachable pattern --> $DIR/explain-unreachable-pats.rs:52:9 | LL | Err(_) => {} - | ^^^^^^ matches no values because `!` is uninhabited + | ^^^^^^------ + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -67,7 +70,10 @@ error: unreachable pattern --> $DIR/explain-unreachable-pats.rs:66:9 | LL | (Err(_), Err(_)) => {} - | ^^^^^^^^^^^^^^^^ matches no values because `Void2` is uninhabited + | ^^^^^^^^^^^^^^^^------ + | | + | matches no values because `Void2` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -75,7 +81,10 @@ error: unreachable pattern --> $DIR/explain-unreachable-pats.rs:73:9 | LL | (Err(_), Err(_)) => {} - | ^^^^^^^^^^^^^^^^ matches no values because `Void1` is uninhabited + | ^^^^^^^^^^^^^^^^------ + | | + | matches no values because `Void1` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/impl-trait.stderr b/tests/ui/pattern/usefulness/impl-trait.stderr index f2945fca82b..75cba4b5f02 100644 --- a/tests/ui/pattern/usefulness/impl-trait.stderr +++ b/tests/ui/pattern/usefulness/impl-trait.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:17:13 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:31:13 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -23,7 +29,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:45:13 | LL | Some(_) => {} - | ^^^^^^^ matches no values because `Void` is uninhabited + | ^^^^^^^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -39,7 +48,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:59:13 | LL | Some(_) => {} - | ^^^^^^^ matches no values because `Void` is uninhabited + | ^^^^^^^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -55,7 +67,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:76:9 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -71,7 +86,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:94:13 | LL | _ => {} - | ^ matches no values because `Void` is uninhabited + | ^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -95,7 +113,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:138:13 | LL | _ => {} - | ^ matches no values because `SecretelyVoid` is uninhabited + | ^------ + | | + | matches no values because `SecretelyVoid` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types @@ -103,7 +124,10 @@ error: unreachable pattern --> $DIR/impl-trait.rs:151:13 | LL | _ => {} - | ^ matches no values because `SecretelyDoubleVoid` is uninhabited + | ^------ + | | + | matches no values because `SecretelyDoubleVoid` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.fixed b/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.fixed new file mode 100644 index 00000000000..18e3aecbd0d --- /dev/null +++ b/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.fixed @@ -0,0 +1,23 @@ +//@ run-rustfix +#![feature(never_patterns)] +#![feature(exhaustive_patterns)] +#![allow(incomplete_features)] +#![deny(unreachable_patterns)] + +enum Void {} + +#[rustfmt::skip] +fn main() { + let res: Result<(), Void> = Ok(()); + match res { + Ok(_) => {} + //~ ERROR unreachable + //~ ERROR unreachable + } + + match res { + Ok(_x) => {} + //~ ERROR unreachable + //~ ERROR unreachable + } +} diff --git a/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.rs b/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.rs new file mode 100644 index 00000000000..a81420d1496 --- /dev/null +++ b/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.rs @@ -0,0 +1,23 @@ +//@ run-rustfix +#![feature(never_patterns)] +#![feature(exhaustive_patterns)] +#![allow(incomplete_features)] +#![deny(unreachable_patterns)] + +enum Void {} + +#[rustfmt::skip] +fn main() { + let res: Result<(), Void> = Ok(()); + match res { + Ok(_) => {} + Err(_) => {} //~ ERROR unreachable + Err(_) => {}, //~ ERROR unreachable + } + + match res { + Ok(_x) => {} + Err(!), //~ ERROR unreachable + Err(!) //~ ERROR unreachable + } +} diff --git a/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.stderr b/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.stderr new file mode 100644 index 00000000000..bb246cea0a0 --- /dev/null +++ b/tests/ui/pattern/usefulness/rustfix-unreachable-pattern.stderr @@ -0,0 +1,51 @@ +error: unreachable pattern + --> $DIR/rustfix-unreachable-pattern.rs:14:9 + | +LL | Err(_) => {} + | ^^^^^^------ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types +note: the lint level is defined here + --> $DIR/rustfix-unreachable-pattern.rs:5:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/rustfix-unreachable-pattern.rs:15:9 + | +LL | Err(_) => {}, + | ^^^^^^------- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types + +error: unreachable pattern + --> $DIR/rustfix-unreachable-pattern.rs:20:9 + | +LL | Err(!), + | ^^^^^^- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types + +error: unreachable pattern + --> $DIR/rustfix-unreachable-pattern.rs:21:9 + | +LL | Err(!) + | ^^^^^^ + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm + | + = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types + +error: aborting due to 4 previous errors + diff --git a/tests/ui/reachable/unreachable-try-pattern.stderr b/tests/ui/reachable/unreachable-try-pattern.stderr index b082bc11603..40b11613105 100644 --- a/tests/ui/reachable/unreachable-try-pattern.stderr +++ b/tests/ui/reachable/unreachable-try-pattern.stderr @@ -17,7 +17,10 @@ warning: unreachable pattern --> $DIR/unreachable-try-pattern.rs:19:24 | LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?; - | ^^^^^ matches no values because `!` is uninhabited + | ^^^^^----------------- + | | + | matches no values because `!` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -30,7 +33,10 @@ warning: unreachable pattern --> $DIR/unreachable-try-pattern.rs:30:40 | LL | let y = (match x { Ok(n) => Ok(n), Err(e) => Err(e) })?; - | ^^^^^^ matches no values because `Void` is uninhabited + | ^^^^^^---------- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr index 90874760a56..0c9552bb950 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/unreachable.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/unreachable.rs:15:9 | LL | Err(!), - | ^^^^^^ matches no values because `Void` is uninhabited + | ^^^^^^- + | | + | matches no values because `Void` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr index dfd7f9d6300..45a0ca01a56 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/enum_same_crate_empty_match.rs:28:9 | LL | _ => {} - | ^ matches no values because `EmptyNonExhaustiveEnum` is uninhabited + | ^------ + | | + | matches no values because `EmptyNonExhaustiveEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr index 83300049ea9..1bb07fd0671 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/patterns.rs:42:9 | LL | Some(_x) => (), - | ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited + | ^^^^^^^^------- + | | + | matches no values because `UninhabitedVariants` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr index 4b107b03645..bd70a7b4091 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/uninhabited/patterns_same_crate.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/patterns_same_crate.rs:53:9 | LL | Some(_x) => (), - | ^^^^^^^^ matches no values because `UninhabitedEnum` is uninhabited + | ^^^^^^^^------- + | | + | matches no values because `UninhabitedEnum` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/patterns_same_crate.rs:58:9 | LL | Some(_x) => (), - | ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited + | ^^^^^^^^------- + | | + | matches no values because `UninhabitedVariants` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types diff --git a/tests/ui/uninhabited/uninhabited-patterns.stderr b/tests/ui/uninhabited/uninhabited-patterns.stderr index db0166ad5f2..7a872767d95 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-patterns.stderr @@ -2,7 +2,10 @@ error: unreachable pattern --> $DIR/uninhabited-patterns.rs:30:9 | LL | Ok(box _) => (), - | ^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited + | ^^^^^^^^^------- + | | + | matches no values because `NotSoSecretlyEmpty` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here @@ -15,7 +18,10 @@ error: unreachable pattern --> $DIR/uninhabited-patterns.rs:39:9 | LL | Err(Ok(_y)) => (), - | ^^^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited + | ^^^^^^^^^^^------- + | | + | matches no values because `NotSoSecretlyEmpty` is uninhabited + | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types |
