1
Fork 0

Reinstate confusion note.

This commit is contained in:
Camille GILLOT 2023-02-27 20:50:01 +00:00
parent 4d8ed585f2
commit 4f97540432
8 changed files with 63 additions and 61 deletions

View file

@ -12,14 +12,17 @@ fn main() {
let a = 4;
//~^ ERROR refutable pattern in local binding
//~| patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered
//~| HELP you might want to use `if let` to ignore the variants that aren't matched
//~| 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
//~| HELP you might want to use `if let` to ignore the variants that aren't matched
//~| 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
//~| HELP you might want to use `if let` to ignore the variants that aren't matched
//~| 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).
}

View file

@ -2,43 +2,43 @@ error[E0005]: refutable pattern in local binding
--> $DIR/const-pattern-irrefutable.rs:12:9
|
LL | let a = 4;
| ^ patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered
| ^
| |
| 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: `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: the matched value is of type `u8`
help: you might want to use `if let` to ignore the variants that aren't matched
|
LL | if let a = 4 { todo!() };
| ++ +++++++++++
error[E0005]: refutable pattern in local binding
--> $DIR/const-pattern-irrefutable.rs:16:9
--> $DIR/const-pattern-irrefutable.rs:17:9
|
LL | let c = 4;
| ^ patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered
| ^
| |
| 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: `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: the matched value is of type `u8`
help: you might want to use `if let` to ignore the variants that aren't matched
|
LL | if let c = 4 { todo!() };
| ++ +++++++++++
error[E0005]: refutable pattern in local binding
--> $DIR/const-pattern-irrefutable.rs:20:9
--> $DIR/const-pattern-irrefutable.rs:22:9
|
LL | let d = 4;
| ^ patterns `0_u8..=1_u8` and `3_u8..=u8::MAX` not covered
| ^
| |
| 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: `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: the matched value is of type `u8`
help: you might want to use `if let` to ignore the variants that aren't matched
|
LL | if let d = 4 { todo!() };
| ++ +++++++++++
error: aborting due to 3 previous errors