-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #64859 - Centril:const-def-here-new-var, r=estebank
check_match: improve diagnostics for `let A = 2;` with `const A: i32 = 3` For example: ``` error[E0005]: refutable pattern in local binding: `std::i32::MIN..=1i32` and `3i32..=std::i32::MAX` not covered --> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9 | LL | let A = 3; | ^ | | | interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `a_var` ... LL | const A: i32 = 2; | ----------------- constant defined here ``` r? @estebank cc @matthiaskrgr @rpjohnst
- Loading branch information
Showing
7 changed files
with
96 additions
and
26 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
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
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
10 changes: 10 additions & 0 deletions
10
src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
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() { | ||
let A = 3; | ||
//~^ ERROR refutable pattern in local binding: `std::i32::MIN..=1i32` and | ||
//~| interpreted as a constant pattern, not a new variable | ||
//~| HELP introduce a variable instead | ||
//~| SUGGESTION a_var | ||
|
||
const A: i32 = 2; | ||
//~^ constant defined here | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr
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,15 @@ | ||
error[E0005]: refutable pattern in local binding: `std::i32::MIN..=1i32` and `3i32..=std::i32::MAX` not covered | ||
--> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9 | ||
| | ||
LL | let A = 3; | ||
| ^ | ||
| | | ||
| interpreted as a constant pattern, not a new variable | ||
| help: introduce a variable instead: `a_var` | ||
... | ||
LL | const A: i32 = 2; | ||
| ----------------- constant defined here | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0005`. |