Skip to content

Conversation

xizheyin
Copy link
Member

This PR extends is_case_difference to handle digit-letter confusables

Add support for detecting 0/O, 1/l, 5/S, 8/B, 9/g confusables in error suggestions.

r? @estebank

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 30, 2025
Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nitpicks.

@rust-log-analyzer

This comment has been minimized.

Comment on lines +3572 to +3592
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ConfusionType {
/// No confusion detected
None,
/// Only case differences (e.g., "hello" vs "Hello")
Case,
/// Only digit-letter confusion (e.g., "0" vs "O", "1" vs "l")
DigitLetter,
/// Both case and digit-letter confusion
Both,
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I define a enum to handle different cases.

help: write it in the correct case (notice the capitalization difference)
help: write it in the correct case (notice the capitalization)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove difference to keep consistency.


let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];

let digit_letter_confusables = [('0', 'O'), ('1', 'l'), ('5', 'S'), ('8', 'B'), ('9', 'g')];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep simple and use reverse

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Jul 31, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 31, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 31, 2025

📌 Commit 7b667e7 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2025
bors added a commit that referenced this pull request Aug 1, 2025
Rollup of 7 pull requests

Successful merges:

 - #143849 (rustdoc: never link to unnamable items)
 - #144683 (Simplify library dependencies on `compiler-builtins`)
 - #144691 (Extend `is_case_difference` to handle digit-letter confusables)
 - #144700 (rustdoc-json: Move `#[macro_export]` from `Other` to it's own  variant)
 - #144751 (Add correct dynamic_lib_extension for aix)
 - #144757 (Ping Muscraft when emitter change)
 - #144759 (triagebot: Label `compiler-builtins` T-libs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c7ec9bc into rust-lang:master Aug 1, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Aug 1, 2025
rust-timer added a commit that referenced this pull request Aug 1, 2025
Rollup merge of #144691 - xizheyin:suggest-confuse, r=estebank

Extend `is_case_difference` to handle digit-letter confusables

This PR extends `is_case_difference` to handle digit-letter confusables

Add support for detecting 0/O, 1/l, 5/S, 8/B, 9/g confusables in error suggestions.

r? `@estebank`

let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];

let digit_letter_confusables = [('0', 'O'), ('1', 'l'), ('5', 'S'), ('8', 'B'), ('9', 'g')];
Copy link

@roadrunnerto100 roadrunnerto100 Aug 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 1 and capital i?

And lowercase L and capital i?

flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 7, 2025
Extend `is_case_difference` to handle digit-letter confusables

This PR extends `is_case_difference` to handle digit-letter confusables

Add support for detecting 0/O, 1/l, 5/S, 8/B, 9/g confusables in error suggestions.

r? `@estebank`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants