Skip to content

Commit 1bf351d

Browse files
committed
We now have proper locations for the existential type items.
1 parent 057cf0f commit 1bf351d

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,8 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
610610
}
611611
visitor.visit_lifetime(lifetime);
612612
}
613-
TyImplTraitExistential(item_id, def_id, ref lifetimes) => {
613+
TyImplTraitExistential(_, def_id, ref lifetimes) => {
614614
visitor.visit_def_mention(Def::Existential(def_id));
615-
visitor.visit_nested_item(item_id);
616615
walk_list!(visitor, visit_lifetime, lifetimes);
617616
}
618617
TyTypeof(ref expression) => {

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,12 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
498498
};
499499
self.with(scope, |_, this| intravisit::walk_item(this, item));
500500
}
501-
hir::ItemExistential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => {
501+
hir::ItemExistential(hir::ExistTy { .. }) => {
502502
// currently existential type declarations are just generated from impl Trait
503503
// items. doing anything on this node is irrelevant, as we currently don't need
504504
// it.
505505
}
506506
hir::ItemTy(_, ref generics)
507-
| hir::ItemExistential(hir::ExistTy { impl_trait_fn: None, ref generics, .. })
508507
| hir::ItemEnum(_, ref generics)
509508
| hir::ItemStruct(_, ref generics)
510509
| hir::ItemUnion(_, ref generics)

src/librustc_privacy/lib.rs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,12 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
229229
hir::ItemUse(..) => {}
230230
// The interface is empty
231231
hir::ItemGlobalAsm(..) => {}
232-
// Checked by visit_ty
233-
hir::ItemExistential(..) => {}
232+
hir::ItemExistential(..) => {
233+
if item_level.is_some() {
234+
// Reach the (potentially private) type and the API being exposed
235+
self.reach(item.id).ty().predicates();
236+
}
237+
}
234238
// Visit everything
235239
hir::ItemConst(..) | hir::ItemStatic(..) |
236240
hir::ItemFn(..) | hir::ItemTy(..) => {
@@ -390,17 +394,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
390394
module_id = self.tcx.hir.get_parent_node(module_id);
391395
}
392396
}
393-
394-
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
395-
if let hir::TyImplTraitExistential(item_id, _, _) = ty.node {
396-
if self.get(item_id.id).is_some() {
397-
// Reach the (potentially private) type and the API being exposed
398-
self.reach(item_id.id).ty().predicates();
399-
}
400-
}
401-
402-
intravisit::walk_ty(self, ty);
403-
}
404397
}
405398

406399
impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
@@ -1556,8 +1549,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
15561549
hir::ItemUse(..) => {}
15571550
// No subitems
15581551
hir::ItemGlobalAsm(..) => {}
1559-
// Checked in visit_ty
1560-
hir::ItemExistential(..) => {}
1552+
hir::ItemExistential(..) => {
1553+
// Check the traits being exposed, as they're separate,
1554+
// e.g. `impl Iterator<Item=T>` has two predicates,
1555+
// `X: Iterator` and `<X as Iterator>::Item == T`,
1556+
// where `X` is the `impl Iterator<Item=T>` itself,
1557+
// stored in `predicates_of`, not in the `Ty` itself.
1558+
1559+
self.check(item.id, self.inner_visibility).predicates();
1560+
}
15611561
// Subitems of these items have inherited publicity
15621562
hir::ItemConst(..) | hir::ItemStatic(..) | hir::ItemFn(..) |
15631563
hir::ItemTy(..) => {
@@ -1655,20 +1655,6 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
16551655
// handled in `visit_item` above
16561656
}
16571657

1658-
fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
1659-
if let hir::TyImplTraitExistential(ref exist_item, _, _) = ty.node {
1660-
// Check the traits being exposed, as they're separate,
1661-
// e.g. `impl Iterator<Item=T>` has two predicates,
1662-
// `X: Iterator` and `<X as Iterator>::Item == T`,
1663-
// where `X` is the `impl Iterator<Item=T>` itself,
1664-
// stored in `predicates_of`, not in the `Ty` itself.
1665-
1666-
self.check(exist_item.id, self.inner_visibility).predicates();
1667-
}
1668-
1669-
intravisit::walk_ty(self, ty);
1670-
}
1671-
16721658
// Don't recurse into expressions in array sizes or const initializers
16731659
fn visit_expr(&mut self, _: &'tcx hir::Expr) {}
16741660
// Don't recurse into patterns in function arguments

0 commit comments

Comments
 (0)