Extend is_case_difference to handle digit-letter confusables#144691
Merged
bors merged 1 commit intorust-lang:masterfrom Aug 1, 2025
Merged
Extend is_case_difference to handle digit-letter confusables#144691bors merged 1 commit intorust-lang:masterfrom
is_case_difference to handle digit-letter confusables#144691bors merged 1 commit intorust-lang:masterfrom
Conversation
estebank
reviewed
Jul 30, 2025
Contributor
estebank
left a comment
There was a problem hiding this comment.
Just a couple of nitpicks.
1295c6a to
10af3e1
Compare
This comment has been minimized.
This comment has been minimized.
xizheyin
commented
Jul 31, 2025
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, | ||
| } |
Member
Author
There was a problem hiding this comment.
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) |
Member
Author
There was a problem hiding this comment.
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')]; |
Member
Author
There was a problem hiding this comment.
I keep simple and use reverse
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
10af3e1 to
7b667e7
Compare
Collaborator
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
Contributor
|
@bors r+ |
Collaborator
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
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')]; |
There was a problem hiding this comment.
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`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR extends
is_case_differenceto handle digit-letter confusablesAdd support for detecting 0/O, 1/l, 5/S, 8/B, 9/g confusables in error suggestions.
r? @estebank