-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest fixing typos and let bindings at the same time #132498
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pnkfelix (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a dedicated ui test whose specific purpose is to track and check this suggestion; error-festival.rs
doesn't seem to be specifically for this suggestion.
42cc20c
to
90cf590
Compare
This comment has been minimized.
This comment has been minimized.
90cf590
to
67a8592
Compare
@bors r+ |
…s, r=estebank Suggest fixing typos and let bindings at the same time Fixes rust-lang#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).
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#132259 (rustc_codegen_llvm: Add a new 'pc' option to branch-protection) - rust-lang#132409 (CI: switch 7 linux jobs to free runners) - rust-lang#132498 (Suggest fixing typos and let bindings at the same time) - rust-lang#132524 (chore(style): sync submodule exclusion list between tidy and rustfmt) - rust-lang#132567 (Properly suggest `E::assoc` when we encounter `E::Variant::assoc`) - rust-lang#132571 (add const_eval_select macro to reduce redundancy) - rust-lang#132637 (Do not filter empty lint passes & re-do CTFE pass) - rust-lang#132642 (Add documentation on `ast::Attribute`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132498 - uellenberg:typo-and-let-suggestions, r=estebank Suggest fixing typos and let bindings at the same time Fixes rust-lang#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).
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
to
for the following code:
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).