@@ -4,12 +4,12 @@ use clippy_utils::ty::expr_sig;
4
4
use clippy_utils:: { is_default_equivalent, path_def_id} ;
5
5
use rustc_errors:: Applicability ;
6
6
use 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 } ;
9
9
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
10
10
use rustc_middle:: lint:: in_external_macro;
11
11
use rustc_session:: declare_lint_pass;
12
- use rustc_span:: sym;
12
+ use rustc_span:: { Span , sym} ;
13
13
14
14
declare_clippy_lint ! {
15
15
/// ### What it does
@@ -92,8 +92,13 @@ fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>)
92
92
struct InferVisitor ( bool ) ;
93
93
94
94
impl 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 ( ..) ) ;
97
102
if !self . 0 {
98
103
walk_ty ( self , t) ;
99
104
}
@@ -104,7 +109,7 @@ fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
104
109
match cx. tcx . parent_hir_node ( expr. hir_id ) {
105
110
Node :: LetStmt ( LetStmt { ty : Some ( ty) , .. } ) => {
106
111
let mut v = InferVisitor :: default ( ) ;
107
- v. visit_ty ( ty) ;
112
+ v. visit_ty_unambig ( ty) ;
108
113
!v. 0
109
114
} ,
110
115
Node :: Expr ( Expr {
0 commit comments