rustdoc: Early doc link resolution fixes and refactorings
This commit is contained in:
parent
c2afaba465
commit
69d6c3b2e6
10 changed files with 180 additions and 113 deletions
|
@ -1169,14 +1169,18 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_associated_item_def_ids(self, tcx: TyCtxt<'tcx>, id: DefIndex) -> &'tcx [DefId] {
|
||||
if let Some(children) = self.root.tables.children.get(self, id) {
|
||||
tcx.arena.alloc_from_iter(
|
||||
children.decode((self, tcx.sess)).map(|child_index| self.local_def_id(child_index)),
|
||||
)
|
||||
} else {
|
||||
&[]
|
||||
}
|
||||
fn get_associated_item_def_ids(
|
||||
self,
|
||||
id: DefIndex,
|
||||
sess: &'a Session,
|
||||
) -> impl Iterator<Item = DefId> + 'a {
|
||||
self.root
|
||||
.tables
|
||||
.children
|
||||
.get(self, id)
|
||||
.unwrap_or_else(Lazy::empty)
|
||||
.decode((self, sess))
|
||||
.map(move |child_index| self.local_def_id(child_index))
|
||||
}
|
||||
|
||||
fn get_associated_item(self, id: DefIndex) -> ty::AssocItem {
|
||||
|
|
|
@ -160,7 +160,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
let _ = cdata;
|
||||
tcx.calculate_dtor(def_id, |_,_| Ok(()))
|
||||
}
|
||||
associated_item_def_ids => { cdata.get_associated_item_def_ids(tcx, def_id.index) }
|
||||
associated_item_def_ids => {
|
||||
tcx.arena.alloc_from_iter(cdata.get_associated_item_def_ids(def_id.index, tcx.sess))
|
||||
}
|
||||
associated_item => { cdata.get_associated_item(def_id.index) }
|
||||
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
|
||||
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
|
||||
|
|
|
@ -1248,7 +1248,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
};
|
||||
let binding = (res, vis, span, expansion).to_name_binding(self.r.arenas);
|
||||
self.r.set_binding_parent_module(binding, parent_scope.module);
|
||||
self.r.all_macros.insert(ident.name, res);
|
||||
self.r.all_macro_rules.insert(ident.name, res);
|
||||
if is_macro_export {
|
||||
let module = self.r.graph_root;
|
||||
self.r.define(module, ident, MacroNS, (res, vis, span, expansion, IsMacroExport));
|
||||
|
|
|
@ -1003,7 +1003,8 @@ pub struct Resolver<'a> {
|
|||
registered_attrs: FxHashSet<Ident>,
|
||||
registered_tools: RegisteredTools,
|
||||
macro_use_prelude: FxHashMap<Symbol, &'a NameBinding<'a>>,
|
||||
all_macros: FxHashMap<Symbol, Res>,
|
||||
/// FIXME: The only user of this is a doc link resolution hack for rustdoc.
|
||||
all_macro_rules: FxHashMap<Symbol, Res>,
|
||||
macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>,
|
||||
dummy_ext_bang: Lrc<SyntaxExtension>,
|
||||
dummy_ext_derive: Lrc<SyntaxExtension>,
|
||||
|
@ -1385,7 +1386,7 @@ impl<'a> Resolver<'a> {
|
|||
registered_attrs,
|
||||
registered_tools,
|
||||
macro_use_prelude: FxHashMap::default(),
|
||||
all_macros: FxHashMap::default(),
|
||||
all_macro_rules: Default::default(),
|
||||
macro_map: FxHashMap::default(),
|
||||
dummy_ext_bang: Lrc::new(SyntaxExtension::dummy_bang(session.edition())),
|
||||
dummy_ext_derive: Lrc::new(SyntaxExtension::dummy_derive(session.edition())),
|
||||
|
@ -3311,8 +3312,8 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
|
||||
// For rustdoc.
|
||||
pub fn all_macros(&self) -> &FxHashMap<Symbol, Res> {
|
||||
&self.all_macros
|
||||
pub fn take_all_macro_rules(&mut self) -> FxHashMap<Symbol, Res> {
|
||||
mem::take(&mut self.all_macro_rules)
|
||||
}
|
||||
|
||||
/// For rustdoc.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue