diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-11-05 20:10:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-05 20:10:50 +0100 |
| commit | b23655893e0be24a50a0921e77c638c4f0f75680 (patch) | |
| tree | c56338cbe6f88c61065a73f7866a88cb463d20f8 /compiler/rustc_codegen_llvm/src/errors.rs | |
| parent | 0078e644398015550cc367a15288f4f4b22e44e7 (diff) | |
| parent | 67a85925b14210f5337c30196e1cc15a08686110 (diff) | |
| download | rust-b23655893e0be24a50a0921e77c638c4f0f75680.tar.gz rust-b23655893e0be24a50a0921e77c638c4f0f75680.zip | |
Rollup merge of #132498 - uellenberg:typo-and-let-suggestions, r=estebank
Suggest fixing typos and let bindings at the same time
Fixes #132483
Currently, a suggestion for adding a let binding won't be shown if we suggest fixing a typo. This changes that behavior to always show both, if possible. Essentially, this turns the suggestion from
```rust
error[E0425]: cannot find value `x2` in this scope
--> src/main.rs:4:5
|
4 | x2 = 2;
| ^^ help: a local variable with a similar name exists: `x1`
For more information about this error, try `rustc --explain E0425`.
```
to
```rust
error[E0425]: cannot find value `x2` in this scope
--> src/main.rs:4:5
|
4 | x2 = 2;
| ^^
|
help: a local variable with a similar name exists
|
4 | x1 = 2;
| ~~
help: you might have meant to introduce a new binding
|
4 | let x2 = 2;
| +++
For more information about this error, try `rustc --explain E0425`.
```
for the following code:
```rust
fn main() {
let x1 = 1;
x2 = 2;
}
```
The original behavior only shows the suggestion for a let binding if a typo suggestion wasn't already displayed. However, this falls apart in the cases like the one above where we have multiple similar variables. I don't think it makes sense to hide this suggestion if there's a similar variable, since that defeats the purpose of this suggestion in that case (it's meant to help those coming from languages like Python).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/errors.rs')
0 files changed, 0 insertions, 0 deletions
