1
Fork 0

When finding a match expr with multiple arms that requires more, suggest it

Given

```rust
match Some(42) {
    Some(0) => {}
    Some(1) => {}
}
```

suggest

```rust
match Some(42) {
    Some(0) => {}
    Some(1) => {}
    None | Some(_) => todo!(),
}
```
This commit is contained in:
Esteban Kuber 2021-12-16 02:28:09 +00:00
parent 2383858f34
commit 084ca79e7c
28 changed files with 263 additions and 50 deletions

View file

@ -604,6 +604,21 @@ fn non_exhaustive_match<'p, 'tcx>(
format!("{}{}{} => todo!()", comma, pre_indentation, pattern), 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
),
));
}
}
_ => {} _ => {}
} }

View file

@ -37,7 +37,10 @@ LL | let _e = || { match e2 { E2::A => (), E2::B => () } };
| ^^ pattern `_` not covered | ^^ pattern `_` not covered
| |
= note: the matched value is of type `E2`, which is marked as non-exhaustive = 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 error[E0505]: cannot move out of `e3` because it is borrowed
--> $DIR/non-exhaustive-match.rs:46:22 --> $DIR/non-exhaustive-match.rs:46:22

View file

@ -37,7 +37,10 @@ LL | match e2 { E2::A => (), E2::B => () };
| ^^ pattern `_` not covered | ^^ pattern `_` not covered
| |
= note: the matched value is of type `E2`, which is marked as non-exhaustive = 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 error: aborting due to 3 previous errors

View file

@ -5,7 +5,11 @@ LL | match Foo::A {
| ^^^^^^ pattern `_` not covered | ^^^^^^ pattern `_` not covered
| |
= note: the matched value is of type `Foo` = 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 error[E0004]: non-exhaustive patterns: `B` not covered
--> $DIR/doc-hidden-non-exhaustive.rs:14:11 --> $DIR/doc-hidden-non-exhaustive.rs:14:11
@ -19,7 +23,11 @@ LL | B,
| - not covered | - not covered
| |
= note: the matched value is of type `Foo` = 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 error[E0004]: non-exhaustive patterns: `B` and `_` not covered
--> $DIR/doc-hidden-non-exhaustive.rs:20:11 --> $DIR/doc-hidden-non-exhaustive.rs:20:11
@ -51,7 +59,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| ---- not covered | ---- not covered
| |
= note: the matched value is of type `Option<Foo>` = note: the matched value is of type `Option<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 ~ Some(Foo::A) => {}
LL + Some(B) | Some(_) => todo!()
|
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -5,7 +5,11 @@ LL | match 0u8 {
| ^^^ pattern `128_u8..=u8::MAX` not covered | ^^^ pattern `128_u8..=u8::MAX` not covered
| |
= note: the matched value is of type `u8` = 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 error: aborting due to previous error

View file

@ -96,7 +96,11 @@ LL | match 0i8 {
| ^^^ pattern `0_i8` not covered | ^^^ pattern `0_i8` not covered
| |
= note: the matched value is of type `i8` = 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 error[E0004]: non-exhaustive patterns: `u128::MAX` not covered
--> $DIR/exhaustiveness.rs:59:8 --> $DIR/exhaustiveness.rs:59:8
@ -144,7 +148,11 @@ LL | match (0u8, true) {
| ^^^^^^^^^^^ pattern `(126_u8..=127_u8, false)` not covered | ^^^^^^^^^^^ pattern `(126_u8..=127_u8, false)` not covered
| |
= note: the matched value is of type `(u8, bool)` = 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 error: aborting due to 12 previous errors

View file

@ -153,7 +153,11 @@ LL | match 0isize {
= note: the matched value is of type `isize` = 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 = 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: 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 error[E0004]: non-exhaustive patterns: type `usize` is non-empty
--> $DIR/pointer-sized-int.rs:48:11 --> $DIR/pointer-sized-int.rs:48:11

View file

@ -5,7 +5,11 @@ LL | match (T::T1(()), V::V2(true)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `(T1(()), V2(_))` and `(T2(()), V1(_))` not covered | ^^^^^^^^^^^^^^^^^^^^^^^^ patterns `(T1(()), V2(_))` and `(T2(()), V1(_))` not covered
| |
= note: the matched value is of type `(T, V)` = 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 error: aborting due to previous error

View file

@ -5,7 +5,11 @@ LL | match (a, b) {
| ^^^^^^ patterns `(None, None)` and `(Some(_), Some(_))` not covered | ^^^^^^ patterns `(None, None)` and `(Some(_), Some(_))` not covered
| |
= note: the matched value is of type `(Option<usize>, Option<usize>)` = note: the matched value is of type `(Option<usize>, Option<usize>)`
= 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 error: aborting due to previous error

View file

@ -18,7 +18,11 @@ LL | match "world" {
| ^^^^^^^ pattern `&_` not covered | ^^^^^^^ pattern `&_` not covered
| |
= note: the matched value is of type `&str` = 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 error: aborting due to 2 previous errors

View file

@ -102,7 +102,11 @@ LL | match Some(A) {
| ^^^^^^^ patterns `Some(B)`, `Some(C)`, `Some(D)` and 2 more not covered | ^^^^^^^ patterns `Some(B)`, `Some(C)`, `Some(D)` and 2 more not covered
| |
= note: the matched value is of type `Option<Enum>` = note: the matched value is of type `Option<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 ~ None => (),
LL + _ => todo!()
|
error: aborting due to 8 previous errors error: aborting due to 8 previous errors

View file

@ -10,7 +10,11 @@ LL | match f {
| ^ patterns `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered | ^ patterns `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered
| |
= note: the matched value is of type `Foo` = 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 error: aborting due to previous error

View file

@ -5,7 +5,11 @@ LL | println!("foo {:}", match tup {
| ^^^ pattern `(true, false)` not covered | ^^^ pattern `(true, false)` not covered
| |
= note: the matched value is of type `(bool, bool)` = 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 error: aborting due to previous error

View file

@ -15,7 +15,11 @@ LL | match Foo::A(true) {
| ^^^^^^^^^^^^ patterns `A(false)`, `B(false)` and `C(false)` not covered | ^^^^^^^^^^^^ patterns `A(false)`, `B(false)` and `C(false)` not covered
| |
= note: the matched value is of type `Foo` = 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 error: aborting due to previous error

View file

@ -5,7 +5,11 @@ LL | match (x, y) {
| ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered | ^^^^^^ patterns `(A, Some(A))`, `(A, Some(B))`, `(B, Some(B))` and 2 more not covered
| |
= note: the matched value is of type `(X, Option<X>)` = note: the matched value is of type `(X, Option<X>)`
= 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 error: aborting due to previous error

View file

@ -5,7 +5,11 @@ LL | match (true, false) {
| ^^^^^^^^^^^^^ pattern `(true, false)` not covered | ^^^^^^^^^^^^^ pattern `(true, false)` not covered
| |
= note: the matched value is of type `(bool, bool)` = 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 error[E0004]: non-exhaustive patterns: `Some(Some(West))` not covered
--> $DIR/match-arm-statics-2.rs:29:11 --> $DIR/match-arm-statics-2.rs:29:11
@ -22,7 +26,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| not covered | not covered
| |
= note: the matched value is of type `Option<Option<Direction>>` = note: the matched value is of type `Option<Option<Direction>>`
= 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 error[E0004]: non-exhaustive patterns: `Foo { bar: Some(North), baz: NewBool(true) }` not covered
--> $DIR/match-arm-statics-2.rs:48:11 --> $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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { bar: Some(North), baz: NewBool(true) }` not covered
| |
= note: the matched value is of type `Foo` = 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 error: aborting due to 3 previous errors

View file

@ -10,7 +10,11 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
| ---- not covered | ---- not covered
| |
= note: the matched value is of type `Option<Private>` = note: the matched value is of type `Option<Private>`
= 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 error: aborting due to previous error

View file

@ -5,7 +5,11 @@ LL | match list {
| ^^^^ pattern `&[_, Some(_), .., None, _]` not covered | ^^^^ pattern `&[_, Some(_), .., None, _]` not covered
| |
= note: the matched value is of type `&[Option<()>]` = 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 error: aborting due to previous error

View file

@ -5,7 +5,11 @@ LL | match (l1, l2) {
| ^^^^^^^^ pattern `(Some(&[]), Err(_))` not covered | ^^^^^^^^ pattern `(Some(&[]), Err(_))` not covered
| |
= note: the matched value is of type `(Option<&[T]>, Result<&[T], ()>)` = 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 error[E0004]: non-exhaustive patterns: `A(C)` not covered
--> $DIR/non-exhaustive-match-nested.rs:15:11 --> $DIR/non-exhaustive-match-nested.rs:15:11
@ -20,7 +24,11 @@ LL | match x {
| ^ pattern `A(C)` not covered | ^ pattern `A(C)` not covered
| |
= note: the matched value is of type `T` = 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 error: aborting due to 2 previous errors

View file

@ -67,7 +67,11 @@ LL | match (T::A, T::A) {
| ^^^^^^^^^^^^ patterns `(A, A)` and `(B, B)` not covered | ^^^^^^^^^^^^ patterns `(A, A)` and `(B, B)` not covered
| |
= note: the matched value is of type `(T, T)` = 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 error[E0004]: non-exhaustive patterns: `B` not covered
--> $DIR/non-exhaustive-match.rs:22:11 --> $DIR/non-exhaustive-match.rs:22:11
@ -95,7 +99,11 @@ LL | match *vec {
| ^^^^ pattern `[]` not covered | ^^^^ pattern `[]` not covered
| |
= note: the matched value is of type `[Option<isize>]` = note: the matched value is of type `[Option<isize>]`
= 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 error[E0004]: non-exhaustive patterns: `[_, _, _, _, ..]` not covered
--> $DIR/non-exhaustive-match.rs:46:11 --> $DIR/non-exhaustive-match.rs:46:11
@ -104,7 +112,11 @@ LL | match *vec {
| ^^^^ pattern `[_, _, _, _, ..]` not covered | ^^^^ pattern `[_, _, _, _, ..]` not covered
| |
= note: the matched value is of type `[f32]` = 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 error: aborting due to 8 previous errors

View file

@ -11,7 +11,11 @@ LL | match (Foo { first: true, second: None }) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered
| |
= note: the matched value is of type `Foo` = 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 error[E0004]: non-exhaustive patterns: `Red` not covered
--> $DIR/non-exhaustive-pattern-witness.rs:23:11 --> $DIR/non-exhaustive-pattern-witness.rs:23:11
@ -28,7 +32,11 @@ LL | match Color::Red {
| ^^^^^^^^^^ pattern `Red` not covered | ^^^^^^^^^^ pattern `Red` not covered
| |
= note: the matched value is of type `Color` = 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 error[E0004]: non-exhaustive patterns: `East`, `South` and `West` not covered
--> $DIR/non-exhaustive-pattern-witness.rs:35:11 --> $DIR/non-exhaustive-pattern-witness.rs:35:11
@ -85,7 +93,11 @@ LL | match Color::Red {
| ^^^^^^^^^^ pattern `CustomRGBA { a: true, .. }` not covered | ^^^^^^^^^^ pattern `CustomRGBA { a: true, .. }` not covered
| |
= note: the matched value is of type `Color` = 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 error[E0004]: non-exhaustive patterns: `[Second(true), Second(false)]` not covered
--> $DIR/non-exhaustive-pattern-witness.rs:70:11 --> $DIR/non-exhaustive-pattern-witness.rs:70:11
@ -94,7 +106,11 @@ LL | match *x {
| ^^ pattern `[Second(true), Second(false)]` not covered | ^^ pattern `[Second(true), Second(false)]` not covered
| |
= note: the matched value is of type `[Enum]` = 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 error[E0004]: non-exhaustive patterns: `((), false)` not covered
--> $DIR/non-exhaustive-pattern-witness.rs:83:11 --> $DIR/non-exhaustive-pattern-witness.rs:83:11

View file

@ -44,7 +44,11 @@ LL | match s2 {
| ^^ pattern `&[false, true]` not covered | ^^ pattern `&[false, true]` not covered
| |
= note: the matched value is of type `&[bool; 2]` = 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 error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:30:11 --> $DIR/slice-patterns-exhaustiveness.rs:30:11
@ -53,7 +57,11 @@ LL | match s3 {
| ^^ pattern `&[false, .., true]` not covered | ^^ pattern `&[false, .., true]` not covered
| |
= note: the matched value is of type `&[bool; 3]` = 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 error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:35:11 --> $DIR/slice-patterns-exhaustiveness.rs:35:11
@ -62,7 +70,11 @@ LL | match s {
| ^ pattern `&[false, .., true]` not covered | ^ pattern `&[false, .., true]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:42:11 --> $DIR/slice-patterns-exhaustiveness.rs:42:11
@ -84,7 +96,11 @@ LL | match s {
| ^ pattern `&[_, _, ..]` not covered | ^ pattern `&[_, _, ..]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:51:11 --> $DIR/slice-patterns-exhaustiveness.rs:51:11
@ -93,7 +109,11 @@ LL | match s {
| ^ pattern `&[false, ..]` not covered | ^ pattern `&[false, ..]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:56:11 --> $DIR/slice-patterns-exhaustiveness.rs:56:11
@ -102,7 +122,11 @@ LL | match s {
| ^ pattern `&[false, _, ..]` not covered | ^ pattern `&[false, _, ..]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:62:11 --> $DIR/slice-patterns-exhaustiveness.rs:62:11
@ -111,7 +135,11 @@ LL | match s {
| ^ pattern `&[_, .., false]` not covered | ^ pattern `&[_, .., false]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:69:11 --> $DIR/slice-patterns-exhaustiveness.rs:69:11
@ -120,7 +148,11 @@ LL | match s {
| ^ pattern `&[_, _, .., true]` not covered | ^ pattern `&[_, _, .., true]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:76:11 --> $DIR/slice-patterns-exhaustiveness.rs:76:11
@ -129,7 +161,11 @@ LL | match s {
| ^ pattern `&[true, _, .., _]` not covered | ^ pattern `&[true, _, .., _]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:85:11 --> $DIR/slice-patterns-exhaustiveness.rs:85:11
@ -164,7 +200,11 @@ LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered | ^ patterns `&[]` and `&[_, _, ..]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[]` and `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:98:11 --> $DIR/slice-patterns-exhaustiveness.rs:98:11
@ -173,7 +213,11 @@ LL | match s {
| ^ patterns `&[]` and `&[_, _, ..]` not covered | ^ patterns `&[]` and `&[_, _, ..]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:103:11 --> $DIR/slice-patterns-exhaustiveness.rs:103:11
@ -182,7 +226,11 @@ LL | match s {
| ^ pattern `&[_, _, ..]` not covered | ^ pattern `&[_, _, ..]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[false]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:108:11 --> $DIR/slice-patterns-exhaustiveness.rs:108:11
@ -191,7 +239,11 @@ LL | match s {
| ^ pattern `&[false]` not covered | ^ pattern `&[false]` not covered
| |
= note: the matched value is of type `&[bool]` = 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 error[E0004]: non-exhaustive patterns: `&[false]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:121:11 --> $DIR/slice-patterns-exhaustiveness.rs:121:11

View file

@ -23,7 +23,11 @@ LL | match Foo::Stable {
| ^^^^^^^^^^^ pattern `_` not covered | ^^^^^^^^^^^ pattern `_` not covered
| |
= note: the matched value is of type `Foo` = 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 error: aborting due to 2 previous errors

View file

@ -12,7 +12,11 @@ LL | match x {
| ^ pattern `B { x: Some(_) }` not covered | ^ pattern `B { x: Some(_) }` not covered
| |
= note: the matched value is of type `A` = 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 error: aborting due to previous error

View file

@ -8,7 +8,11 @@ LL | match x {
| ^ pattern `Foo(_, _)` not covered | ^ pattern `Foo(_, _)` not covered
| |
= note: the matched value is of type `Foo` = 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 error: aborting due to previous error

View file

@ -18,7 +18,11 @@ LL | match data {
| ^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered | ^^^^ patterns `&[]`, `&[_]`, `&[_, _]` and 1 more not covered
| |
= note: the matched value is of type `&[u8]` = 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 error: aborting due to 2 previous errors

View file

@ -10,7 +10,11 @@ LL | Unstable,
| -------- not covered | -------- not covered
| |
= note: the matched value is of type `Foo` = 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 error: aborting due to previous error

View file

@ -19,7 +19,11 @@ LL | match enum_unit {
| ^^^^^^^^^ pattern `_` not covered | ^^^^^^^^^ pattern `_` not covered
| |
= note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive = 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 error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/enum.rs:23:11 --> $DIR/enum.rs:23:11