mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Add more missing methods to IntraLinkCrateLoader
This helps with (but does not fix)
https://github.com/rust-lang/rust/issues/84738. I tested on
edcee7b812
and still hit ICEs.
This commit is contained in:
parent
489ec310d2
commit
cdafe99539
@ -1,3 +1,4 @@
|
||||
use ast::visit;
|
||||
use rustc_ast as ast;
|
||||
use rustc_hir::def::Namespace::TypeNS;
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
@ -16,7 +17,7 @@ crate fn load_intra_link_crates(resolver: Resolver, krate: &ast::Crate) -> Resol
|
||||
let mut loader = IntraLinkCrateLoader { current_mod: CRATE_DEF_ID, resolver };
|
||||
// `walk_crate` doesn't visit the crate itself for some reason.
|
||||
loader.load_links_in_attrs(&krate.attrs, krate.span);
|
||||
ast::visit::walk_crate(&mut loader, krate);
|
||||
visit::walk_crate(&mut loader, krate);
|
||||
loader.resolver
|
||||
}
|
||||
|
||||
@ -54,7 +55,12 @@ impl IntraLinkCrateLoader {
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::visit::Visitor<'_> for IntraLinkCrateLoader {
|
||||
impl visit::Visitor<'_> for IntraLinkCrateLoader {
|
||||
fn visit_foreign_item(&mut self, item: &ast::ForeignItem) {
|
||||
self.load_links_in_attrs(&item.attrs, item.span);
|
||||
visit::walk_foreign_item(self, item)
|
||||
}
|
||||
|
||||
fn visit_item(&mut self, item: &ast::Item) {
|
||||
use rustc_ast_lowering::ResolverAstLowering;
|
||||
|
||||
@ -64,12 +70,29 @@ impl ast::visit::Visitor<'_> for IntraLinkCrateLoader {
|
||||
let old_mod = mem::replace(&mut self.current_mod, new_mod);
|
||||
|
||||
self.load_links_in_attrs(&item.attrs, item.span);
|
||||
ast::visit::walk_item(self, item);
|
||||
visit::walk_item(self, item);
|
||||
|
||||
self.current_mod = old_mod;
|
||||
} else {
|
||||
self.load_links_in_attrs(&item.attrs, item.span);
|
||||
ast::visit::walk_item(self, item);
|
||||
visit::walk_item(self, item);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: if doc-comments are ever allowed on function parameters, this will have to implement `visit_param` too.
|
||||
|
||||
fn visit_assoc_item(&mut self, item: &ast::AssocItem, ctxt: visit::AssocCtxt) {
|
||||
self.load_links_in_attrs(&item.attrs, item.span);
|
||||
visit::walk_assoc_item(self, item, ctxt)
|
||||
}
|
||||
|
||||
fn visit_field_def(&mut self, field: &ast::FieldDef) {
|
||||
self.load_links_in_attrs(&field.attrs, field.span);
|
||||
visit::walk_field_def(self, field)
|
||||
}
|
||||
|
||||
fn visit_variant(&mut self, v: &ast::Variant) {
|
||||
self.load_links_in_attrs(&v.attrs, v.span);
|
||||
visit::walk_variant(self, v)
|
||||
}
|
||||
}
|
||||
|
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep1.rs
Normal file
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep1.rs
Normal file
@ -0,0 +1 @@
|
||||
// intentionally empty
|
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep2.rs
Normal file
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep2.rs
Normal file
@ -0,0 +1 @@
|
||||
// intentionally empty
|
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep3.rs
Normal file
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep3.rs
Normal file
@ -0,0 +1 @@
|
||||
// intentionally empty
|
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep4.rs
Normal file
1
src/test/rustdoc-ui/intra-doc/auxiliary/dep4.rs
Normal file
@ -0,0 +1 @@
|
||||
// intentionally empty
|
26
src/test/rustdoc-ui/intra-doc/extern-crate-load.rs
Normal file
26
src/test/rustdoc-ui/intra-doc/extern-crate-load.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// check-pass
|
||||
// aux-crate:dep1=dep1.rs
|
||||
// aux-crate:dep2=dep2.rs
|
||||
// aux-crate:dep3=dep3.rs
|
||||
// aux-crate:dep4=dep4.rs
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
|
||||
pub trait Trait {
|
||||
/// [dep1]
|
||||
type Item;
|
||||
}
|
||||
|
||||
pub struct S {
|
||||
/// [dep2]
|
||||
pub x: usize,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
/// [dep3]
|
||||
pub fn printf();
|
||||
}
|
||||
|
||||
pub enum E {
|
||||
/// [dep4]
|
||||
A
|
||||
}
|
Loading…
Reference in New Issue
Block a user