Skip to content

Suggested spelling correction seems off-base #72553

Closed
@dtolnay

Description

@dtolnay

In https://www.reddit.com/r/rust/comments/gpw2ra/how_is_the_rust_compiler_able_to_tell_the_visible/ I noticed this surprising spelling suggestion:

#![feature(non_ascii_idents)]

fn main() {
    let _ = 读文;
}
error[E0425]: cannot find value `读文` in this scope
   --> src/main.rs:45:13
    |
45  |     let _ = 读文;
    |             ^^^^ help: a tuple variant with a similar name exists: `Ok`

To me 读文 and Ok don't seem like they would be similar enough to meet the threshold for showing such a suggestion. Can we calibrate this better for short idents?

For comparison, even kO doesn't assume you mean Ok.

error[E0425]: cannot find value `kO` in this scope
  --> src/main.rs:45:13
   |
45 |     let _ = kO;
   |             ^^ not found in this scope

rustc 1.45.0-nightly (8970e8b 2020-05-23)

Mentioning @estebank who worked on suggestions most recently in #65421.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.T-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