Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out, no 😆

if let Ok((Some(ext), res)) = resolver.resolve_macro_path(
&path,
None,
&ParentScope::module(resolver.graph_root(), resolver),
false,
false,
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, you noted a problem with #[macro_export] above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this code was like this to handle macro_export/old-style macro resolution. Which still exists. But perhaps we can handle this a bit cleaner.

) {
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);
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/rustdoc-ui/intra-doc/private-macro.rs
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) {}
}
}