-
Notifications
You must be signed in to change notification settings - Fork 13.3k
collect doc alias as tips during resolution #127721
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
base: master
Are you sure you want to change the base?
Conversation
In general I'd prefer to maybe not do this at all for the local crate. |
Agree and accept this suggestion. @rustbot ready |
This comment was marked as resolved.
This comment was marked as resolved.
@bvanjoi triage here, any interest in rebasing this? |
@bvanjoi |
Rebased. @rustbot ready |
This comment was marked as resolved.
This comment was marked as resolved.
Update: Fixes the incorrect submodule... |
This comment was marked as resolved.
This comment was marked as resolved.
Hi @estebank could you take a look at this when you get a chance? Thanks 🙂 |
Maybe r? @petrochenkov (or reroll)? |
@@ -1285,3 +1285,29 @@ pub fn parse_confusables(attr: &Attribute) -> Option<Vec<Symbol>> { | |||
|
|||
Some(candidates) | |||
} | |||
|
|||
pub fn collect_doc_alias_symbol_from_attrs<'tcx>( |
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.
Both calls to this function immediately use contains(sym)
on the result, so it's probably better to pass sym
to here and avoid the collection.
format!( | ||
"`{}` has a name defined in the doc alias attribute as `{}`", | ||
self.r.tcx.item_name(did), | ||
path.last().unwrap().ident.as_str() |
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.
path.last().unwrap().ident.as_str() | |
path.last().unwrap().ident |
@@ -783,6 +796,50 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { | |||
(false, candidates) | |||
} | |||
|
|||
fn lookup_doc_alias_name(&mut self, path: &[Segment], ns: Namespace) -> Option<DefId> { | |||
let item_str = path.last().unwrap().ident; |
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.
let item_str = path.last().unwrap().ident; | |
let item_name = path.last().unwrap().ident.name; |
} else { | ||
let mod_path = &path[..path.len() - 1]; | ||
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = | ||
self.resolve_path(mod_path, Some(TypeNS), None) |
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 don't think the logic is right, we are reporting an error for one specific unresolved segment in a path (and it's not necessarily the last one), not for all segments, and all segments before the one unresolved segment should be already resolved and recorded into partial_res_map
.
So
- no need to search candidates for all segments, only for the currently unresolved one
- no need to use
resolve_path
for the previous segments,partial_res_map
should already be filled.
Close #124273
Collect the symbol in the doc alias attributes and provide a tip when a match is found.
r? @estebank