From ebdee366b0e16d1d019db2f5c22a730b4451194f Mon Sep 17 00:00:00 2001 From: kjeremy Date: Mon, 6 Jul 2020 17:13:55 -0400 Subject: Clippy perf warnings Removes redundant clones --- crates/ra_hir_ty/src/display.rs | 4 ++-- crates/ra_hir_ty/src/infer/expr.rs | 6 ++---- crates/ra_hir_ty/src/lib.rs | 2 +- crates/ra_hir_ty/src/lower.rs | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) (limited to 'crates/ra_hir_ty') diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs index 23cea1a2a..ac68c5661 100644 --- a/crates/ra_hir_ty/src/display.rs +++ b/crates/ra_hir_ty/src/display.rs @@ -369,7 +369,7 @@ impl HirDisplay for ApplicationTy { let data = (*datas) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - data.clone().subst(&self.parameters) + data.subst(&self.parameters) } }; write!(f, "impl ")?; @@ -456,7 +456,7 @@ impl HirDisplay for Ty { let data = (*datas) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - data.clone().subst(&opaque_ty.parameters) + data.subst(&opaque_ty.parameters) } }; write!(f, "impl ")?; diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 22884522a..06baac2a9 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -85,10 +85,8 @@ impl<'a> InferenceContext<'a> { ctor: TypeCtor::Tuple { cardinality: num_args as u16 }, parameters, }); - let substs = Substs::build_for_generics(&generic_params) - .push(ty.clone()) - .push(arg_ty.clone()) - .build(); + let substs = + Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); let trait_env = Arc::clone(&self.trait_env); let implements_fn_trait = diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 7f3f5e771..c12bed4af 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs @@ -891,7 +891,7 @@ impl Ty { let data = (*it) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - data.clone().subst(&opaque_ty.parameters) + data.subst(&opaque_ty.parameters) }) } }; diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 3dc154e92..01af3187b 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -720,8 +720,7 @@ fn assoc_type_bindings_from_type_bound<'a>( None => return SmallVec::<[GenericPredicate; 1]>::new(), Some(t) => t, }; - let projection_ty = - ProjectionTy { associated_ty, parameters: super_trait_ref.substs.clone() }; + let projection_ty = ProjectionTy { associated_ty, parameters: super_trait_ref.substs }; let mut preds = SmallVec::with_capacity( binding.type_ref.as_ref().map_or(0, |_| 1) + binding.bounds.len(), ); -- cgit v1.2.3