-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Consider doc(alias) when providing typo suggestions #107108
Consider doc(alias) when providing typo suggestions #107108
Conversation
r? @Nilstrieb (rustbot has picked a reviewer for you, use r? to override) |
123d275
to
cf5e337
Compare
if let sym::doc = attr.name_or_empty() { | ||
if let Some(values) = attr.meta_item_list() { | ||
for v in values { | ||
if v.name_or_empty().as_str() != "alias" { |
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.
Could you add alias
to the symbols table in rustc_span/src/symbols.rs
(I think that was the path) instead of doing this string comparison?
cf5e337
to
c67108b
Compare
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.
This looks mostly fine to me but I'll r? compiler-errors who has more experience with this code than me for a second look whether these are the right places to put this
c67108b
to
8c5843a
Compare
The implementation looks fine here. I think this is only invoked on error paths, so the extra computation when probing for candidates is fine. I have a few nits that you could address if you want:
|
8c5843a
to
b4af140
Compare
|
||
Err(MethodError::NoMatch(NoMatchData { | ||
static_candidates, | ||
unsatisfied_predicates, | ||
out_of_scope_traits, | ||
lev_candidate, | ||
lev_candidate: similar_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.
The field in NoMatchData
should probably be renamed too.
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.
This looks good but lev_candidate
should also be renamed in NoMatchData
Afterwards I can approve.
This means that ```rust impl Foo { #[doc(alias = "quux")] fn bar(&self) {} } fn main() { (Foo {}).quux(); } ``` will suggest `bar`. This currently uses the "there is a method with a similar name" help text, because the point where we choose and emit a suggestion is different from where we gather the suggestions. Changes have mainly been made to the latter. The selection code will now fall back to aliased candidates, but generally only if there is no candidate that matches based on the existing Levenshtein methodology. Fixes rust-lang#83968.
b4af140
to
f908f0b
Compare
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.
Thanks!
@bors r+ |
Rollup of 7 pull requests Successful merges: - rust-lang#104926 (Move relationships from FulfillmentContext to Inherited) - rust-lang#106854 (Add `Arc::into_inner` for safely discarding `Arc`s without calling the destructor on the inner type.) - rust-lang#107108 (Consider doc(alias) when providing typo suggestions) - rust-lang#107186 (rustdoc: Use correct pseudo-element selector) - rust-lang#107192 (Add myself to the mailmap) - rust-lang#107195 (Fix typo in universal_regions.rs comment) - rust-lang#107203 (Suggest remove deref for type mismatch) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This means that
will suggest
bar
. This currently uses the "there is a method with a similar name" help text, because the point where we choose and emit a suggestion is different from where we gather the suggestions. Changes have mainly been made to the latter.The selection code will now fall back to aliased candidates, but generally only if there is no candidate that matches based on the existing Levenshtein methodology.
Fixes #83968.