@@ -69,10 +69,7 @@ struct NumericFallbackVisitor<'a, 'tcx> {
6969
7070impl < ' a , ' tcx > NumericFallbackVisitor < ' a , ' tcx > {
7171 fn new ( cx : & ' a LateContext < ' tcx > ) -> Self {
72- Self {
73- ty_bounds : vec ! [ TyBound :: Nothing ] ,
74- cx,
75- }
72+ Self { ty_bounds : vec ! [ TyBound :: Nothing ] , cx }
7673 }
7774
7875 /// Check whether a passed literal has potential to cause fallback or not.
@@ -129,19 +126,21 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
129126 }
130127 return ;
131128 }
132- } ,
129+ }
133130
134- ExprKind :: MethodCall ( _, args, _) => {
131+ ExprKind :: MethodCall ( _, receiver , args, _) => {
135132 if let Some ( def_id) = self . cx . typeck_results ( ) . type_dependent_def_id ( expr. hir_id ) {
136133 let fn_sig = self . cx . tcx . fn_sig ( def_id) . skip_binder ( ) ;
137- for ( expr, bound) in iter:: zip ( * args, fn_sig. inputs ( ) ) {
134+ for ( expr, bound) in
135+ iter:: zip ( std:: iter:: once ( * receiver) . chain ( args. iter ( ) ) , fn_sig. inputs ( ) )
136+ {
138137 self . ty_bounds . push ( TyBound :: Ty ( * bound) ) ;
139138 self . visit_expr ( expr) ;
140139 self . ty_bounds . pop ( ) ;
141140 }
142141 return ;
143142 }
144- } ,
143+ }
145144
146145 ExprKind :: Struct ( _, fields, base) => {
147146 let ty = self . cx . typeck_results ( ) . expr_ty ( expr) ;
@@ -176,15 +175,15 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
176175 return ;
177176 }
178177 }
179- } ,
178+ }
180179
181180 ExprKind :: Lit ( lit) => {
182181 let ty = self . cx . typeck_results ( ) . expr_ty ( expr) ;
183182 self . check_lit ( lit, ty, expr. hir_id ) ;
184183 return ;
185- } ,
184+ }
186185
187- _ => { } ,
186+ _ => { }
188187 }
189188
190189 walk_expr ( self , expr) ;
@@ -198,7 +197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
198197 } else {
199198 self . ty_bounds . push ( TyBound :: Nothing ) ;
200199 }
201- } ,
200+ }
202201
203202 _ => self . ty_bounds . push ( TyBound :: Nothing ) ,
204203 }
0 commit comments