@@ -8,8 +8,9 @@ use rustc_hir::{
8
8
self as hir,
9
9
def:: { CtorOf , DefKind , Res } ,
10
10
def_id:: LocalDefId ,
11
- intravisit:: { walk_ty, NestedVisitorMap , Visitor } ,
12
- Expr , ExprKind , FnRetTy , FnSig , GenericArg , HirId , Impl , ImplItemKind , Item , ItemKind , Path , QPath , TyKind ,
11
+ intravisit:: { walk_ty, walk_inf, NestedVisitorMap , Visitor } ,
12
+ Expr , ExprKind , FnRetTy , FnSig , GenericArg , HirId , Impl , ImplItemKind , Item , ItemKind , Node , Path , PathSegment ,
13
+ QPath , TyKind ,
13
14
} ;
14
15
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
15
16
use rustc_middle:: hir:: map:: Map ;
@@ -263,6 +264,11 @@ struct SkipTyCollector {
263
264
impl < ' tcx > Visitor < ' tcx > for SkipTyCollector {
264
265
type Map = Map < ' tcx > ;
265
266
267
+ fn visit_infer ( & mut self , inf : & hir:: InferArg ) {
268
+ self . types_to_skip . push ( inf. hir_id ) ;
269
+
270
+ walk_inf ( self , inf)
271
+ }
266
272
fn visit_ty ( & mut self , hir_ty : & hir:: Ty < ' _ > ) {
267
273
self . types_to_skip . push ( hir_ty. hir_id ) ;
268
274
@@ -274,6 +280,52 @@ impl<'tcx> Visitor<'tcx> for SkipTyCollector {
274
280
}
275
281
}
276
282
283
+ <<<<<<< HEAD
284
+ =======
285
+ struct LintTyCollector < ' a , ' tcx > {
286
+ cx : & ' a LateContext < ' tcx > ,
287
+ self_ty : Ty < ' tcx > ,
288
+ types_to_lint : Vec < HirId > ,
289
+ types_to_skip : Vec < HirId > ,
290
+ }
291
+
292
+ impl <' a , ' tcx > Visitor < ' tcx > for LintTyCollector < ' a , ' tcx > {
293
+ type Map = Map < ' tcx > ;
294
+
295
+ fn visit_ty ( & mut self , hir_ty : & ' tcx hir:: Ty < ' _ > ) {
296
+ if_chain ! {
297
+ if let Some ( ty) = self . cx. typeck_results( ) . node_type_opt( hir_ty. hir_id) ;
298
+ if should_lint_ty( hir_ty, ty, self . self_ty) ;
299
+ then {
300
+ self . types_to_lint. push( hir_ty. hir_id) ;
301
+ } else {
302
+ self . types_to_skip. push( hir_ty. hir_id) ;
303
+ }
304
+ }
305
+
306
+ walk_ty( self , hir_ty) ;
307
+ }
308
+
309
+ fn visit_infer( & mut self , inf: & ' tcx hir:: InferArg ) {
310
+ if_chain! {
311
+ if let Some ( ty) = self . cx. typeck_results( ) . node_type_opt( inf. hir_id) ;
312
+ if should_lint_ty( & inf. to_ty( ) , ty, self . self_ty) ;
313
+ then {
314
+ self . types_to_lint. push( inf. hir_id) ;
315
+ } else {
316
+ self . types_to_skip. push( inf. hir_id) ;
317
+ }
318
+ }
319
+
320
+ walk_inf( self , inf)
321
+ }
322
+
323
+ fn nested_visit_map( & mut self ) -> NestedVisitorMap <Self :: Map > {
324
+ NestedVisitorMap :: None
325
+ }
326
+ }
327
+
328
+ >>>>>>> Add inferred args to typeck
277
329
fn span_lint( cx: & LateContext <' _>, span: Span ) {
278
330
span_lint_and_sugg(
279
331
cx,
0 commit comments