@@ -84,6 +84,7 @@ struct EmbargoVisitor<'a, 'tcx: 'a> {
84
84
}
85
85
86
86
struct ReachEverythingInTheInterfaceVisitor < ' b , ' a : ' b , ' tcx : ' a > {
87
+ access_level : Option < AccessLevel > ,
87
88
item_def_id : DefId ,
88
89
ev : & ' b mut EmbargoVisitor < ' a , ' tcx > ,
89
90
}
@@ -134,6 +135,7 @@ impl<'a, 'tcx> EmbargoVisitor<'a, 'tcx> {
134
135
fn reach < ' b > ( & ' b mut self , item_id : ast:: NodeId )
135
136
-> ReachEverythingInTheInterfaceVisitor < ' b , ' a , ' tcx > {
136
137
ReachEverythingInTheInterfaceVisitor {
138
+ access_level : self . prev_level . map ( |l| l. min ( AccessLevel :: Reachable ) ) ,
137
139
item_def_id : self . tcx . hir . local_def_id ( item_id) ,
138
140
ev : self ,
139
141
}
@@ -164,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
164
166
hir:: ItemKind :: Existential ( ref ty_data) => {
165
167
if let Some ( impl_trait_fn) = ty_data. impl_trait_fn {
166
168
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 ) ) ;
168
170
}
169
171
}
170
172
if item. vis . node . is_pub ( ) { self . prev_level } else { None }
@@ -240,6 +242,9 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
240
242
hir:: ItemKind :: ExternCrate ( ..) => { }
241
243
}
242
244
245
+ let orig_level = self . prev_level ;
246
+ self . prev_level = item_level;
247
+
243
248
// Mark all items in interfaces of reachable items as reachable
244
249
match item. node {
245
250
// The interface is empty
@@ -337,9 +342,6 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
337
342
}
338
343
}
339
344
340
- let orig_level = self . prev_level ;
341
- self . prev_level = item_level;
342
-
343
345
intravisit:: walk_item ( self , item) ;
344
346
345
347
self . prev_level = orig_level;
@@ -475,7 +477,7 @@ impl<'b, 'a, 'tcx> ReachEverythingInTheInterfaceVisitor<'b, 'a, 'tcx> {
475
477
fn check_trait_ref ( & mut self , trait_ref : ty:: TraitRef < ' tcx > ) {
476
478
if let Some ( node_id) = self . ev . tcx . hir . as_local_node_id ( trait_ref. def_id ) {
477
479
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 ) ;
479
481
}
480
482
}
481
483
}
@@ -496,7 +498,7 @@ impl<'b, 'a, 'tcx> TypeVisitor<'tcx> for ReachEverythingInTheInterfaceVisitor<'b
496
498
497
499
if let Some ( def_id) = ty_def_id {
498
500
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 ) ;
500
502
}
501
503
}
502
504
0 commit comments