@@ -4,12 +4,12 @@ use clippy_utils::ty::expr_sig;
44use clippy_utils:: { is_default_equivalent, path_def_id} ;
55use rustc_errors:: Applicability ;
66use rustc_hir:: def:: Res ;
7- use rustc_hir:: intravisit:: { Visitor , walk_ty} ;
8- use rustc_hir:: { Block , Expr , ExprKind , LetStmt , Node , QPath , Ty , TyKind } ;
7+ use rustc_hir:: intravisit:: { InferKind , Visitor , VisitorExt , walk_ty} ;
8+ use rustc_hir:: { AmbigArg , Block , Expr , ExprKind , HirId , LetStmt , Node , QPath , Ty , TyKind } ;
99use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
1010use rustc_middle:: lint:: in_external_macro;
1111use rustc_session:: declare_lint_pass;
12- use rustc_span:: sym;
12+ use rustc_span:: { Span , sym} ;
1313
1414declare_clippy_lint ! {
1515 /// ### What it does
@@ -92,8 +92,13 @@ fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>)
9292struct InferVisitor ( bool ) ;
9393
9494impl Visitor < ' _ > for InferVisitor {
95- fn visit_ty ( & mut self , t : & Ty < ' _ > ) {
96- self . 0 |= matches ! ( t. kind, TyKind :: Infer | TyKind :: OpaqueDef ( ..) | TyKind :: TraitObject ( ..) ) ;
95+ fn visit_infer ( & mut self , inf_id : HirId , _inf_span : Span , _kind : InferKind < ' _ > ) -> Self :: Result {
96+ self . 0 = true ;
97+ self . visit_id ( inf_id) ;
98+ }
99+
100+ fn visit_ty ( & mut self , t : & Ty < ' _ , AmbigArg > ) {
101+ self . 0 |= matches ! ( t. kind, TyKind :: OpaqueDef ( ..) | TyKind :: TraitObject ( ..) ) ;
97102 if !self . 0 {
98103 walk_ty ( self , t) ;
99104 }
@@ -104,7 +109,7 @@ fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
104109 match cx. tcx . parent_hir_node ( expr. hir_id ) {
105110 Node :: LetStmt ( LetStmt { ty : Some ( ty) , .. } ) => {
106111 let mut v = InferVisitor :: default ( ) ;
107- v. visit_ty ( ty) ;
112+ v. visit_ty_unambig ( ty) ;
108113 !v. 0
109114 } ,
110115 Node :: Expr ( Expr {
0 commit comments