Skip to content

Commit

Permalink
resolve: Populate external traits lazily as well
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Aug 11, 2019
1 parent a8017d6 commit aee4313
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
let expansion = ExpnId::root(); // FIXME(jseyfried) intercrate hygiene
match res {
Res::Def(kind @ DefKind::Mod, def_id)
| Res::Def(kind @ DefKind::Enum, def_id) => {
| Res::Def(kind @ DefKind::Enum, def_id)
| Res::Def(kind @ DefKind::Trait, def_id) => {
let module = self.r.new_module(parent,
ModuleKind::Def(kind, def_id, ident.name),
def_id,
Expand All @@ -880,13 +881,16 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
| Res::Def(DefKind::ForeignTy, _)
| Res::Def(DefKind::OpaqueTy, _)
| Res::Def(DefKind::TraitAlias, _)
| Res::Def(DefKind::AssocTy, _)
| Res::Def(DefKind::AssocOpaqueTy, _)
| Res::PrimTy(..)
| Res::ToolMod => {
self.r.define(parent, ident, TypeNS, (res, vis, DUMMY_SP, expansion));
}
Res::Def(DefKind::Fn, _)
| Res::Def(DefKind::Static, _)
| Res::Def(DefKind::Const, _)
| Res::Def(DefKind::AssocConst, _)
| Res::Def(DefKind::Ctor(CtorOf::Variant, ..), _) => {
self.r.define(parent, ident, ValueNS, (res, vis, DUMMY_SP, expansion));
}
Expand All @@ -899,28 +903,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
self.r.struct_constructors.insert(struct_def_id, (res, vis));
}
}
Res::Def(DefKind::Trait, def_id) => {
let module_kind = ModuleKind::Def(DefKind::Trait, def_id, ident.name);
let module = self.r.new_module(parent,
module_kind,
parent.normal_ancestor_id,
expansion,
span);
self.r.define(parent, ident, TypeNS, (module, vis, DUMMY_SP, expansion));
Res::Def(DefKind::Method, def_id) => {
self.r.define(parent, ident, ValueNS, (res, vis, DUMMY_SP, expansion));

module.populate_on_access.set(false);
for child in self.r.cstore.item_children_untracked(def_id, self.r.session) {
let res = child.res.map_id(|_| panic!("unexpected id"));
let ns = if let Res::Def(DefKind::AssocTy, _) = res {
TypeNS
} else { ValueNS };
self.r.define(module, child.ident, ns,
(res, ty::Visibility::Public, DUMMY_SP, expansion));

if self.r.cstore.associated_item_cloned_untracked(child.res.def_id())
.method_has_self_argument {
self.r.has_self.insert(res.def_id());
}
if self.r.cstore.associated_item_cloned_untracked(def_id).method_has_self_argument {
self.r.has_self.insert(def_id);
}
}
Res::Def(DefKind::Struct, def_id) | Res::Def(DefKind::Union, def_id) => {
Expand Down

0 comments on commit aee4313

Please sign in to comment.