Auto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomez
rustdoc: Pre-calculate traits that are in scope for doc links This eliminates one more late use of resolver (part of #83761). At early doc link resolution time we go through parent modules of items from the current crate, reexports of items from other crates, trait items, and impl items collected by `collect-intra-doc-links` pass, determine traits that are in scope in each such module, and put those traits into a map used by later rustdoc passes. r? `@jyn514`
This commit is contained in:
commit
788b1fe5b7
7 changed files with 131 additions and 41 deletions
|
@ -1373,11 +1373,15 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
self.root.traits.decode(self).map(move |index| self.local_def_id(index))
|
||||
}
|
||||
|
||||
fn get_trait_impls(self) -> impl Iterator<Item = (DefId, Option<SimplifiedType>)> + 'a {
|
||||
self.cdata.trait_impls.values().flat_map(move |impls| {
|
||||
impls
|
||||
.decode(self)
|
||||
.map(move |(idx, simplified_self_ty)| (self.local_def_id(idx), simplified_self_ty))
|
||||
fn get_trait_impls(self) -> impl Iterator<Item = (DefId, DefId, Option<SimplifiedType>)> + 'a {
|
||||
self.cdata.trait_impls.iter().flat_map(move |((trait_cnum_raw, trait_index), impls)| {
|
||||
let trait_def_id = DefId {
|
||||
krate: self.cnum_map[CrateNum::from_u32(*trait_cnum_raw)],
|
||||
index: *trait_index,
|
||||
};
|
||||
impls.decode(self).map(move |(impl_index, simplified_self_ty)| {
|
||||
(trait_def_id, self.local_def_id(impl_index), simplified_self_ty)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ impl CStore {
|
|||
pub fn trait_impls_in_crate_untracked(
|
||||
&self,
|
||||
cnum: CrateNum,
|
||||
) -> impl Iterator<Item = (DefId, Option<SimplifiedType>)> + '_ {
|
||||
) -> impl Iterator<Item = (DefId, DefId, Option<SimplifiedType>)> + '_ {
|
||||
self.get_crate_data(cnum).get_trait_impls()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue