diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-09-01 18:43:35 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-09-05 22:25:57 +0900 |
| commit | 4bcaddeeb23544eb2c86b600c3d775e2773758c2 (patch) | |
| tree | 565a007c45f4d890796abe66ad5d014f7fb7c4f7 /clippy_lints/src/default_numeric_fallback.rs | |
| parent | 9ae329232b368c6ca7352d403de9e34a71debc4b (diff) | |
| download | rust-4bcaddeeb23544eb2c86b600c3d775e2773758c2.tar.gz rust-4bcaddeeb23544eb2c86b600c3d775e2773758c2.zip | |
separate the receiver from arguments in HIR under /clippy
Diffstat (limited to 'clippy_lints/src/default_numeric_fallback.rs')
| -rw-r--r-- | clippy_lints/src/default_numeric_fallback.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/clippy_lints/src/default_numeric_fallback.rs b/clippy_lints/src/default_numeric_fallback.rs index fb418a3251f..64c5de51042 100644 --- a/clippy_lints/src/default_numeric_fallback.rs +++ b/clippy_lints/src/default_numeric_fallback.rs @@ -69,10 +69,7 @@ struct NumericFallbackVisitor<'a, 'tcx> { impl<'a, 'tcx> NumericFallbackVisitor<'a, 'tcx> { fn new(cx: &'a LateContext<'tcx>) -> Self { - Self { - ty_bounds: vec![TyBound::Nothing], - cx, - } + Self { ty_bounds: vec![TyBound::Nothing], cx } } /// 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> { } return; } - }, + } - ExprKind::MethodCall(_, args, _) => { + ExprKind::MethodCall(_, receiver, args, _) => { if let Some(def_id) = self.cx.typeck_results().type_dependent_def_id(expr.hir_id) { let fn_sig = self.cx.tcx.fn_sig(def_id).skip_binder(); - for (expr, bound) in iter::zip(*args, fn_sig.inputs()) { + for (expr, bound) in + iter::zip(std::iter::once(*receiver).chain(args.iter()), fn_sig.inputs()) + { self.ty_bounds.push(TyBound::Ty(*bound)); self.visit_expr(expr); self.ty_bounds.pop(); } return; } - }, + } ExprKind::Struct(_, fields, base) => { let ty = self.cx.typeck_results().expr_ty(expr); @@ -176,15 +175,15 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { return; } } - }, + } ExprKind::Lit(lit) => { let ty = self.cx.typeck_results().expr_ty(expr); self.check_lit(lit, ty, expr.hir_id); return; - }, + } - _ => {}, + _ => {} } walk_expr(self, expr); @@ -198,7 +197,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> { } else { self.ty_bounds.push(TyBound::Nothing); } - }, + } _ => self.ty_bounds.push(TyBound::Nothing), } |
