Compute all_traits_impls during resolution.
This commit is contained in:
parent
26eeec0baf
commit
635978041d
8 changed files with 17 additions and 18 deletions
|
@ -1281,7 +1281,14 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
|
|||
this.with_self_rib(Res::SelfTy(None, None), |this| {
|
||||
// Resolve the trait reference, if necessary.
|
||||
this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this, trait_id| {
|
||||
let item_def_id = this.r.local_def_id(item_id).to_def_id();
|
||||
let item_def_id = this.r.local_def_id(item_id);
|
||||
|
||||
// Register the trait definitions from here.
|
||||
if let Some(trait_id) = trait_id {
|
||||
this.r.trait_impls.entry(trait_id).or_default().push(item_def_id);
|
||||
}
|
||||
|
||||
let item_def_id = item_def_id.to_def_id();
|
||||
this.with_self_rib(Res::SelfTy(trait_id, Some((item_def_id, false))), |this| {
|
||||
if let Some(trait_ref) = opt_trait_reference.as_ref() {
|
||||
// Resolve type arguments in the trait path.
|
||||
|
|
|
@ -60,7 +60,7 @@ use rustc_span::{Span, DUMMY_SP};
|
|||
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::ops::ControlFlow;
|
||||
use std::{cmp, fmt, iter, ptr};
|
||||
use tracing::debug;
|
||||
|
@ -1034,6 +1034,7 @@ pub struct Resolver<'a> {
|
|||
item_generics_num_lifetimes: FxHashMap<LocalDefId, usize>,
|
||||
|
||||
main_def: Option<MainDefinition>,
|
||||
trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
|
||||
}
|
||||
|
||||
/// Nothing really interesting here; it just provides memory for the rest of the crate.
|
||||
|
@ -1398,6 +1399,7 @@ impl<'a> Resolver<'a> {
|
|||
legacy_const_generic_args: Default::default(),
|
||||
item_generics_num_lifetimes: Default::default(),
|
||||
main_def: Default::default(),
|
||||
trait_impls: Default::default(),
|
||||
};
|
||||
|
||||
let root_parent_scope = ParentScope::module(graph_root, &resolver);
|
||||
|
@ -1455,6 +1457,7 @@ impl<'a> Resolver<'a> {
|
|||
.map(|(ident, entry)| (ident.name, entry.introduced_by_item))
|
||||
.collect(),
|
||||
main_def,
|
||||
trait_impls: self.trait_impls,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1474,6 +1477,7 @@ impl<'a> Resolver<'a> {
|
|||
.map(|(ident, entry)| (ident.name, entry.introduced_by_item))
|
||||
.collect(),
|
||||
main_def: self.main_def.clone(),
|
||||
trait_impls: self.trait_impls.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue