@@ -229,8 +229,12 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
229
229
hir:: ItemUse ( ..) => { }
230
230
// The interface is empty
231
231
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
+ }
234
238
// Visit everything
235
239
hir:: ItemConst ( ..) | hir:: ItemStatic ( ..) |
236
240
hir:: ItemFn ( ..) | hir:: ItemTy ( ..) => {
@@ -390,17 +394,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
390
394
module_id = self . tcx . hir . get_parent_node ( module_id) ;
391
395
}
392
396
}
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
- }
404
397
}
405
398
406
399
impl < ' b , ' a , ' tcx > ReachEverythingInTheInterfaceVisitor < ' b , ' a , ' tcx > {
@@ -1556,8 +1549,15 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
1556
1549
hir:: ItemUse ( ..) => { }
1557
1550
// No subitems
1558
1551
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
+ }
1561
1561
// Subitems of these items have inherited publicity
1562
1562
hir:: ItemConst ( ..) | hir:: ItemStatic ( ..) | hir:: ItemFn ( ..) |
1563
1563
hir:: ItemTy ( ..) => {
@@ -1655,20 +1655,6 @@ impl<'a, 'tcx> Visitor<'tcx> for PrivateItemsInPublicInterfacesVisitor<'a, 'tcx>
1655
1655
// handled in `visit_item` above
1656
1656
}
1657
1657
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
-
1672
1658
// Don't recurse into expressions in array sizes or const initializers
1673
1659
fn visit_expr ( & mut self , _: & ' tcx hir:: Expr ) { }
1674
1660
// Don't recurse into patterns in function arguments
0 commit comments