forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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 rust-lang#100817 - vincenzopalazzo:macros/bool_spelli…
…ng_sugg, r=davidtwco sugg: suggest the usage of boolean value when there is a typo in the keyword Fixes rust-lang#100686 This adds a new suggestion when there is a well-known typo With the following program ```rust fn main() { let x = True; } ``` Now we have the following suggestion ``` error[E0425]: cannot find value `True` in this scope --> test.rs:2:13 | 2 | let x = True; | ^^^^ not found in this scope | help: you may want to use a bool value instead | 2 | let x = true; | ~~~~ error: aborting due to previous error ``` Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
- Loading branch information
Showing
3 changed files
with
59 additions
and
5 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,12 @@ | ||
// Suggest the boolean value instead of emit a generic error that the value | ||
// True is not in the scope. | ||
|
||
fn main() { | ||
let x = True; | ||
//~^ ERROR cannot find value `True` in this scope | ||
//~| HELP you may want to use a bool value instead | ||
|
||
let y = False; | ||
//~^ ERROR cannot find value `False` in this scope | ||
//~| HELP you may want to use a bool value instead | ||
} |
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,25 @@ | ||
error[E0425]: cannot find value `True` in this scope | ||
--> $DIR/bool_typo_err_suggest.rs:5:13 | ||
| | ||
LL | let x = True; | ||
| ^^^^ not found in this scope | ||
| | ||
help: you may want to use a bool value instead | ||
| | ||
LL | let x = true; | ||
| ~~~~ | ||
|
||
error[E0425]: cannot find value `False` in this scope | ||
--> $DIR/bool_typo_err_suggest.rs:9:13 | ||
| | ||
LL | let y = False; | ||
| ^^^^^ not found in this scope | ||
| | ||
help: you may want to use a bool value instead | ||
| | ||
LL | let y = false; | ||
| ~~~~~ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |