-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Suggest similar names for types #96839
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
let mut names = Vec::new(); | ||
if let Some(ribs) = ribs { | ||
// Search in lexical scope. | ||
// Walk backwards up the ribs in scope and collect candidates. | ||
for rib in ribs[TypeNS].iter().rev() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the logics after this line with reference to the following function:
fn lookup_typo_candidate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way these could be merged or share logic? Might be worth leaving a comment at the very least.
@jackh726 |
names.sort_by_key(|name| (name.candidate, name.res)); | ||
names.dedup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is what the PartialOrd
/Ord
derives are for. Can you try using an IndexSet
instead? I'm wary of adding these impls, given their potential as a source of incremental bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, sort as in lookup_typo_candidate
by the candidate name str
let mut names = Vec::new(); | ||
if let Some(ribs) = ribs { | ||
// Search in lexical scope. | ||
// Walk backwards up the ribs in scope and collect candidates. | ||
for rib in ribs[TypeNS].iter().rev() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way these could be merged or share logic? Might be worth leaving a comment at the very least.
☔ The latest upstream changes (presumably #97239) made this pull request unmergeable. Please resolve the merge conflicts. |
@@ -2381,7 +2381,7 @@ impl<'hir> Ty<'hir> { | |||
} | |||
|
|||
/// Not represented directly in the AST; referred to by name through a `ty_path`. | |||
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] | |||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
☔ The latest upstream changes (presumably #99078) made this pull request unmergeable. Please resolve the merge conflicts. |
ping from triage - can you post your status on this PR? Thanks |
Fixes #96625
Fixes #95462
This PR enables to suggest similar names for types like the following examples. About the detailed motivation of this PR, please see the above issues.