From 5ae4500eff740b5935fc24b23e3c4be9789caf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 24 Feb 2020 14:42:14 +0100 Subject: [PATCH 1/3] remove redundant clones in librustc_mir_build and librustc_data_structures --- src/librustc_data_structures/obligation_forest/mod.rs | 4 ++-- src/librustc_mir_build/build/matches/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_data_structures/obligation_forest/mod.rs b/src/librustc_data_structures/obligation_forest/mod.rs index 334daddba8820..6711a49b2b7c1 100644 --- a/src/librustc_data_structures/obligation_forest/mod.rs +++ b/src/librustc_data_structures/obligation_forest/mod.rs @@ -314,7 +314,7 @@ impl ObligationForest { return Ok(()); } - match self.active_cache.entry(obligation.as_cache_key().clone()) { + match self.active_cache.entry(obligation.as_cache_key()) { Entry::Occupied(o) => { let node = &mut self.nodes[*o.get()]; if let Some(parent_index) = parent { @@ -385,7 +385,7 @@ impl ObligationForest { self.error_cache .entry(node.obligation_tree_id) .or_default() - .insert(node.obligation.as_cache_key().clone()); + .insert(node.obligation.as_cache_key()); } /// Performs a pass through the obligation list. This must diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index f900ae45b94d6..7995125524314 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -649,7 +649,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } PatKind::Or { ref pats } => { - self.visit_bindings(&pats[0], pattern_user_ty.clone(), f); + self.visit_bindings(&pats[0], pattern_user_ty, f); } } } From d4a005bd03dd2ef229bb809d128f9b31c159c18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 24 Feb 2020 14:48:40 +0100 Subject: [PATCH 2/3] librustc{, codegen_ssa,infer,mir_build}: don't clone types that are copy --- src/librustc/ty/context.rs | 2 +- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/query/job.rs | 2 +- src/librustc_codegen_ssa/mir/constant.rs | 2 +- src/librustc_infer/infer/lexical_region_resolve/mod.rs | 2 +- src/librustc_mir_build/build/expr/into.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index e59738d888608..c027d6f61b01f 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1526,7 +1526,7 @@ impl<'tcx> GlobalCtxt<'tcx> { ty::tls::with_related_context(tcx, |icx| { let new_icx = ty::tls::ImplicitCtxt { tcx, - query: icx.query.clone(), + query: icx.query, diagnostics: icx.diagnostics, layout_depth: icx.layout_depth, task_deps: icx.task_deps, diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index a195c944ff28d..d17ef3a6c9a8c 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1447,7 +1447,7 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd> { impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> { fn to_predicate(&self) -> Predicate<'tcx> { ty::Predicate::Trait( - ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value.clone() }), + ty::Binder::dummy(ty::TraitPredicate { trait_ref: *self.value }), self.constness, ) } diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index 8aae57e72cd52..3394fed840222 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -173,7 +173,7 @@ impl<'tcx> QueryLatch<'tcx> { return CycleError { usage, cycle }; } - current_job = info.job.parent.clone(); + current_job = info.job.parent; } panic!("did not find a cycle") diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 9ceb75a603bc4..4248627dccaf2 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -31,7 +31,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => { let val = self.eval_mir_constant(constant)?; let ty = self.monomorphize(&constant.literal.ty); - Ok(OperandRef::from_const(bx, val.clone(), ty)) + Ok(OperandRef::from_const(bx, val, ty)) } } } diff --git a/src/librustc_infer/infer/lexical_region_resolve/mod.rs b/src/librustc_infer/infer/lexical_region_resolve/mod.rs index 0b5536219e566..fc9f3bb076745 100644 --- a/src/librustc_infer/infer/lexical_region_resolve/mod.rs +++ b/src/librustc_infer/infer/lexical_region_resolve/mod.rs @@ -848,7 +848,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { for upper_bound in &upper_bounds { if let ty::RePlaceholder(p) = upper_bound.region { if node_universe.cannot_name(p.universe) { - let origin = self.var_infos[node_idx].origin.clone(); + let origin = self.var_infos[node_idx].origin; errors.push(RegionResolutionError::UpperBoundUniverseConflict( node_idx, origin, diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index 51b0b5bc7cb0b..4583e244f493d 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -376,7 +376,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { TerminatorKind::Yield { value, resume, - resume_arg: destination.clone(), + resume_arg: *destination, drop: cleanup, }, ); From 1892ff7aa6f7d82cbe18a531da3566fbd1939e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 24 Feb 2020 14:53:55 +0100 Subject: [PATCH 3/3] librustc_macros: remove redundant single component path import --- src/librustc_macros/src/hash_stable.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc_macros/src/hash_stable.rs b/src/librustc_macros/src/hash_stable.rs index e6f457dd663c2..dc6ae961e5a6e 100644 --- a/src/librustc_macros/src/hash_stable.rs +++ b/src/librustc_macros/src/hash_stable.rs @@ -1,7 +1,6 @@ use proc_macro2::{self, Ident}; use quote::quote; use syn::{self, parse_quote, Meta, NestedMeta}; -use synstructure; struct Attributes { ignore: bool,