diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index f1c2ec08c3cc..a0325101c41d 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -604,6 +604,21 @@ fn non_exhaustive_match<'p, 'tcx>( format!("{}{}{} => todo!()", comma, pre_indentation, pattern), )); } + [.., prev, last] if prev.span.ctxt() == last.span.ctxt() => { + if let Ok(snippet) = sm.span_to_snippet(prev.span.between(last.span)) { + let comma = + if matches!(last.body.kind, hir::ExprKind::Block(..)) { "" } else { "," }; + suggestion = Some(( + last.span.shrink_to_hi(), + format!( + "{}{}{} => todo!()", + comma, + snippet.strip_prefix(",").unwrap_or(&snippet), + pattern + ), + )); + } + } _ => {} } diff --git a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr index 4e5fdbc3d5fb..0ce1f6cf9ada 100644 --- a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr +++ b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr @@ -37,7 +37,10 @@ LL | let _e = || { match e2 { E2::A => (), E2::B => () } }; | ^^ pattern `_` not covered | = note: the matched value is of type `E2`, which is marked as non-exhaustive - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL | let _e = || { match e2 { E2::A => (), E2::B => (), _ => todo!() } }; + | ++++++++++++++ error[E0505]: cannot move out of `e3` because it is borrowed --> $DIR/non-exhaustive-match.rs:46:22 diff --git a/src/test/ui/match/match_non_exhaustive.stderr b/src/test/ui/match/match_non_exhaustive.stderr index 24e37d0851a1..6103975df1e7 100644 --- a/src/test/ui/match/match_non_exhaustive.stderr +++ b/src/test/ui/match/match_non_exhaustive.stderr @@ -37,7 +37,10 @@ LL | match e2 { E2::A => (), E2::B => () }; | ^^ pattern `_` not covered | = note: the matched value is of type `E2`, which is marked as non-exhaustive - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL | match e2 { E2::A => (), E2::B => (), _ => todo!() }; + | ++++++++++++++ error: aborting due to 3 previous errors diff --git a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr index a93d6bd57b60..6c56873ab2d4 100644 --- a/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr +++ b/src/test/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr @@ -5,7 +5,11 @@ LL | match Foo::A { | ^^^^^^ pattern `_` not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo::B => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/doc-hidden-non-exhaustive.rs:14:11 @@ -19,7 +23,11 @@ LL | B, | - not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo::C => {} +LL + B => todo!() + | error[E0004]: non-exhaustive patterns: `B` and `_` not covered --> $DIR/doc-hidden-non-exhaustive.rs:20:11 @@ -51,7 +59,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), | ---- not covered | = note: the matched value is of type `Option` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Some(Foo::A) => {} +LL + Some(B) | Some(_) => todo!() + | error: aborting due to 4 previous errors diff --git a/src/test/ui/pattern/usefulness/guards.stderr b/src/test/ui/pattern/usefulness/guards.stderr index 56707aad148e..4a3b12d58fac 100644 --- a/src/test/ui/pattern/usefulness/guards.stderr +++ b/src/test/ui/pattern/usefulness/guards.stderr @@ -5,7 +5,11 @@ LL | match 0u8 { | ^^^ pattern `128_u8..=u8::MAX` not covered | = note: the matched value is of type `u8` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ 128 ..= 255 if true => {} +LL + 128_u8..=u8::MAX => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr b/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr index 8734d0f04ac4..56de29cbd812 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr @@ -96,7 +96,11 @@ LL | match 0i8 { | ^^^ pattern `0_i8` not covered | = note: the matched value is of type `i8` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ 1 ..= i8::MAX => {} +LL + 0_i8 => todo!() + | error[E0004]: non-exhaustive patterns: `u128::MAX` not covered --> $DIR/exhaustiveness.rs:59:8 @@ -144,7 +148,11 @@ LL | match (0u8, true) { | ^^^^^^^^^^^ pattern `(126_u8..=127_u8, false)` not covered | = note: the matched value is of type `(u8, bool)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (0 ..= 255, true) => {} +LL + (126_u8..=127_u8, false) => todo!() + | error: aborting due to 12 previous errors diff --git a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index 574c9849dbbf..11a3bf5b1778 100644 --- a/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr +++ b/src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -153,7 +153,11 @@ LL | match 0isize { = note: the matched value is of type `isize` = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ 1 ..= isize::MAX => {} +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: type `usize` is non-empty --> $DIR/pointer-sized-int.rs:48:11 diff --git a/src/test/ui/pattern/usefulness/issue-15129.stderr b/src/test/ui/pattern/usefulness/issue-15129.stderr index 94ef44f57a96..5ee2f6825ff6 100644 --- a/src/test/ui/pattern/usefulness/issue-15129.stderr +++ b/src/test/ui/pattern/usefulness/issue-15129.stderr @@ -5,7 +5,11 @@ LL | match (T::T1(()), V::V2(true)) { | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `(T1(()), V2(_))` and `(T2(()), V1(_))` not covered | = note: the matched value is of type `(T, V)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (T::T2(()), V::V2(b)) => (), +LL ~ (T1(()), V2(_)) | (T2(()), V1(_)) => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-2111.stderr b/src/test/ui/pattern/usefulness/issue-2111.stderr index 44a0aee02f2f..ae02d7f7dfca 100644 --- a/src/test/ui/pattern/usefulness/issue-2111.stderr +++ b/src/test/ui/pattern/usefulness/issue-2111.stderr @@ -5,7 +5,11 @@ LL | match (a, b) { | ^^^^^^ patterns `(None, None)` and `(Some(_), Some(_))` not covered | = note: the matched value is of type `(Option, Option)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (Some(_), None) | (None, Some(_)) => {} +LL + (None, None) | (Some(_), Some(_)) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-30240.stderr b/src/test/ui/pattern/usefulness/issue-30240.stderr index e3c4d3ff785e..1c25355b9c45 100644 --- a/src/test/ui/pattern/usefulness/issue-30240.stderr +++ b/src/test/ui/pattern/usefulness/issue-30240.stderr @@ -18,7 +18,11 @@ LL | match "world" { | ^^^^^^^ pattern `&_` not covered | = note: the matched value is of type `&str` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ "hello" => {} +LL + &_ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/issue-35609.stderr b/src/test/ui/pattern/usefulness/issue-35609.stderr index 87ae74c2040d..3c2d351fe8bd 100644 --- a/src/test/ui/pattern/usefulness/issue-35609.stderr +++ b/src/test/ui/pattern/usefulness/issue-35609.stderr @@ -102,7 +102,11 @@ LL | match Some(A) { | ^^^^^^^ patterns `Some(B)`, `Some(C)`, `Some(D)` and 2 more not covered | = note: the matched value is of type `Option` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ None => (), +LL + _ => todo!() + | error: aborting due to 8 previous errors diff --git a/src/test/ui/pattern/usefulness/issue-39362.stderr b/src/test/ui/pattern/usefulness/issue-39362.stderr index 760760eb5d1d..55794faf243a 100644 --- a/src/test/ui/pattern/usefulness/issue-39362.stderr +++ b/src/test/ui/pattern/usefulness/issue-39362.stderr @@ -10,7 +10,11 @@ LL | match f { | ^ patterns `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo::Bar { bar: Bar::B, .. } => (), +LL ~ _ => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-4321.stderr b/src/test/ui/pattern/usefulness/issue-4321.stderr index b1e81f7ffd77..19ee7aaf9bef 100644 --- a/src/test/ui/pattern/usefulness/issue-4321.stderr +++ b/src/test/ui/pattern/usefulness/issue-4321.stderr @@ -5,7 +5,11 @@ LL | println!("foo {:}", match tup { | ^^^ pattern `(true, false)` not covered | = note: the matched value is of type `(bool, bool)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (true, true) => "baz", +LL + (true, false) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-56379.stderr b/src/test/ui/pattern/usefulness/issue-56379.stderr index e8c15035517d..02a5ff2a37ae 100644 --- a/src/test/ui/pattern/usefulness/issue-56379.stderr +++ b/src/test/ui/pattern/usefulness/issue-56379.stderr @@ -15,7 +15,11 @@ LL | match Foo::A(true) { | ^^^^^^^^^^^^ patterns `A(false)`, `B(false)` and `C(false)` not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo::C(true) => {} +LL + A(false) | B(false) | C(false) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/issue-72377.stderr b/src/test/ui/pattern/usefulness/issue-72377.stderr index fa996da1e605..396595b26353 100644 --- a/src/test/ui/pattern/usefulness/issue-72377.stderr +++ b/src/test/ui/pattern/usefulness/issue-72377.stderr @@ -5,7 +5,11 @@ LL | match (x, y) { | ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered | = note: the matched value is of type `(X, Option)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (X::A, Some(X::C)) | (X::C, Some(X::A)) => false, +LL ~ _ => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr b/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr index d1bfdfab9d8f..65fdb1b54f4f 100644 --- a/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr +++ b/src/test/ui/pattern/usefulness/match-arm-statics-2.stderr @@ -5,7 +5,11 @@ LL | match (true, false) { | ^^^^^^^^^^^^^ pattern `(true, false)` not covered | = note: the matched value is of type `(bool, bool)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (false, true) => (), +LL + (true, false) => todo!() + | error[E0004]: non-exhaustive patterns: `Some(Some(West))` not covered --> $DIR/match-arm-statics-2.rs:29:11 @@ -22,7 +26,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), | not covered | = note: the matched value is of type `Option>` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ None => (), +LL + Some(Some(West)) => todo!() + | error[E0004]: non-exhaustive patterns: `Foo { bar: Some(North), baz: NewBool(true) }` not covered --> $DIR/match-arm-statics-2.rs:48:11 @@ -37,7 +45,11 @@ LL | match (Foo { bar: Some(North), baz: NewBool(true) }) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { bar: Some(North), baz: NewBool(true) }` not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo { bar: Some(EAST), .. } => (), +LL + Foo { bar: Some(North), baz: NewBool(true) } => todo!() + | error: aborting due to 3 previous errors diff --git a/src/test/ui/pattern/usefulness/match-privately-empty.stderr b/src/test/ui/pattern/usefulness/match-privately-empty.stderr index 8f32f73db0c9..3b1a7e184ba4 100644 --- a/src/test/ui/pattern/usefulness/match-privately-empty.stderr +++ b/src/test/ui/pattern/usefulness/match-privately-empty.stderr @@ -10,7 +10,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T), | ---- not covered | = note: the matched value is of type `Option` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ }) => {} +LL + Some(Private { misc: true, .. }) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/match-slice-patterns.stderr b/src/test/ui/pattern/usefulness/match-slice-patterns.stderr index 7f48c5f99bdb..3b4fc754dd77 100644 --- a/src/test/ui/pattern/usefulness/match-slice-patterns.stderr +++ b/src/test/ui/pattern/usefulness/match-slice-patterns.stderr @@ -5,7 +5,11 @@ LL | match list { | ^^^^ pattern `&[_, Some(_), .., None, _]` not covered | = note: the matched value is of type `&[Option<()>]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ &[.., Some(_), _] => {} +LL ~ &[_, Some(_), .., None, _] => todo!(), + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr index 518018e16303..e38e12220e33 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr @@ -5,7 +5,11 @@ LL | match (l1, l2) { | ^^^^^^^^ pattern `(Some(&[]), Err(_))` not covered | = note: the matched value is of type `(Option<&[T]>, Result<&[T], ()>)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)", +LL + (Some(&[]), Err(_)) => todo!() + | error[E0004]: non-exhaustive patterns: `A(C)` not covered --> $DIR/non-exhaustive-match-nested.rs:15:11 @@ -20,7 +24,11 @@ LL | match x { | ^ pattern `A(C)` not covered | = note: the matched value is of type `T` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ T::B => { panic!("goodbye"); } +LL + A(C) => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr index 14370915b850..136c653e35d7 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr @@ -67,7 +67,11 @@ LL | match (T::A, T::A) { | ^^^^^^^^^^^^ patterns `(A, A)` and `(B, B)` not covered | = note: the matched value is of type `(T, T)` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ (T::B, T::A) => {} +LL + (A, A) | (B, B) => todo!() + | error[E0004]: non-exhaustive patterns: `B` not covered --> $DIR/non-exhaustive-match.rs:22:11 @@ -95,7 +99,11 @@ LL | match *vec { | ^^^^ pattern `[]` not covered | = note: the matched value is of type `[Option]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [None] => {} +LL + [] => todo!() + | error[E0004]: non-exhaustive patterns: `[_, _, _, _, ..]` not covered --> $DIR/non-exhaustive-match.rs:46:11 @@ -104,7 +112,11 @@ LL | match *vec { | ^^^^ pattern `[_, _, _, _, ..]` not covered | = note: the matched value is of type `[f32]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [] => (), +LL + [_, _, _, _, ..] => todo!() + | error: aborting due to 8 previous errors diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr index 2cf0b320e15f..cb41ee06b15d 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr @@ -11,7 +11,11 @@ LL | match (Foo { first: true, second: None }) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo { first: false, second: Some([1, 2, 3, 4]) } => (), +LL + Foo { first: false, second: Some([_, _, _, _]) } => todo!() + | error[E0004]: non-exhaustive patterns: `Red` not covered --> $DIR/non-exhaustive-pattern-witness.rs:23:11 @@ -28,7 +32,11 @@ LL | match Color::Red { | ^^^^^^^^^^ pattern `Red` not covered | = note: the matched value is of type `Color` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Color::Green => (), +LL + Red => todo!() + | error[E0004]: non-exhaustive patterns: `East`, `South` and `West` not covered --> $DIR/non-exhaustive-pattern-witness.rs:35:11 @@ -85,7 +93,11 @@ LL | match Color::Red { | ^^^^^^^^^^ pattern `CustomRGBA { a: true, .. }` not covered | = note: the matched value is of type `Color` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Color::CustomRGBA { a: false, r: _, g: _, b: _ } => (), +LL + CustomRGBA { a: true, .. } => todo!() + | error[E0004]: non-exhaustive patterns: `[Second(true), Second(false)]` not covered --> $DIR/non-exhaustive-pattern-witness.rs:70:11 @@ -94,7 +106,11 @@ LL | match *x { | ^^ pattern `[Second(true), Second(false)]` not covered | = note: the matched value is of type `[Enum]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [_, _, ref tail @ .., _] => (), +LL + [Second(true), Second(false)] => todo!() + | error[E0004]: non-exhaustive patterns: `((), false)` not covered --> $DIR/non-exhaustive-pattern-witness.rs:83:11 diff --git a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr index 1f6d305b3444..dd1f24fdb677 100644 --- a/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr +++ b/src/test/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr @@ -44,7 +44,11 @@ LL | match s2 { | ^^ pattern `&[false, true]` not covered | = note: the matched value is of type `&[bool; 2]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [.., false] => {} +LL + &[false, true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:30:11 @@ -53,7 +57,11 @@ LL | match s3 { | ^^ pattern `&[false, .., true]` not covered | = note: the matched value is of type `&[bool; 3]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [.., false] => {} +LL + &[false, .., true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:35:11 @@ -62,7 +70,11 @@ LL | match s { | ^ pattern `&[false, .., true]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [.., false] => {} +LL + &[false, .., true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:42:11 @@ -84,7 +96,11 @@ LL | match s { | ^ pattern `&[_, _, ..]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [_] => {} +LL + &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:51:11 @@ -93,7 +109,11 @@ LL | match s { | ^ pattern `&[false, ..]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [true, ..] => {} +LL + &[false, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:56:11 @@ -102,7 +122,11 @@ LL | match s { | ^ pattern `&[false, _, ..]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [true, ..] => {} +LL + &[false, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:62:11 @@ -111,7 +135,11 @@ LL | match s { | ^ pattern `&[_, .., false]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [.., true] => {} +LL + &[_, .., false] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:69:11 @@ -120,7 +148,11 @@ LL | match s { | ^ pattern `&[_, _, .., true]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [.., false] => {} +LL + &[_, _, .., true] => todo!() + | error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:76:11 @@ -129,7 +161,11 @@ LL | match s { | ^ pattern `&[true, _, .., _]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [false, .., false] => {} +LL + &[true, _, .., _] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:85:11 @@ -164,7 +200,11 @@ LL | match s { | ^ patterns `&[]` and `&[_, _, ..]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ &[false] => {} +LL + &[] | &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:98:11 @@ -173,7 +213,11 @@ LL | match s { | ^ patterns `&[]` and `&[_, _, ..]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ CONST => {} +LL + &[] | &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:103:11 @@ -182,7 +226,11 @@ LL | match s { | ^ pattern `&[_, _, ..]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ CONST => {} +LL + &[_, _, ..] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:108:11 @@ -191,7 +239,11 @@ LL | match s { | ^ pattern `&[false]` not covered | = note: the matched value is of type `&[bool]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ &[_, _, ..] => {} +LL + &[false] => todo!() + | error[E0004]: non-exhaustive patterns: `&[false]` not covered --> $DIR/slice-patterns-exhaustiveness.rs:121:11 diff --git a/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr b/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr index 5897bb4177a7..a556094c370c 100644 --- a/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr +++ b/src/test/ui/pattern/usefulness/stable-gated-patterns.stderr @@ -23,7 +23,11 @@ LL | match Foo::Stable { | ^^^^^^^^^^^ pattern `_` not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo::Stable2 => {} +LL + _ => todo!() + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr b/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr index 6dc67f95a466..02009ea3eed0 100644 --- a/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr +++ b/src/test/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr @@ -12,7 +12,11 @@ LL | match x { | ^ pattern `B { x: Some(_) }` not covered | = note: the matched value is of type `A` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ A::B { x: None } => {} +LL + B { x: Some(_) } => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr index a5ba50ac0b01..455760d22496 100644 --- a/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr +++ b/src/test/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr @@ -8,7 +8,11 @@ LL | match x { | ^ pattern `Foo(_, _)` not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo(2, b) => println!("{}", b) +LL + Foo(_, _) => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr b/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr index b83865d90c74..1f0bf5ccca5b 100644 --- a/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr +++ b/src/test/ui/pattern/usefulness/type_polymorphic_byte_str_literals.stderr @@ -18,7 +18,11 @@ LL | match data { | ^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered | = note: the matched value is of type `&[u8]` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ [_, _, _] => 1, +LL ~ _ => todo!(), + | error: aborting due to 2 previous errors diff --git a/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr b/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr index 6f1233b5ee9f..a0717c5e0bff 100644 --- a/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr +++ b/src/test/ui/pattern/usefulness/unstable-gated-patterns.stderr @@ -10,7 +10,11 @@ LL | Unstable, | -------- not covered | = note: the matched value is of type `Foo` - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ Foo::Stable2 => {} +LL + Unstable => todo!() + | error: aborting due to previous error diff --git a/src/test/ui/rfc-2008-non-exhaustive/enum.stderr b/src/test/ui/rfc-2008-non-exhaustive/enum.stderr index 8fc0b4feb259..c8e27d5e3587 100644 --- a/src/test/ui/rfc-2008-non-exhaustive/enum.stderr +++ b/src/test/ui/rfc-2008-non-exhaustive/enum.stderr @@ -19,7 +19,11 @@ LL | match enum_unit { | ^^^^^^^^^ pattern `_` not covered | = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive - = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms +help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms + | +LL ~ NonExhaustiveEnum::Struct { .. } => "third", +LL + _ => todo!() + | error[E0004]: non-exhaustive patterns: `_` not covered --> $DIR/enum.rs:23:11