Skip to content
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

For a typo let_some_variable =, suggest let some_variable = instead of let let_some_variable = #117894

Closed
carols10cents opened this issue Nov 14, 2023 · 2 comments · Fixed by #117934
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@carols10cents
Copy link
Member

carols10cents commented Nov 14, 2023

Code

fn main() {
    let_some_variable = 6;
}

Current output

error[E0425]: cannot find value `let_some_variable` in this scope
 --> src/main.rs:2:5
  |
2 |     let_some_variable = 6;
  |     ^^^^^^^^^^^^^^^^^
  |
help: you might have meant to introduce a new binding
  |
2 |     let let_some_variable = 6;
  |     +++

Desired output

error[E0425]: cannot find value `let_some_variable` in this scope
 --> src/main.rs:2:5
  |
2 |     let_some_variable = 6;
  |     ^^^^^^^^^^^^^^^^^
  |
help: you might have meant to introduce a new binding
  |
2 |     let some_variable = 6;
  |        +

Rationale and extra context

I accidentally typoed an underscore instead of a space between let and the name of the new variable I was trying to declare. If a binding isn't found, and it starts with let_ (or frankly letsome_variable, if you forget/miss the space completely), it seems like it would be more likely to suggest let (let plus a space) rather than the current suggestion of an additional let .

Other cases

No response

Anything else?

@estebank said I should file this ❤️

@carols10cents carols10cents added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 14, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 14, 2023
@Young-Flash
Copy link
Member

interesting, I'd like to have a try. but might not solve it quicklly casuze I am new to rustc

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 14, 2023
@Noratrieb
Copy link
Member

sounds good! feel free to ask for help if you need it, but the implementation should be fairly simple.
@rustbot assign @Young-Flash

@bors bors closed this as completed in 4fd68eb Nov 24, 2023
RalfJung pushed a commit to RalfJung/miri that referenced this issue Nov 25, 2023
feat: make `let_binding_suggestion` more reasonable

This is my first PR for rustc, which trying to fix rust-lang/rust#117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
feat: make `let_binding_suggestion` more reasonable

This is my first PR for rustc, which trying to fix rust-lang/rust#117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
feat: make `let_binding_suggestion` more reasonable

This is my first PR for rustc, which trying to fix rust-lang/rust#117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants