@@ -176,6 +176,10 @@ where
176
176
{
177
177
type BreakTy = V :: BreakTy ;
178
178
179
+ fn visit_predicate ( & mut self , p : ty:: Predicate < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
180
+ self . visit_clause ( p. as_clause ( ) . unwrap ( ) )
181
+ }
182
+
179
183
fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> ControlFlow < V :: BreakTy > {
180
184
let tcx = self . def_id_visitor . tcx ( ) ;
181
185
// GenericArgs are not visited here because they are visited below
@@ -1142,6 +1146,14 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
1142
1146
}
1143
1147
}
1144
1148
1149
+ impl < ' tcx > rustc_ty_utils:: sig_types:: Spanned < ' tcx > for TypePrivacyVisitor < ' tcx > {
1150
+ type BreakTy = ( ) ;
1151
+ fn visit ( & mut self , span : Span , value : impl TypeVisitable < TyCtxt < ' tcx > > ) -> ControlFlow < ( ) > {
1152
+ self . span = span;
1153
+ value. visit_with ( & mut self . skeleton ( ) )
1154
+ }
1155
+ }
1156
+
1145
1157
impl < ' tcx > Visitor < ' tcx > for TypePrivacyVisitor < ' tcx > {
1146
1158
type NestedFilter = nested_filter:: All ;
1147
1159
@@ -1183,7 +1195,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
1183
1195
// Types in signatures.
1184
1196
// FIXME: This is very ineffective. Ideally each HIR type should be converted
1185
1197
// into a semantic type only once and the result should be cached somehow.
1186
- if self . visit ( rustc_hir_analysis:: hir_ty_to_ty ( self . tcx , hir_ty) ) . is_break ( ) {
1198
+ if self . visit ( rustc_hir_analysis:: hir_ty_to_ty ( self . tcx ( ) , hir_ty) ) . is_break ( ) {
1187
1199
return ;
1188
1200
}
1189
1201
}
@@ -1348,7 +1360,20 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
1348
1360
fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
1349
1361
let orig_current_item = mem:: replace ( & mut self . current_item , item. owner_id . def_id ) ;
1350
1362
let old_maybe_typeck_results = self . maybe_typeck_results . take ( ) ;
1351
- intravisit:: walk_item ( self , item) ;
1363
+ rustc_ty_utils:: sig_types:: walk_types ( self . tcx ( ) , item. owner_id . def_id , self ) ;
1364
+ match item. kind {
1365
+ hir:: ItemKind :: Macro ( _, _) => intravisit:: walk_item ( self , item) ,
1366
+ hir:: ItemKind :: Static ( _, _, body_id)
1367
+ | hir:: ItemKind :: Const ( _, body_id)
1368
+ | hir:: ItemKind :: Fn ( _, _, body_id) => self . visit_nested_body ( body_id) ,
1369
+ hir:: ItemKind :: Impl ( hir:: Impl { of_trait : Some ( tr) , .. } ) => {
1370
+ self . span = tr. path . span ;
1371
+ let trait_ref =
1372
+ self . tcx ( ) . impl_trait_ref ( item. owner_id . def_id ) . unwrap ( ) . instantiate_identity ( ) ;
1373
+ self . visit_def_id ( trait_ref. def_id , "trait" , & trait_ref. print_only_trait_path ( ) ) ;
1374
+ }
1375
+ _ => { }
1376
+ }
1352
1377
self . maybe_typeck_results = old_maybe_typeck_results;
1353
1378
self . current_item = orig_current_item;
1354
1379
}
0 commit comments