From 7fbd30b1ae0ce9293302bbf4bfb814f1dc791107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 16 Jan 2020 23:15:52 +0100 Subject: [PATCH] don't clone types that are copy found via clippy --- src/librustc/infer/error_reporting/mod.rs | 2 +- src/librustc_ast_lowering/expr.rs | 6 +++--- src/librustc_builtin_macros/deriving/generic/mod.rs | 2 +- src/librustc_errors/annotate_snippet_emitter_writer.rs | 2 +- src/librustc_incremental/persist/save.rs | 2 +- src/librustc_lint/context.rs | 2 +- src/librustc_metadata/rmeta/decoder.rs | 2 +- src/librustc_metadata/rmeta/encoder.rs | 2 +- src/librustc_mir/borrow_check/borrow_set.rs | 4 ++-- src/librustc_mir_build/build/mod.rs | 2 +- src/librustc_passes/stability.rs | 2 +- src/librustc_traits/chalk_context/mod.rs | 2 +- src/librustc_typeck/check/closure.rs | 2 +- src/librustdoc/clean/auto_trait.rs | 2 +- src/libtest/lib.rs | 4 +--- 15 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index c52d4335ea1..febf4f21a67 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -2008,7 +2008,7 @@ impl<'tcx> ObligationCause<'tcx> { TypeError::IntrinsicCast => { Error0308("cannot coerce intrinsics to function pointers") } - TypeError::ObjectUnsafeCoercion(did) => Error0038(did.clone()), + TypeError::ObjectUnsafeCoercion(did) => Error0038(*did), _ => Error0308("mismatched types"), }, } diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index 9a229e709a5..2866a1624de 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -909,18 +909,18 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind<'hir> { let inner = hir::InlineAsmInner { - inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(), + inputs: asm.inputs.iter().map(|&(c, _)| c).collect(), outputs: asm .outputs .iter() .map(|out| hir::InlineAsmOutput { - constraint: out.constraint.clone(), + constraint: out.constraint, is_rw: out.is_rw, is_indirect: out.is_indirect, span: out.expr.span, }) .collect(), - asm: asm.asm.clone(), + asm: asm.asm, asm_str_style: asm.asm_str_style, clobbers: asm.clobbers.clone().into(), volatile: asm.volatile, diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs index 7092483843f..9226f458165 100644 --- a/src/librustc_builtin_macros/deriving/generic/mod.rs +++ b/src/librustc_builtin_macros/deriving/generic/mod.rs @@ -1608,7 +1608,7 @@ impl<'a> TraitDef<'a> { } else { ast::BindingMode::ByRef(mutbl) }; - cx.pat(path.span, PatKind::Ident(binding_mode, (*path).clone(), None)) + cx.pat(path.span, PatKind::Ident(binding_mode, *path, None)) }) .collect() } diff --git a/src/librustc_errors/annotate_snippet_emitter_writer.rs b/src/librustc_errors/annotate_snippet_emitter_writer.rs index 7413cef6d32..009ab6ac5b1 100644 --- a/src/librustc_errors/annotate_snippet_emitter_writer.rs +++ b/src/librustc_errors/annotate_snippet_emitter_writer.rs @@ -196,7 +196,7 @@ impl AnnotateSnippetEmitterWriter { ) { let converter = DiagnosticConverter { source_map: self.source_map.clone(), - level: level.clone(), + level: *level, message, code: code.clone(), msp: msp.clone(), diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 588e639f289..87f39dedd02 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -236,7 +236,7 @@ fn encode_work_product_index( let serialized_products: Vec<_> = work_products .iter() .map(|(id, work_product)| SerializedWorkProduct { - id: id.clone(), + id: *id, work_product: work_product.clone(), }) .collect(); diff --git a/src/librustc_lint/context.rs b/src/librustc_lint/context.rs index 2b514c301f2..42ec8787cb2 100644 --- a/src/librustc_lint/context.rs +++ b/src/librustc_lint/context.rs @@ -245,7 +245,7 @@ impl LintStore { pub fn register_renamed(&mut self, old_name: &str, new_name: &str) { let target = match self.by_name.get(new_name) { - Some(&Id(lint_id)) => lint_id.clone(), + Some(&Id(lint_id)) => lint_id, _ => bug!("invalid lint renaming of {} to {}", old_name, new_name), }; self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target)); diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs index eb3dcfa7227..6280121f655 100644 --- a/src/librustc_metadata/rmeta/decoder.rs +++ b/src/librustc_metadata/rmeta/decoder.rs @@ -840,7 +840,7 @@ impl<'a, 'tcx> CrateMetadata { fn get_stability(&self, id: DefIndex) -> Option { match self.is_proc_macro(id) { - true => self.root.proc_macro_stability.clone(), + true => self.root.proc_macro_stability, false => self.root.per_def.stability.get(self, id).map(|stab| stab.decode(self)), } } diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 7f8791d0c34..8ad92ce75a8 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -504,7 +504,7 @@ impl<'tcx> EncodeContext<'tcx> { }, proc_macro_data, proc_macro_stability: if is_proc_macro { - tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| stab.clone()) + tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| *stab) } else { None }, diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index f2a44986cc4..9d5cf3ec4be 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -200,8 +200,8 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> { region, reserve_location: location, activation_location: TwoPhaseActivation::NotTwoPhase, - borrowed_place: borrowed_place.clone(), - assigned_place: assigned_place.clone(), + borrowed_place: *borrowed_place, + assigned_place: *assigned_place, }; let idx = self.idx_vec.push(borrow); self.location_map.insert(location, idx); diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 6214453e64f..44ff493b5b4 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -65,7 +65,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> { } else if cx.body_owner_kind.is_fn_or_closure() { // fetch the fully liberated fn signature (that is, all bound // types/lifetimes replaced) - let fn_sig = cx.tables().liberated_fn_sigs()[id].clone(); + let fn_sig = cx.tables().liberated_fn_sigs()[id]; let fn_def_id = tcx.hir().local_def_id(id); let ty = tcx.type_of(fn_def_id); diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index af37d218d68..5ec7e73f873 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -91,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { // deprecated_since and its reason. if let Some(parent_stab) = self.parent_stab { if parent_stab.rustc_depr.is_some() && stab.rustc_depr.is_none() { - stab.rustc_depr = parent_stab.rustc_depr.clone() + stab.rustc_depr = parent_stab.rustc_depr } } diff --git a/src/librustc_traits/chalk_context/mod.rs b/src/librustc_traits/chalk_context/mod.rs index 4b10b08ddd9..0b18352df33 100644 --- a/src/librustc_traits/chalk_context/mod.rs +++ b/src/librustc_traits/chalk_context/mod.rs @@ -400,7 +400,7 @@ impl context::UnificationOps, ChalkArenas<'tcx>> &mut self, value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, ) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) { - (value.clone(), UniverseMap) + (*value, UniverseMap) } fn invert_goal( diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 6bb7f4995b6..084e6c8d083 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -175,7 +175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } ty::Infer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid), ty::FnPtr(sig) => { - let expected_sig = ExpectedSig { cause_span: None, sig: sig.skip_binder().clone() }; + let expected_sig = ExpectedSig { cause_span: None, sig: *sig.skip_binder() }; (Some(expected_sig), Some(ty::ClosureKind::Fn)) } _ => (None, None), diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 56013ee3a81..f37f6921ceb 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -239,7 +239,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { // constraint, and add it to our list. Since we make sure to never re-add // deleted items, this process will always finish. while !vid_map.is_empty() { - let target = vid_map.keys().next().expect("Keys somehow empty").clone(); + let target = *vid_map.keys().next().expect("Keys somehow empty"); let deps = vid_map.remove(&target).expect("Entry somehow missing"); for smaller in deps.smaller.iter() { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 45669d120c7..4c4d7958243 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -485,9 +485,7 @@ pub fn run_test( } StaticBenchFn(benchfn) => { // Benchmarks aren't expected to panic, so we run them all in-process. - crate::bench::benchmark(desc, monitor_ch, opts.nocapture, |harness| { - (benchfn.clone())(harness) - }); + crate::bench::benchmark(desc, monitor_ch, opts.nocapture, benchfn); } DynTestFn(f) => { match strategy {