diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-26 15:56:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-26 15:56:26 -0700 |
| commit | 54744601bfae6d3e09ea8c958beab8d58e850434 (patch) | |
| tree | 55c483d009372461096b597086e2606c076cc1a4 /src/test | |
| parent | 389dda149c0524c7d5b8d2020ace3cbc97bda60b (diff) | |
| parent | 69715c903312c3e734bfd9098a5e8773f2e19d01 (diff) | |
| download | rust-54744601bfae6d3e09ea8c958beab8d58e850434.tar.gz rust-54744601bfae6d3e09ea8c958beab8d58e850434.zip | |
Rollup merge of #100817 - vincenzopalazzo:macros/bool_spelling_sugg, r=davidtwco
sugg: suggest the usage of boolean value when there is a typo in the keyword
Fixes https://github.com/rust-lang/rust/issues/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>
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/suggestions/bool_typo_err_suggest.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/suggestions/bool_typo_err_suggest.stderr | 25 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/bool_typo_err_suggest.rs b/src/test/ui/suggestions/bool_typo_err_suggest.rs new file mode 100644 index 00000000000..deab0fb05b7 --- /dev/null +++ b/src/test/ui/suggestions/bool_typo_err_suggest.rs @@ -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 +} diff --git a/src/test/ui/suggestions/bool_typo_err_suggest.stderr b/src/test/ui/suggestions/bool_typo_err_suggest.stderr new file mode 100644 index 00000000000..52bde07ca07 --- /dev/null +++ b/src/test/ui/suggestions/bool_typo_err_suggest.stderr @@ -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`. |
