-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tweak confusable idents checking #75349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak confusable idents checking #75349
Conversation
Confusable idents detection uses a type `BTreeMap<Symbol, Span>`. This is highly dubious given that `Symbol` doesn't guarantee a meaningful order. (In practice, it currently gives an order that mostly matches source code order.) As a result, changes in `Symbol` representation make the `lint-confusable-idents.rs` test fail, because this error message: > identifier pair considered confusable between `s` and `s` is changed to this: > identifier pair considered confusable between `s` and `s` and the corresponding span pointers get swapped erroneously, leading to an incorrect "previous identifier" label. This commit sorts the relevant symbols by span before doing the checking, which ensures that the ident that appears first in the code will be mentioned first in the message. The commit also extends the test slightly to be more thorough.
`CowBoxSymStr` is a type that either holds a `SymbolStr` (which is much the same as a `Symbol`), or an owned string. When computing skeletons, a `SymbolStr` is stored if the skeleton is the same as the original string, otherwise an owned string is stored. So, basically, `CowBoxSymStr` is a type for string interning. But we already have one of those: `Symbol` itself. This PR removes `CowBoxSymStr`, using `Symbol` instead. A good thing about this is that it avoids storing `SymbolStr` values in `skeleton_map`, something that is discouraged. The PR also inlines and removes the `calc_skeleton()` function because that simplifies the code.
These two commits are the first two commits from #74554. |
@bors r+ |
📌 Commit 0a597bd has been approved by |
Actually, @bors r-. |
@bors try @rust-timer queue zzz |
Awaiting bors try build completion |
🙅 Please do not |
@bors r- |
Awaiting bors try build completion |
⌛ Trying commit 0a597bd with merge 47c28a19a7d1cfc337986990a4a31c207c1c46eb... |
☀️ Try build successful - checks-actions, checks-azure |
Queued 47c28a19a7d1cfc337986990a4a31c207c1c46eb with parent 08324fe, future comparison URL. |
Finished benchmarking try commit (47c28a19a7d1cfc337986990a4a31c207c1c46eb): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
NonAsciiIdents is still allow by default I think, but some of the other lints like confusable idents are not. Regardless this seems perf-neutral or a slight improvement, even, so @bors r=petrochenkov |
📌 Commit 0a597bd has been approved by |
☀️ Test successful - checks-actions, checks-azure |
The confusable idents checking does some sub-optimal things with symbols.
r? @petrochenkov
cc @crlf0710