diff options
| author | mejrs <> | 2022-12-23 21:02:23 +0100 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2023-01-11 14:40:02 -0800 |
| commit | 31c20210b9683f983953e1a4e45db94146b3c7cb (patch) | |
| tree | e75765ba780b71da1998109e22abe6b64905086e /tests | |
| parent | ef3307289056ac3151a1a6eb29065932e5326bcf (diff) | |
| download | rust-31c20210b9683f983953e1a4e45db94146b3c7cb.tar.gz rust-31c20210b9683f983953e1a4e45db94146b3c7cb.zip | |
Migrate pattern matching
Diffstat (limited to 'tests')
30 files changed, 137 insertions, 135 deletions
diff --git a/tests/ui/consts/const-match-check.eval1.stderr b/tests/ui/consts/const-match-check.eval1.stderr index 6e61dbbd8ee..1caf1617e21 100644 --- a/tests/ui/consts/const-match-check.eval1.stderr +++ b/tests/ui/consts/const-match-check.eval1.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-match-check.rs:25:15 | LL | A = { let 0 = 0; 0 }, diff --git a/tests/ui/consts/const-match-check.eval2.stderr b/tests/ui/consts/const-match-check.eval2.stderr index 1b3b6e06c3d..f038ba1c8ed 100644 --- a/tests/ui/consts/const-match-check.eval2.stderr +++ b/tests/ui/consts/const-match-check.eval2.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-match-check.rs:31:24 | LL | let x: [i32; { let 0 = 0; 0 }] = []; diff --git a/tests/ui/consts/const-match-check.matchck.stderr b/tests/ui/consts/const-match-check.matchck.stderr index bc8edfa7af9..b1921f8a41e 100644 --- a/tests/ui/consts/const-match-check.matchck.stderr +++ b/tests/ui/consts/const-match-check.matchck.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-match-check.rs:4:22 | LL | const X: i32 = { let 0 = 0; 0 }; @@ -12,7 +12,7 @@ help: you might want to use `if let` to ignore the variants that aren't matched LL | const X: i32 = { if let 0 = 0 { todo!() } 0 }; | ++ ~~~~~~~~~~~ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-match-check.rs:8:23 | LL | static Y: i32 = { let 0 = 0; 0 }; @@ -26,7 +26,7 @@ help: you might want to use `if let` to ignore the variants that aren't matched LL | static Y: i32 = { if let 0 = 0 { todo!() } 0 }; | ++ ~~~~~~~~~~~ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-match-check.rs:13:26 | LL | const X: i32 = { let 0 = 0; 0 }; @@ -40,7 +40,7 @@ help: you might want to use `if let` to ignore the variants that aren't matched LL | const X: i32 = { if let 0 = 0 { todo!() } 0 }; | ++ ~~~~~~~~~~~ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `1_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-match-check.rs:19:26 | LL | const X: i32 = { let 0 = 0; 0 }; diff --git a/tests/ui/consts/const-pattern-irrefutable.rs b/tests/ui/consts/const-pattern-irrefutable.rs index 2105c12a168..61bdf57ffdb 100644 --- a/tests/ui/consts/const-pattern-irrefutable.rs +++ b/tests/ui/consts/const-pattern-irrefutable.rs @@ -9,8 +9,20 @@ use foo::d; const a: u8 = 2; fn main() { - let a = 4; //~ ERROR refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX - let c = 4; //~ ERROR refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX - let d = 4; //~ ERROR refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX + let a = 4; + //~^ ERROR refutable pattern in local binding + //~| patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + //~| missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable + //~| HELP introduce a variable instead + let c = 4; + //~^ ERROR refutable pattern in local binding + //~| patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + //~| missing patterns are not covered because `c` is interpreted as a constant pattern, not a new variable + //~| HELP introduce a variable instead + let d = 4; + //~^ ERROR refutable pattern in local binding + //~| patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + //~| missing patterns are not covered because `d` is interpreted as a constant pattern, not a new variable + //~| HELP introduce a variable instead fn f() {} // Check that the `NOTE`s still work with an item here (cf. issue #35115). } diff --git a/tests/ui/consts/const-pattern-irrefutable.stderr b/tests/ui/consts/const-pattern-irrefutable.stderr index a2b8f072c6e..c156ea1610c 100644 --- a/tests/ui/consts/const-pattern-irrefutable.stderr +++ b/tests/ui/consts/const-pattern-irrefutable.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-pattern-irrefutable.rs:12:9 | LL | const a: u8 = 2; @@ -7,13 +7,14 @@ LL | const a: u8 = 2; LL | let a = 4; | ^ | | - | interpreted as a constant pattern, not a new variable + | patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + | missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `a_var` | = note: the matched value is of type `u8` -error[E0005]: refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered - --> $DIR/const-pattern-irrefutable.rs:13:9 +error[E0005]: refutable pattern in local binding + --> $DIR/const-pattern-irrefutable.rs:17:9 | LL | pub const b: u8 = 2; | --------------- constant defined here @@ -21,13 +22,14 @@ LL | pub const b: u8 = 2; LL | let c = 4; | ^ | | - | interpreted as a constant pattern, not a new variable + | patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + | missing patterns are not covered because `c` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `c_var` | = note: the matched value is of type `u8` -error[E0005]: refutable pattern in local binding: `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered - --> $DIR/const-pattern-irrefutable.rs:14:9 +error[E0005]: refutable pattern in local binding + --> $DIR/const-pattern-irrefutable.rs:22:9 | LL | pub const d: u8 = 2; | --------------- constant defined here @@ -35,7 +37,8 @@ LL | pub const d: u8 = 2; LL | let d = 4; | ^ | | - | interpreted as a constant pattern, not a new variable + | patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered + | missing patterns are not covered because `d` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `d_var` | = note: the matched value is of type `u8` diff --git a/tests/ui/consts/const_let_refutable.stderr b/tests/ui/consts/const_let_refutable.stderr index d7e8c048f7d..d6119028f5b 100644 --- a/tests/ui/consts/const_let_refutable.stderr +++ b/tests/ui/consts/const_let_refutable.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in function argument: `&[]`, `&[_]` and `&[_, _, _, ..]` not covered +error[E0005]: refutable pattern in function argument --> $DIR/const_let_refutable.rs:3:16 | LL | const fn slice(&[a, b]: &[i32]) -> i32 { diff --git a/tests/ui/empty/empty-never-array.rs b/tests/ui/empty/empty-never-array.rs index 3de2b1a78a3..fd93346101d 100644 --- a/tests/ui/empty/empty-never-array.rs +++ b/tests/ui/empty/empty-never-array.rs @@ -8,7 +8,8 @@ enum Helper<T, U> { fn transmute<T, U>(t: T) -> U { let Helper::U(u) = Helper::T(t, []); - //~^ ERROR refutable pattern in local binding: `Helper::T(_, _)` not covered + //~^ ERROR refutable pattern in local binding + //~| `Helper::T(_, _)` not covered u } diff --git a/tests/ui/empty/empty-never-array.stderr b/tests/ui/empty/empty-never-array.stderr index adf78274368..9385382f860 100644 --- a/tests/ui/empty/empty-never-array.stderr +++ b/tests/ui/empty/empty-never-array.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `Helper::T(_, _)` not covered +error[E0005]: refutable pattern in local binding --> $DIR/empty-never-array.rs:10:9 | LL | let Helper::U(u) = Helper::T(t, []); @@ -7,18 +7,18 @@ LL | let Helper::U(u) = Helper::T(t, []); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Helper<T, U>` defined here - --> $DIR/empty-never-array.rs:4:5 + --> $DIR/empty-never-array.rs:3:6 | LL | enum Helper<T, U> { - | ------ + | ^^^^^^ LL | T(T, [!; 0]), - | ^ not covered + | - not covered = note: the matched value is of type `Helper<T, U>` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let u = if let Helper::U(u) = Helper::T(t, []) { u } else { todo!() }; | ++++++++++ ++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Helper::U(u) = Helper::T(t, []) else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/error-codes/E0005.stderr b/tests/ui/error-codes/E0005.stderr index 0f179259356..3c27a7d4c06 100644 --- a/tests/ui/error-codes/E0005.stderr +++ b/tests/ui/error-codes/E0005.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `None` not covered +error[E0005]: refutable pattern in local binding --> $DIR/E0005.rs:3:9 | LL | let Some(y) = x; @@ -6,17 +6,12 @@ LL | let Some(y) = x; | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html -note: `Option<i32>` defined here - --> $SRC_DIR/core/src/option.rs:LL:COL - ::: $SRC_DIR/core/src/option.rs:LL:COL - | - = note: not covered = note: the matched value is of type `Option<i32>` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let y = if let Some(y) = x { y } else { todo!() }; | ++++++++++ ++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Some(y) = x else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/error-codes/E0297.stderr b/tests/ui/error-codes/E0297.stderr index 903422f3b9b..293028f5f68 100644 --- a/tests/ui/error-codes/E0297.stderr +++ b/tests/ui/error-codes/E0297.stderr @@ -1,14 +1,9 @@ -error[E0005]: refutable pattern in `for` loop binding: `None` not covered +error[E0005]: refutable pattern in `for` loop binding --> $DIR/E0297.rs:4:9 | LL | for Some(x) in xs {} | ^^^^^^^ pattern `None` not covered | -note: `Option<i32>` defined here - --> $SRC_DIR/core/src/option.rs:LL:COL - ::: $SRC_DIR/core/src/option.rs:LL:COL - | - = note: not covered = note: the matched value is of type `Option<i32>` error: aborting due to previous error diff --git a/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr index e253e4791e8..5e4df7422fc 100644 --- a/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr +++ b/tests/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `Err(_)` not covered +error[E0005]: refutable pattern in local binding --> $DIR/feature-gate-exhaustive-patterns.rs:8:9 | LL | let Ok(_x) = foo(); @@ -6,17 +6,12 @@ LL | let Ok(_x) = foo(); | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html -note: `Result<u32, !>` defined here - --> $SRC_DIR/core/src/result.rs:LL:COL - ::: $SRC_DIR/core/src/result.rs:LL:COL - | - = note: not covered = note: the matched value is of type `Result<u32, !>` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let _x = if let Ok(_x) = foo() { _x } else { todo!() }; | +++++++++++ +++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Ok(_x) = foo() else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/for/for-loop-refutable-pattern-error-message.stderr b/tests/ui/for/for-loop-refutable-pattern-error-message.stderr index 20b689aa5e0..49a82a6769d 100644 --- a/tests/ui/for/for-loop-refutable-pattern-error-message.stderr +++ b/tests/ui/for/for-loop-refutable-pattern-error-message.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in `for` loop binding: `&i32::MIN..=0_i32` and `&2_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in `for` loop binding --> $DIR/for-loop-refutable-pattern-error-message.rs:2:9 | LL | for &1 in [1].iter() {} diff --git a/tests/ui/issues/issue-15381.rs b/tests/ui/issues/issue-15381.rs index 392fb1b24dd..23b266bef1d 100644 --- a/tests/ui/issues/issue-15381.rs +++ b/tests/ui/issues/issue-15381.rs @@ -2,7 +2,8 @@ fn main() { let values: Vec<u8> = vec![1,2,3,4,5,6,7,8]; for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { - //~^ ERROR refutable pattern in `for` loop binding: `&[]`, `&[_]`, `&[_, _]` and 1 more not + //~^ ERROR refutable pattern in `for` loop binding + //~| patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered println!("y={}", y); } } diff --git a/tests/ui/issues/issue-15381.stderr b/tests/ui/issues/issue-15381.stderr index c4667ce1c8b..085958411cc 100644 --- a/tests/ui/issues/issue-15381.stderr +++ b/tests/ui/issues/issue-15381.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in `for` loop binding: `&[]`, `&[_]`, `&[_, _]` and 1 more not covered +error[E0005]: refutable pattern in `for` loop binding --> $DIR/issue-15381.rs:4:9 | LL | for &[x,y,z] in values.chunks(3).filter(|&xs| xs.len() == 3) { diff --git a/tests/ui/never_type/exhaustive_patterns.stderr b/tests/ui/never_type/exhaustive_patterns.stderr index e41baf86218..40c7c1d1067 100644 --- a/tests/ui/never_type/exhaustive_patterns.stderr +++ b/tests/ui/never_type/exhaustive_patterns.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `Either::B(_)` not covered +error[E0005]: refutable pattern in local binding --> $DIR/exhaustive_patterns.rs:20:9 | LL | let Either::A(()) = foo(); @@ -7,13 +7,13 @@ LL | let Either::A(()) = foo(); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Either<(), !>` defined here - --> $DIR/exhaustive_patterns.rs:12:5 + --> $DIR/exhaustive_patterns.rs:10:6 | LL | enum Either<A, B> { - | ------ + | ^^^^^^ LL | A(A), LL | B(inner::Wrapper<B>), - | ^ not covered + | - not covered = note: the matched value is of type `Either<(), !>` help: you might want to use `if let` to ignore the variant that isn't matched | diff --git a/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr b/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr index 95b22ac0594..4adcf4feee9 100644 --- a/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr +++ b/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:2:10 | LL | let (0 | (1 | 2)) = 0; diff --git a/tests/ui/pattern/usefulness/issue-31561.rs b/tests/ui/pattern/usefulness/issue-31561.rs index 5b878851a31..82414f0418b 100644 --- a/tests/ui/pattern/usefulness/issue-31561.rs +++ b/tests/ui/pattern/usefulness/issue-31561.rs @@ -6,5 +6,6 @@ enum Thing { fn main() { let Thing::Foo(y) = Thing::Foo(1); - //~^ ERROR refutable pattern in local binding: `Thing::Bar` and `Thing::Baz` not covered + //~^ ERROR refutable pattern in local binding + //~| `Thing::Bar` and `Thing::Baz` not covered } diff --git a/tests/ui/pattern/usefulness/issue-31561.stderr b/tests/ui/pattern/usefulness/issue-31561.stderr index 20f2f09500a..202fe9de5d3 100644 --- a/tests/ui/pattern/usefulness/issue-31561.stderr +++ b/tests/ui/pattern/usefulness/issue-31561.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `Thing::Bar` and `Thing::Baz` not covered +error[E0005]: refutable pattern in local binding --> $DIR/issue-31561.rs:8:9 | LL | let Thing::Foo(y) = Thing::Foo(1); @@ -7,21 +7,21 @@ LL | let Thing::Foo(y) = Thing::Foo(1); = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Thing` defined here - --> $DIR/issue-31561.rs:3:5 + --> $DIR/issue-31561.rs:1:6 | LL | enum Thing { - | ----- + | ^^^^^ LL | Foo(u8), LL | Bar, - | ^^^ not covered + | --- not covered LL | Baz - | ^^^ not covered + | --- not covered = note: the matched value is of type `Thing` help: you might want to use `if let` to ignore the variants that aren't matched | LL | let y = if let Thing::Foo(y) = Thing::Foo(1) { y } else { todo!() }; | ++++++++++ ++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variants that aren't matched +help: alternatively, you might want to use `let else` to handle the variants that aren't matched | LL | let Thing::Foo(y) = Thing::Foo(1) else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs index af42fc1aeb4..5145f769075 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs +++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs @@ -15,9 +15,6 @@ enum E { //~^ NOTE `E` defined here //~| NOTE `E` defined here //~| NOTE `E` defined here - //~| NOTE `E` defined here - //~| NOTE `E` defined here - //~| NOTE `E` defined here //~| NOTE not covered //~| NOTE not covered //~| NOTE not covered @@ -41,37 +38,41 @@ fn by_val(e: E) { E::A => {} } - let E::A = e; //~ ERROR refutable pattern in local binding: `E::B` and `E::C` not covered - //~^ NOTE patterns `E::B` and `E::C` not covered + let E::A = e; + //~^ ERROR refutable pattern in local binding + //~| patterns `E::B` and `E::C` not covered //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html //~| NOTE the matched value is of type `E` } fn by_ref_once(e: &E) { - match e { //~ ERROR non-exhaustive patterns: `&E::B` and `&E::C` not covered - //~^ NOTE patterns `&E::B` and `&E::C` not covered + match e { + //~^ ERROR non-exhaustive patterns + //~| patterns `&E::B` and `&E::C` not covered //~| NOTE the matched value is of type `&E` E::A => {} } - let E::A = e; //~ ERROR refutable pattern in local binding: `&E::B` and `&E::C` not covered - //~^ NOTE patterns `&E::B` and `&E::C` not covered + let E::A = e; + //~^ ERROR refutable pattern in local binding + //~| patterns `&E::B` and `&E::C` not covered //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html //~| NOTE the matched value is of type `&E` } fn by_ref_thrice(e: & &mut &E) { - match e { //~ ERROR non-exhaustive patterns: `&&mut &E::B` and `&&mut &E::C` not covered - //~^ NOTE patterns `&&mut &E::B` and `&&mut &E::C` not covered + match e { + //~^ ERROR non-exhaustive patterns + //~| patterns `&&mut &E::B` and `&&mut &E::C` not covered //~| NOTE the matched value is of type `&&mut &E` E::A => {} } let E::A = e; - //~^ ERROR refutable pattern in local binding: `&&mut &E::B` and `&&mut &E::C` not covered - //~| NOTE patterns `&&mut &E::B` and `&&mut &E::C` not covered + //~^ ERROR refutable pattern in local binding + //~| patterns `&&mut &E::B` and `&&mut &E::C` not covered //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html //~| NOTE the matched value is of type `&&mut &E` @@ -83,20 +84,21 @@ enum Opt { Some(u8), None, //~^ NOTE `Opt` defined here - //~| NOTE `Opt` defined here //~| NOTE not covered //~| NOTE not covered } fn ref_pat(e: Opt) { - match e {//~ ERROR non-exhaustive patterns: `Opt::None` not covered - //~^ NOTE pattern `Opt::None` not covered + match e { + //~^ ERROR non-exhaustive patterns + //~| pattern `Opt::None` not covered //~| NOTE the matched value is of type `Opt` Opt::Some(ref _x) => {} } - let Opt::Some(ref _x) = e; //~ ERROR refutable pattern in local binding: `Opt::None` not covered - //~^ NOTE the matched value is of type `Opt` + let Opt::Some(ref _x) = e; + //~^ ERROR refutable pattern in local binding + //~| NOTE the matched value is of type `Opt` //~| NOTE pattern `Opt::None` not covered //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr index 678c9b2ab58..3e375066f1b 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `E::B` and `E::C` not covered - --> $DIR/non-exhaustive-defined-here.rs:38:11 + --> $DIR/non-exhaustive-defined-here.rs:35:11 | LL | match e1 { | ^^ patterns `E::B` and `E::C` not covered @@ -22,8 +22,8 @@ LL ~ E::A => {} LL + E::B | E::C => todo!() | -error[E0005]: refutable pattern in local binding: `E::B` and `E::C` not covered - --> $DIR/non-exhaustive-defined-here.rs:44:9 +error[E0005]: refutable pattern in local binding + --> $DIR/non-exhaustive-defined-here.rs:41:9 | LL | let E::A = e; | ^^^^ patterns `E::B` and `E::C` not covered @@ -31,16 +31,16 @@ LL | let E::A = e; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `E` defined here - --> $DIR/non-exhaustive-defined-here.rs:14:5 + --> $DIR/non-exhaustive-defined-here.rs:6:6 | LL | enum E { - | - + | ^ ... LL | B, - | ^ not covered + | - not covered ... LL | C - | ^ not covered + | - not covered = note: the matched value is of type `E` help: you might want to use `if let` to ignore the variants that aren't matched | @@ -48,7 +48,7 @@ LL | if let E::A = e { todo!() } | ++ ~~~~~~~~~~~ error[E0004]: non-exhaustive patterns: `&E::B` and `&E::C` not covered - --> $DIR/non-exhaustive-defined-here.rs:52:11 + --> $DIR/non-exhaustive-defined-here.rs:50:11 | LL | match e { | ^ patterns `&E::B` and `&E::C` not covered @@ -71,8 +71,8 @@ LL ~ E::A => {} LL + &E::B | &E::C => todo!() | -error[E0005]: refutable pattern in local binding: `&E::B` and `&E::C` not covered - --> $DIR/non-exhaustive-defined-here.rs:58:9 +error[E0005]: refutable pattern in local binding + --> $DIR/non-exhaustive-defined-here.rs:57:9 | LL | let E::A = e; | ^^^^ patterns `&E::B` and `&E::C` not covered @@ -80,16 +80,16 @@ LL | let E::A = e; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `E` defined here - --> $DIR/non-exhaustive-defined-here.rs:14:5 + --> $DIR/non-exhaustive-defined-here.rs:6:6 | LL | enum E { - | - + | ^ ... LL | B, - | ^ not covered + | - not covered ... LL | C - | ^ not covered + | - not covered = note: the matched value is of type `&E` help: you might want to use `if let` to ignore the variants that aren't matched | @@ -120,8 +120,8 @@ LL ~ E::A => {} LL + &&mut &E::B | &&mut &E::C => todo!() | -error[E0005]: refutable pattern in local binding: `&&mut &E::B` and `&&mut &E::C` not covered - --> $DIR/non-exhaustive-defined-here.rs:72:9 +error[E0005]: refutable pattern in local binding + --> $DIR/non-exhaustive-defined-here.rs:73:9 | LL | let E::A = e; | ^^^^ patterns `&&mut &E::B` and `&&mut &E::C` not covered @@ -129,16 +129,16 @@ LL | let E::A = e; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `E` defined here - --> $DIR/non-exhaustive-defined-here.rs:14:5 + --> $DIR/non-exhaustive-defined-here.rs:6:6 | LL | enum E { - | - + | ^ ... LL | B, - | ^ not covered + | - not covered ... LL | C - | ^ not covered + | - not covered = note: the matched value is of type `&&mut &E` help: you might want to use `if let` to ignore the variants that aren't matched | @@ -152,7 +152,7 @@ LL | match e { | ^ pattern `Opt::None` not covered | note: `Opt` defined here - --> $DIR/non-exhaustive-defined-here.rs:84:5 + --> $DIR/non-exhaustive-defined-here.rs:85:5 | LL | enum Opt { | --- @@ -166,8 +166,8 @@ LL ~ Opt::Some(ref _x) => {} LL + Opt::None => todo!() | -error[E0005]: refutable pattern in local binding: `Opt::None` not covered - --> $DIR/non-exhaustive-defined-here.rs:98:9 +error[E0005]: refutable pattern in local binding + --> $DIR/non-exhaustive-defined-here.rs:99:9 | LL | let Opt::Some(ref _x) = e; | ^^^^^^^^^^^^^^^^^ pattern `Opt::None` not covered @@ -175,19 +175,19 @@ LL | let Opt::Some(ref _x) = e; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Opt` defined here - --> $DIR/non-exhaustive-defined-here.rs:84:5 + --> $DIR/non-exhaustive-defined-here.rs:81:6 | LL | enum Opt { - | --- + | ^^^ ... LL | None, - | ^^^^ not covered + | ---- not covered = note: the matched value is of type `Opt` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let _x = if let Opt::Some(ref _x) = e { _x } else { todo!() }; | +++++++++++ +++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Opt::Some(ref _x) = e else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs index 7c9aa51e748..7a3e991d593 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs @@ -1,7 +1,9 @@ fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { } -//~^ ERROR refutable pattern in function argument: `(_, _)` not covered +//~^ ERROR refutable pattern in function argument +//~| `(_, _)` not covered fn main() { let (1, (Some(1), 2..=3)) = (1, (None, 2)); - //~^ ERROR refutable pattern in local binding: `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered + //~^ ERROR refutable pattern in local binding + //~| `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered } diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr index d1dacc822e9..c518de47740 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in function argument: `(_, _)` not covered +error[E0005]: refutable pattern in function argument --> $DIR/refutable-pattern-errors.rs:1:9 | LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { } @@ -6,8 +6,8 @@ LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { } | = note: the matched value is of type `(isize, (Option<isize>, isize))` -error[E0005]: refutable pattern in local binding: `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered - --> $DIR/refutable-pattern-errors.rs:5:9 +error[E0005]: refutable pattern in local binding + --> $DIR/refutable-pattern-errors.rs:6:9 | LL | let (1, (Some(1), 2..=3)) = (1, (None, 2)); | ^^^^^^^^^^^^^^^^^^^^^ patterns `(i32::MIN..=0_i32, _)` and `(2_i32..=i32::MAX, _)` not covered diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs index a2d9e1935de..17dc38ab25d 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs +++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs @@ -1,5 +1,6 @@ fn main() { let f = |3: isize| println!("hello"); - //~^ ERROR refutable pattern in function argument: `_` not covered + //~^ ERROR refutable pattern in function argument + //~| `_` not covered f(4); } diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr index c9d8cf43f95..55f0b2319fb 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in function argument: `_` not covered +error[E0005]: refutable pattern in function argument --> $DIR/refutable-pattern-in-fn-arg.rs:2:14 | LL | let f = |3: isize| println!("hello"); diff --git a/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr b/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr index 86ad6aa847c..b7521df88ec 100644 --- a/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr +++ b/tests/ui/recursion/recursive-types-are-not-uninhabited.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `Err(_)` not covered +error[E0005]: refutable pattern in local binding --> $DIR/recursive-types-are-not-uninhabited.rs:6:9 | LL | let Ok(x) = res; @@ -6,17 +6,12 @@ LL | let Ok(x) = res; | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html -note: `Result<u32, &R<'_>>` defined here - --> $SRC_DIR/core/src/result.rs:LL:COL - ::: $SRC_DIR/core/src/result.rs:LL:COL - | - = note: not covered = note: the matched value is of type `Result<u32, &R<'_>>` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let x = if let Ok(x) = res { x } else { todo!() }; | ++++++++++ ++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Ok(x) = res else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs index ac819dce6db..15f08486f0f 100644 --- a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs +++ b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs @@ -1,7 +1,8 @@ fn main() { let A = 3; - //~^ ERROR refutable pattern in local binding: `i32::MIN..=1_i32` and - //~| interpreted as a constant pattern, not a new variable + //~^ ERROR refutable pattern in local binding + //~| patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered + //~| missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable //~| HELP introduce a variable instead //~| SUGGESTION a_var diff --git a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr index 618bcaca14c..1c1cab25fbf 100644 --- a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr +++ b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr @@ -1,10 +1,11 @@ -error[E0005]: refutable pattern in local binding: `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered +error[E0005]: refutable pattern in local binding --> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9 | LL | let A = 3; | ^ | | - | interpreted as a constant pattern, not a new variable + | patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered + | missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `a_var` ... LL | const A: i32 = 2; diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.rs b/tests/ui/uninhabited/uninhabited-irrefutable.rs index 1a0f3c5e550..4b001aca2d1 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.rs +++ b/tests/ui/uninhabited/uninhabited-irrefutable.rs @@ -24,5 +24,7 @@ enum Foo { fn main() { let x: Foo = Foo::D(123, 456); - let Foo::D(_y, _z) = x; //~ ERROR refutable pattern in local binding: `Foo::A(_)` not covered + let Foo::D(_y, _z) = x; + //~^ ERROR refutable pattern in local binding + //~| `Foo::A(_)` not covered } diff --git a/tests/ui/uninhabited/uninhabited-irrefutable.stderr b/tests/ui/uninhabited/uninhabited-irrefutable.stderr index 32f287a1818..461863e1127 100644 --- a/tests/ui/uninhabited/uninhabited-irrefutable.stderr +++ b/tests/ui/uninhabited/uninhabited-irrefutable.stderr @@ -1,4 +1,4 @@ -error[E0005]: refutable pattern in local binding: `Foo::A(_)` not covered +error[E0005]: refutable pattern in local binding --> $DIR/uninhabited-irrefutable.rs:27:9 | LL | let Foo::D(_y, _z) = x; @@ -7,18 +7,18 @@ LL | let Foo::D(_y, _z) = x; = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html note: `Foo` defined here - --> $DIR/uninhabited-irrefutable.rs:19:5 + --> $DIR/uninhabited-irrefutable.rs:18:6 | LL | enum Foo { - | --- + | ^^^ LL | A(foo::SecretlyEmpty), - | ^ not covered + | - not covered = note: the matched value is of type `Foo` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let (_y, _z) = if let Foo::D(_y, _z) = x { (_y, _z) } else { todo!() }; | +++++++++++++++++ +++++++++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Foo::D(_y, _z) = x else { todo!() }; | ++++++++++++++++ diff --git a/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr b/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr index d33a61ca848..2c67eac51f5 100644 --- a/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr +++ b/tests/ui/uninhabited/uninhabited-matches-feature-gated.stderr @@ -95,7 +95,7 @@ LL ~ Ok(x) => x, LL ~ Err(_) => todo!(), | -error[E0005]: refutable pattern in local binding: `Err(_)` not covered +error[E0005]: refutable pattern in local binding --> $DIR/uninhabited-matches-feature-gated.rs:37:9 | LL | let Ok(x) = x; @@ -103,17 +103,12 @@ LL | let Ok(x) = x; | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html -note: `Result<u32, Void>` defined here - --> $SRC_DIR/core/src/result.rs:LL:COL - ::: $SRC_DIR/core/src/result.rs:LL:COL - | - = note: not covered = note: the matched value is of type `Result<u32, Void>` help: you might want to use `if let` to ignore the variant that isn't matched | LL | let x = if let Ok(x) = x { x } else { todo!() }; | ++++++++++ ++++++++++++++++++++++ -help: alternatively, you might want to use let else to handle the variant that isn't matched +help: alternatively, you might want to use `let else` to handle the variant that isn't matched | LL | let Ok(x) = x else { todo!() }; | ++++++++++++++++ |
