rustdoc: Resolve doc links on fields during early resolution
This commit is contained in:
parent
3d237ab529
commit
6d590ba942
3 changed files with 57 additions and 1 deletions
|
@ -260,10 +260,22 @@ impl EarlyDocLinkResolver<'_, '_> {
|
||||||
if let Res::Def(DefKind::Mod, ..) = child.res {
|
if let Res::Def(DefKind::Mod, ..) = child.res {
|
||||||
self.resolve_doc_links_extern_inner(def_id); // Inner attribute scope
|
self.resolve_doc_links_extern_inner(def_id); // Inner attribute scope
|
||||||
}
|
}
|
||||||
// Traits are processed in `add_extern_traits_in_scope`.
|
// `DefKind::Trait`s are processed in `process_extern_impls`.
|
||||||
if let Res::Def(DefKind::Mod | DefKind::Enum, ..) = child.res {
|
if let Res::Def(DefKind::Mod | DefKind::Enum, ..) = child.res {
|
||||||
self.process_module_children_or_reexports(def_id);
|
self.process_module_children_or_reexports(def_id);
|
||||||
}
|
}
|
||||||
|
if let Res::Def(DefKind::Struct | DefKind::Union | DefKind::Variant, _) =
|
||||||
|
child.res
|
||||||
|
{
|
||||||
|
let field_def_ids = Vec::from_iter(
|
||||||
|
self.resolver
|
||||||
|
.cstore()
|
||||||
|
.associated_item_def_ids_untracked(def_id, self.sess),
|
||||||
|
);
|
||||||
|
for field_def_id in field_def_ids {
|
||||||
|
self.resolve_doc_links_extern_outer(field_def_id, scope_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
src/test/rustdoc-ui/intra-doc/assoc-field.rs
Normal file
26
src/test/rustdoc-ui/intra-doc/assoc-field.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// Traits in scope are collected for doc links in field attributes.
|
||||||
|
|
||||||
|
// check-pass
|
||||||
|
// aux-build: assoc-field-dep.rs
|
||||||
|
|
||||||
|
extern crate assoc_field_dep;
|
||||||
|
pub use assoc_field_dep::*;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Struct;
|
||||||
|
|
||||||
|
pub mod mod1 {
|
||||||
|
pub struct Fields {
|
||||||
|
/// [crate::Struct::clone]
|
||||||
|
pub field: u8,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod mod2 {
|
||||||
|
pub enum Fields {
|
||||||
|
V {
|
||||||
|
/// [crate::Struct::clone]
|
||||||
|
field: u8,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
18
src/test/rustdoc-ui/intra-doc/auxiliary/assoc-field-dep.rs
Normal file
18
src/test/rustdoc-ui/intra-doc/auxiliary/assoc-field-dep.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct Struct;
|
||||||
|
|
||||||
|
pub mod dep_mod1 {
|
||||||
|
pub struct Fields {
|
||||||
|
/// [crate::Struct::clone]
|
||||||
|
pub field: u8,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod dep_mod2 {
|
||||||
|
pub enum Fields {
|
||||||
|
V {
|
||||||
|
/// [crate::Struct::clone]
|
||||||
|
field: u8,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue