@@ -8,8 +8,9 @@ use rustc_hir::{
88 self as hir,
99 def:: { CtorOf , DefKind , Res } ,
1010 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 ,
1314} ;
1415use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
1516use rustc_middle:: hir:: map:: Map ;
@@ -263,6 +264,11 @@ struct SkipTyCollector {
263264impl < ' tcx > Visitor < ' tcx > for SkipTyCollector {
264265 type Map = Map < ' tcx > ;
265266
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+ }
266272 fn visit_ty ( & mut self , hir_ty : & hir:: Ty < ' _ > ) {
267273 self . types_to_skip . push ( hir_ty. hir_id ) ;
268274
@@ -274,6 +280,52 @@ impl<'tcx> Visitor<'tcx> for SkipTyCollector {
274280 }
275281}
276282
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
277329fn span_lint( cx: & LateContext <' _>, span: Span ) {
278330 span_lint_and_sugg(
279331 cx,
0 commit comments