@@ -84,6 +84,7 @@ struct EmbargoVisitor<'a, 'tcx: 'a> {
8484}
8585
8686struct ReachEverythingInTheInterfaceVisitor < ' b , ' a : ' b , ' tcx : ' a > {
87+ access_level : Option < AccessLevel > ,
8788 item_def_id : DefId ,
8889 ev : & ' b mut EmbargoVisitor < ' a , ' tcx > ,
8990}
@@ -134,6 +135,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
134135 fn reach < ' b > ( & ' b mut self , item_id : ast:: NodeId )
135136 -> ReachEverythingInTheInterfaceVisitor < ' b , ' a , ' tcx > {
136137 ReachEverythingInTheInterfaceVisitor {
138+ access_level : self . prev_level . map ( |l| l. min ( AccessLevel :: Reachable ) ) ,
137139 item_def_id : self . tcx . hir . local_def_id ( item_id) ,
138140 ev : self ,
139141 }
@@ -164,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
164166 hir:: ItemKind :: Existential ( ref ty_data) => {
165167 if let Some ( impl_trait_fn) = ty_data. impl_trait_fn {
166168 if let Some ( node_id) = self . tcx . hir . as_local_node_id ( impl_trait_fn) {
167- self . update ( node_id, Some ( AccessLevel :: Reachable ) ) ;
169+ self . update ( node_id, Some ( AccessLevel :: ReachableFromImplTrait ) ) ;
168170 }
169171 }
170172 if item. vis . node . is_pub ( ) { self . prev_level } else { None }
@@ -240,6 +242,9 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
240242 hir:: ItemKind :: ExternCrate ( ..) => { }
241243 }
242244
245+ let orig_level = self . prev_level ;
246+ self . prev_level = item_level;
247+
243248 // Mark all items in interfaces of reachable items as reachable
244249 match item. node {
245250 // The interface is empty
@@ -337,9 +342,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
337342 }
338343 }
339344
340- let orig_level = self . prev_level ;
341- self . prev_level = item_level;
342-
343345 intravisit:: walk_item ( self , item) ;
344346
345347 self . prev_level = orig_level;
@@ -475,7 +477,7 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
475477 fn check_trait_ref ( & mut self , trait_ref : ty:: TraitRef < ' tcx > ) {
476478 if let Some ( node_id) = self . ev . tcx . hir . as_local_node_id ( trait_ref. def_id ) {
477479 let item = self . ev . tcx . hir . expect_item ( node_id) ;
478- self . ev . update ( item. id , Some ( AccessLevel :: Reachable ) ) ;
480+ self . ev . update ( item. id , self . access_level ) ;
479481 }
480482 }
481483}
@@ -496,7 +498,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
496498
497499 if let Some ( def_id) = ty_def_id {
498500 if let Some ( node_id) = self . ev . tcx . hir . as_local_node_id ( def_id) {
499- self . ev . update ( node_id, Some ( AccessLevel :: Reachable ) ) ;
501+ self . ev . update ( node_id, self . access_level ) ;
500502 }
501503 }
502504
0 commit comments