@@ -1191,16 +1191,7 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
1191
1191
fn visit_generic_arg ( & mut self , generic_arg : & ' tcx hir:: GenericArg < ' tcx > ) {
1192
1192
match generic_arg {
1193
1193
hir:: GenericArg :: Type ( t) => self . visit_ty ( t) ,
1194
- hir:: GenericArg :: Infer ( inf) => {
1195
- self . span = inf. span ;
1196
- let parent_hir_id = self . tcx . hir ( ) . get_parent_node ( inf. hir_id ) ;
1197
- if let Some ( typeck_results) = self . maybe_typeck_results {
1198
- let node_substs = typeck_results. node_substs ( parent_hir_id) ;
1199
- for ty in node_substs. types ( ) {
1200
- self . visit ( ty) ;
1201
- }
1202
- }
1203
- }
1194
+ hir:: GenericArg :: Infer ( inf) => self . visit_infer ( inf) ,
1204
1195
hir:: GenericArg :: Lifetime ( _) | hir:: GenericArg :: Const ( _) => { }
1205
1196
}
1206
1197
}
@@ -1224,6 +1215,23 @@ impl<'tcx> Visitor<'tcx> for TypePrivacyVisitor<'tcx> {
1224
1215
intravisit:: walk_ty ( self , hir_ty) ;
1225
1216
}
1226
1217
1218
+ fn visit_infer ( & mut self , inf : & ' tcx hir:: InferArg ) {
1219
+ self . span = inf. span ;
1220
+ if let Some ( typeck_results) = self . maybe_typeck_results {
1221
+ if let Some ( ty) = typeck_results. node_type_opt ( inf. hir_id ) {
1222
+ if self . visit ( ty) . is_break ( ) {
1223
+ return ;
1224
+ }
1225
+ }
1226
+ } else {
1227
+ // FIXME see above note for same issue.
1228
+ if self . visit ( rustc_typeck:: hir_ty_to_ty ( self . tcx , & inf. to_ty ( ) ) ) . is_break ( ) {
1229
+ return ;
1230
+ }
1231
+ }
1232
+ intravisit:: walk_inf ( self , inf) ;
1233
+ }
1234
+
1227
1235
fn visit_trait_ref ( & mut self , trait_ref : & ' tcx hir:: TraitRef < ' tcx > ) {
1228
1236
self . span = trait_ref. path . span ;
1229
1237
if self . maybe_typeck_results . is_none ( ) {
0 commit comments