Skip to content

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

Closed
@carols10cents

Description

@carols10cents

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 ❤️

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions