From c9b4ac5be4daaabc062ab1ee663eba8594750003 Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:24:16 +0530 Subject: clippy::redudant_borrow --- crates/hir_ty/src/infer/coerce.rs | 2 +- crates/hir_ty/src/infer/expr.rs | 12 ++++++------ crates/hir_ty/src/infer/pat.rs | 2 +- crates/hir_ty/src/infer/path.rs | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 03b97e7db..8647d7437 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -109,7 +109,7 @@ impl<'a> InferenceContext<'a> { } // Consider coercing the subtype to a DST - if let Ok(ret) = self.try_coerce_unsized(&from_ty, &to_ty) { + if let Ok(ret) = self.try_coerce_unsized(&from_ty, to_ty) { return Ok(ret); } diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index e34f194ff..4805c0a00 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -54,7 +54,7 @@ impl<'a> InferenceContext<'a> { /// Infer type of expression with possibly implicit coerce to the expected type. /// Return the type after possible coercion. pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty { - let ty = self.infer_expr_inner(expr, &expected); + let ty = self.infer_expr_inner(expr, expected); let ty = if let Some(target) = expected.only_has_type(&mut self.table) { if !self.coerce(&ty, &target) { self.result @@ -135,11 +135,11 @@ impl<'a> InferenceContext<'a> { let mut both_arms_diverge = Diverges::Always; let mut result_ty = self.table.new_type_var(); - let then_ty = self.infer_expr_inner(*then_branch, &expected); + let then_ty = self.infer_expr_inner(*then_branch, expected); both_arms_diverge &= mem::replace(&mut self.diverges, Diverges::Maybe); result_ty = self.coerce_merge_branch(Some(*then_branch), &result_ty, &then_ty); let else_ty = match else_branch { - Some(else_branch) => self.infer_expr_inner(*else_branch, &expected), + Some(else_branch) => self.infer_expr_inner(*else_branch, expected), None => TyBuilder::unit(), }; both_arms_diverge &= self.diverges; @@ -330,8 +330,8 @@ impl<'a> InferenceContext<'a> { .infer_method_call( tgt_expr, *receiver, - &args, - &method_name, + args, + method_name, generic_args.as_deref(), ), Expr::Match { expr, arms } => { @@ -993,7 +993,7 @@ impl<'a> InferenceContext<'a> { } fn register_obligations_for_call(&mut self, callable_ty: &Ty) { - let callable_ty = self.resolve_ty_shallow(&callable_ty); + let callable_ty = self.resolve_ty_shallow(callable_ty); if let TyKind::FnDef(fn_def, parameters) = callable_ty.kind(&Interner) { let def: CallableDefId = from_chalk(self.db, *fn_def); let generic_predicates = self.db.generic_predicates(def.into()); diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 25dff7e49..8f5db1f40 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -192,7 +192,7 @@ impl<'a> InferenceContext<'a> { Pat::Path(path) => { // FIXME use correct resolver for the surrounding expression let resolver = self.resolver.clone(); - self.infer_path(&resolver, &path, pat.into()).unwrap_or(self.err_ty()) + self.infer_path(&resolver, path, pat.into()).unwrap_or(self.err_ty()) } Pat::Bind { mode, name: _, subpat } => { let mode = if mode == &BindingAnnotation::Unannotated { diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index 14c99eafd..056cdb5d5 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs @@ -43,11 +43,11 @@ impl<'a> InferenceContext<'a> { } let ty = self.make_ty(type_ref); let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1); - let ctx = crate::lower::TyLoweringContext::new(self.db, &resolver); + let ctx = crate::lower::TyLoweringContext::new(self.db, resolver); let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty); self.resolve_ty_assoc_item( ty, - &path.segments().last().expect("path had at least one segment").name, + path.segments().last().expect("path had at least one segment").name, id, )? } else { @@ -154,7 +154,7 @@ impl<'a> InferenceContext<'a> { let segment = remaining_segments.last().expect("there should be at least one segment here"); - self.resolve_ty_assoc_item(ty, &segment.name, id) + self.resolve_ty_assoc_item(ty, segment.name, id) } } } -- cgit v1.2.3 From aabd41cafc1a79f5ad124a31a360ab0442c13efd Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:40:22 +0530 Subject: clippy::redundant_field_names --- crates/hir_ty/src/infer/pat.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 8f5db1f40..035f4ded6 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -275,7 +275,7 @@ impl<'a> InferenceContext<'a> { if !self.unify(&ty, &expected) { self.result .type_mismatches - .insert(pat.into(), TypeMismatch { expected: expected, actual: ty.clone() }); + .insert(pat.into(), TypeMismatch { expected, actual: ty.clone() }); } self.write_pat_ty(pat, ty.clone()); ty -- cgit v1.2.3 From 5ac6804bb3a07b959e8c2c3534255a8d6bb4948c Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:48:15 +0530 Subject: cargo fmt --- crates/hir_ty/src/infer/expr.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 4805c0a00..5ea2e5934 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -327,13 +327,7 @@ impl<'a> InferenceContext<'a> { self.normalize_associated_types_in(ret_ty) } Expr::MethodCall { receiver, args, method_name, generic_args } => self - .infer_method_call( - tgt_expr, - *receiver, - args, - method_name, - generic_args.as_deref(), - ), + .infer_method_call(tgt_expr, *receiver, args, method_name, generic_args.as_deref()), Expr::Match { expr, arms } => { let input_ty = self.infer_expr(*expr, &Expectation::none()); -- cgit v1.2.3