Skip to content

Stop triggering similar_names for 3-character names #14869

Open
@amab8901

Description

@amab8901

Summary

The purpose of similar_names is to warn when names are hard to distinguish from each other. It assumes that every pair of names that differ only by a single character must be hard to distinguish. But this isn't true for names that have 3 characters. For example nobody fails to distinguish between words like CEO vs CTO

I think this lint should always remain silent when the names being compared have only 3 characters

Lint Name

similar_names

Reproducer

I tried this code:

fn main() {
    let kta = "lol";
    let ktv = "lol2";

    dbg!(&kta);
    dbg!(&ktv);
}

I saw this happen:

binding's name is too similar to existing binding

I expected to see this happen:

similar_names lint should remain silent in this situation

Version

rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions