-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Point at const when intended binding fall-through pattern is a const
``` error[E0004]: non-exhaustive patterns: `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered --> $DIR/intended-binding-pattern-is-const.rs:2:11 | LL | match 1 { | ^ patterns `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered LL | x => {} | - this pattern doesn't introduce a new catch-all binding, but rather pattern matches against the value of constant `x` | = note: the matched value is of type `i32` note: constant `x` defined here --> $DIR/intended-binding-pattern-is-const.rs:7:5 | LL | const x: i32 = 4; | ^^^^^^^^^^^^ help: if you meant to introduce a binding, use a different name | LL | x_var => {} | ++++ help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL | x => {}, i32::MIN..=3_i32 | 5_i32..=i32::MAX => todo!() | ++++++++++++++++++++++++++++++++++++++++++++++++ ```
- Loading branch information
Showing
3 changed files
with
62 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fn main() { | ||
match 1 { //~ ERROR non-exhaustive patterns | ||
//~^ patterns `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered | ||
//~| the matched value is of type `i32` | ||
x => {} //~ this pattern doesn't introduce a new catch-all binding | ||
//~^ HELP ensure that all possible cases are being handled | ||
//~| HELP if you meant to introduce a binding, use a different name | ||
} | ||
const x: i32 = 4; //~ NOTE constant `x` defined here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0004]: non-exhaustive patterns: `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered | ||
--> $DIR/intended-binding-pattern-is-const.rs:2:11 | ||
| | ||
LL | match 1 { | ||
| ^ patterns `i32::MIN..=3_i32` and `5_i32..=i32::MAX` not covered | ||
... | ||
LL | x => {} | ||
| - this pattern doesn't introduce a new catch-all binding, but rather pattern matches against the value of constant `x` | ||
| | ||
= note: the matched value is of type `i32` | ||
note: constant `x` defined here | ||
--> $DIR/intended-binding-pattern-is-const.rs:9:5 | ||
| | ||
LL | const x: i32 = 4; | ||
| ^^^^^^^^^^^^ | ||
help: if you meant to introduce a binding, use a different name | ||
| | ||
LL | x_var => {} | ||
| ++++ | ||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | ||
| | ||
LL | x => {}, i32::MIN..=3_i32 | 5_i32..=i32::MAX => todo!() | ||
| ++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0004`. |