@@ -176,6 +176,10 @@ where
176176{
177177 type BreakTy = V :: BreakTy ;
178178
179+ fn visit_predicate ( & mut self , p : ty:: Predicate < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
180+ self . visit_clause ( p. as_clause ( ) . unwrap ( ) )
181+ }
182+
179183 fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> ControlFlow < V :: BreakTy > {
180184 let tcx = self . def_id_visitor . tcx ( ) ;
181185 // GenericArgs are not visited here because they are visited below
@@ -1142,6 +1146,14 @@ impl<'tcx> TypePrivacyVisitor<'tcx> {
11421146 }
11431147}
11441148
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+
11451157impl < ' tcx > Visitor < ' tcx > for TypePrivacyVisitor < ' tcx > {
11461158 type NestedFilter = nested_filter:: All ;
11471159
@@ -1183,7 +1195,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
11831195 // Types in signatures.
11841196 // FIXME: This is very ineffective. Ideally each HIR type should be converted
11851197 // 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 ( ) {
11871199 return ;
11881200 }
11891201 }
@@ -1348,7 +1360,20 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
13481360 fn visit_item ( & mut self , item : & ' tcx hir:: Item < ' tcx > ) {
13491361 let orig_current_item = mem:: replace ( & mut self . current_item , item. owner_id . def_id ) ;
13501362 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+ }
13521377 self . maybe_typeck_results = old_maybe_typeck_results;
13531378 self . current_item = orig_current_item;
13541379 }
0 commit comments