From c9b4ac5be4daaabc062ab1ee663eba8594750003 Mon Sep 17 00:00:00 2001 From: Maan2003 Date: Sun, 13 Jun 2021 09:24:16 +0530 Subject: clippy::redudant_borrow --- .../hir_ty/src/diagnostics/match_check/deconstruct_pat.rs | 2 +- crates/hir_ty/src/diagnostics/match_check/usefulness.rs | 6 +++--- crates/hir_ty/src/infer.rs | 2 +- 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 +++--- crates/hir_ty/src/interner.rs | 6 +++--- crates/hir_ty/src/lower.rs | 6 +++--- crates/hir_ty/src/method_resolution.rs | 14 +++++++------- 10 files changed, 29 insertions(+), 29 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs index 222141bd6..088d2791e 100644 --- a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs +++ b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs @@ -528,7 +528,7 @@ impl SplitWildcard { smallvec![NonExhaustive] } TyKind::Never => SmallVec::new(), - _ if cx.is_uninhabited(&pcx.ty) => SmallVec::new(), + _ if cx.is_uninhabited(pcx.ty) => SmallVec::new(), TyKind::Adt(..) | TyKind::Tuple(..) | TyKind::Ref(..) => smallvec![Single], // This type is one for which we cannot list constructors, like `str` or `f64`. _ => smallvec![NonExhaustive], diff --git a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs index bd76a606c..f5ac71444 100644 --- a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs +++ b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs @@ -645,7 +645,7 @@ impl SubPatSet { (Seq { subpats: s_set }, Seq { subpats: mut o_set }) => { s_set.retain(|i, s_sub_set| { // Missing entries count as full. - let o_sub_set = o_set.remove(&i).unwrap_or(Full); + let o_sub_set = o_set.remove(i).unwrap_or(Full); s_sub_set.union(o_sub_set); // We drop full entries. !s_sub_set.is_full() @@ -656,7 +656,7 @@ impl SubPatSet { (Alt { subpats: s_set, .. }, Alt { subpats: mut o_set, .. }) => { s_set.retain(|i, s_sub_set| { // Missing entries count as empty. - let o_sub_set = o_set.remove(&i).unwrap_or(Empty); + let o_sub_set = o_set.remove(i).unwrap_or(Empty); s_sub_set.union(o_sub_set); // We drop empty entries. !s_sub_set.is_empty() @@ -898,7 +898,7 @@ impl Usefulness { } else { witnesses .into_iter() - .map(|witness| witness.apply_constructor(pcx, &ctor, ctor_wild_subpatterns)) + .map(|witness| witness.apply_constructor(pcx, ctor, ctor_wild_subpatterns)) .collect() }; WithWitnesses(new_witnesses) diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index f023c1fb7..9590c2e47 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -782,7 +782,7 @@ impl Expectation { fn adjust_for_branches(&self, table: &mut unify::InferenceTable) -> Expectation { match self { Expectation::HasType(ety) => { - let ety = table.resolve_ty_shallow(&ety); + let ety = table.resolve_ty_shallow(ety); if !ety.is_ty_var() { Expectation::HasType(ety) } else { 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) } } } diff --git a/crates/hir_ty/src/interner.rs b/crates/hir_ty/src/interner.rs index 29ffdd9b7..5fef878e8 100644 --- a/crates/hir_ty/src/interner.rs +++ b/crates/hir_ty/src/interner.rs @@ -331,7 +331,7 @@ impl chalk_ir::interner::Interner for Interner { &self, clauses: &'a Self::InternedProgramClauses, ) -> &'a [chalk_ir::ProgramClause] { - &clauses + clauses } fn intern_quantified_where_clauses( @@ -373,7 +373,7 @@ impl chalk_ir::interner::Interner for Interner { &self, canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, ) -> &'a [chalk_ir::CanonicalVarKind] { - &canonical_var_kinds + canonical_var_kinds } fn intern_constraints( @@ -413,7 +413,7 @@ impl chalk_ir::interner::Interner for Interner { &self, variances: &'a Self::InternedVariances, ) -> &'a [chalk_ir::Variance] { - &variances + variances } } diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index c83933c73..0b8f21e5d 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -238,7 +238,7 @@ impl<'a> TyLoweringContext<'a> { // away instead of two. let actual_opaque_type_data = self .with_debruijn(DebruijnIndex::INNERMOST, |ctx| { - ctx.lower_impl_trait(&bounds) + ctx.lower_impl_trait(bounds) }); self.opaque_type_data.borrow_mut()[idx as usize] = actual_opaque_type_data; @@ -421,7 +421,7 @@ impl<'a> TyLoweringContext<'a> { let found = self .db .trait_data(trait_ref.hir_trait_id()) - .associated_type_by_name(&segment.name); + .associated_type_by_name(segment.name); match found { Some(associated_ty) => { // FIXME handle type parameters on the segment @@ -505,7 +505,7 @@ impl<'a> TyLoweringContext<'a> { pub(crate) fn lower_path(&self, path: &Path) -> (Ty, Option) { // Resolve the path (in type namespace) if let Some(type_ref) = path.type_anchor() { - let (ty, res) = self.lower_ty_ext(&type_ref); + let (ty, res) = self.lower_ty_ext(type_ref); return self.lower_ty_relative_path(ty, res, path.segments()); } let (resolution, remaining_index) = diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index a23527f7d..8c00a6369 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -372,7 +372,7 @@ pub(crate) fn lookup_method( db, env, krate, - &traits_in_scope, + traits_in_scope, visible_from_module, Some(name), LookupMode::MethodCall, @@ -484,7 +484,7 @@ fn iterate_method_candidates_impl( LookupMode::Path => { // No autoderef for path lookups iterate_method_candidates_for_self_ty( - &ty, + ty, db, env, krate, @@ -513,7 +513,7 @@ fn iterate_method_candidates_with_autoref( db, env.clone(), krate, - &traits_in_scope, + traits_in_scope, visible_from_module, name, &mut callback, @@ -531,7 +531,7 @@ fn iterate_method_candidates_with_autoref( db, env.clone(), krate, - &traits_in_scope, + traits_in_scope, visible_from_module, name, &mut callback, @@ -549,7 +549,7 @@ fn iterate_method_candidates_with_autoref( db, env, krate, - &traits_in_scope, + traits_in_scope, visible_from_module, name, &mut callback, @@ -593,7 +593,7 @@ fn iterate_method_candidates_by_receiver( db, env.clone(), krate, - &traits_in_scope, + traits_in_scope, name, Some(receiver_ty), &mut callback, @@ -870,7 +870,7 @@ fn transform_receiver_ty( .fill_with_unknown() .build(), AssocContainerId::ImplId(impl_id) => { - let impl_substs = inherent_impl_substs(db, env, impl_id, &self_ty)?; + let impl_substs = inherent_impl_substs(db, env, impl_id, self_ty)?; TyBuilder::subst_for_def(db, function_id) .use_parent_substs(&impl_substs) .fill_with_unknown() -- cgit v1.2.3