-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
rustdoc: Unify macro intra-doc link resolution with type and value resolution #91427
Changes from 1 commit
7cd0291
9630a81
956f7ee
496be6b
e70e74f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,29 +396,14 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { | |
path_str: &'a str, | ||
module_id: DefId, | ||
) -> Result<Res, ResolutionFailure<'a>> { | ||
let path = ast::Path::from_ident(Ident::from_str(path_str)); | ||
self.cx.enter_resolver(|resolver| { | ||
// FIXME(jynelson): does this really need 3 separate lookups? | ||
if let Ok((Some(ext), res)) = resolver.resolve_macro_path( | ||
&path, | ||
None, | ||
&ParentScope::module(resolver.graph_root(), resolver), | ||
false, | ||
false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps we should also add tests that ensure that macros can still be linked to on both newer and older editions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yeah, you noted a problem with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this code was like this to handle |
||
) { | ||
if let SyntaxExtensionKind::LegacyBang { .. } = ext.kind { | ||
return Ok(res.try_into().unwrap()); | ||
} | ||
} | ||
if let Some(&res) = resolver.all_macros().get(&Symbol::intern(path_str)) { | ||
return Ok(res.try_into().unwrap()); | ||
} | ||
debug!("resolving {} as a macro in the module {:?}", path_str, module_id); | ||
if let Ok((_, res)) = | ||
resolver.resolve_str_path_error(DUMMY_SP, path_str, MacroNS, module_id) | ||
{ | ||
// don't resolve builtins like `#[derive]` | ||
if let Ok(res) = res.try_into() { | ||
debug!("{} resolved to {:?} in macro namespace (3)", path_str, res); | ||
return Ok(res); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// check-pass | ||
#![deny(rustdoc::broken_intra_doc_links)] | ||
|
||
mod bar { | ||
macro_rules! str {() => {}} | ||
} | ||
|
||
pub mod foo { | ||
pub struct Baz {} | ||
impl Baz { | ||
/// [str] | ||
pub fn foo(&self) {} | ||
} | ||
} |
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.
turns out, no 😆