Skip to content

Commit 5d55877

Browse files
authored
Rollup merge of #68292 - matthiaskrgr:clone_on_copy, r=eddyb
don't clone types that are copy Found via clippy. r? @eddyb
2 parents c411c22 + 7fbd30b commit 5d55877

File tree

15 files changed

+18
-20
lines changed

15 files changed

+18
-20
lines changed

src/librustc/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ impl<'tcx> ObligationCause<'tcx> {
20082008
TypeError::IntrinsicCast => {
20092009
Error0308("cannot coerce intrinsics to function pointers")
20102010
}
2011-
TypeError::ObjectUnsafeCoercion(did) => Error0038(did.clone()),
2011+
TypeError::ObjectUnsafeCoercion(did) => Error0038(*did),
20122012
_ => Error0308("mismatched types"),
20132013
},
20142014
}

src/librustc_ast_lowering/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -909,18 +909,18 @@ impl<'hir> LoweringContext<'_, 'hir> {
909909

910910
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind<'hir> {
911911
let inner = hir::InlineAsmInner {
912-
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
912+
inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
913913
outputs: asm
914914
.outputs
915915
.iter()
916916
.map(|out| hir::InlineAsmOutput {
917-
constraint: out.constraint.clone(),
917+
constraint: out.constraint,
918918
is_rw: out.is_rw,
919919
is_indirect: out.is_indirect,
920920
span: out.expr.span,
921921
})
922922
.collect(),
923-
asm: asm.asm.clone(),
923+
asm: asm.asm,
924924
asm_str_style: asm.asm_str_style,
925925
clobbers: asm.clobbers.clone().into(),
926926
volatile: asm.volatile,

src/librustc_builtin_macros/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ impl<'a> TraitDef<'a> {
16081608
} else {
16091609
ast::BindingMode::ByRef(mutbl)
16101610
};
1611-
cx.pat(path.span, PatKind::Ident(binding_mode, (*path).clone(), None))
1611+
cx.pat(path.span, PatKind::Ident(binding_mode, *path, None))
16121612
})
16131613
.collect()
16141614
}

src/librustc_errors/annotate_snippet_emitter_writer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl AnnotateSnippetEmitterWriter {
196196
) {
197197
let converter = DiagnosticConverter {
198198
source_map: self.source_map.clone(),
199-
level: level.clone(),
199+
level: *level,
200200
message,
201201
code: code.clone(),
202202
msp: msp.clone(),

src/librustc_incremental/persist/save.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn encode_work_product_index(
236236
let serialized_products: Vec<_> = work_products
237237
.iter()
238238
.map(|(id, work_product)| SerializedWorkProduct {
239-
id: id.clone(),
239+
id: *id,
240240
work_product: work_product.clone(),
241241
})
242242
.collect();

src/librustc_lint/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl LintStore {
245245

246246
pub fn register_renamed(&mut self, old_name: &str, new_name: &str) {
247247
let target = match self.by_name.get(new_name) {
248-
Some(&Id(lint_id)) => lint_id.clone(),
248+
Some(&Id(lint_id)) => lint_id,
249249
_ => bug!("invalid lint renaming of {} to {}", old_name, new_name),
250250
};
251251
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));

src/librustc_metadata/rmeta/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ impl<'a, 'tcx> CrateMetadata {
840840

841841
fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
842842
match self.is_proc_macro(id) {
843-
true => self.root.proc_macro_stability.clone(),
843+
true => self.root.proc_macro_stability,
844844
false => self.root.per_def.stability.get(self, id).map(|stab| stab.decode(self)),
845845
}
846846
}

src/librustc_metadata/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl<'tcx> EncodeContext<'tcx> {
504504
},
505505
proc_macro_data,
506506
proc_macro_stability: if is_proc_macro {
507-
tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| stab.clone())
507+
tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| *stab)
508508
} else {
509509
None
510510
},

src/librustc_mir/borrow_check/borrow_set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
200200
region,
201201
reserve_location: location,
202202
activation_location: TwoPhaseActivation::NotTwoPhase,
203-
borrowed_place: borrowed_place.clone(),
204-
assigned_place: assigned_place.clone(),
203+
borrowed_place: *borrowed_place,
204+
assigned_place: *assigned_place,
205205
};
206206
let idx = self.idx_vec.push(borrow);
207207
self.location_map.insert(location, idx);

src/librustc_mir_build/build/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
6565
} else if cx.body_owner_kind.is_fn_or_closure() {
6666
// fetch the fully liberated fn signature (that is, all bound
6767
// types/lifetimes replaced)
68-
let fn_sig = cx.tables().liberated_fn_sigs()[id].clone();
68+
let fn_sig = cx.tables().liberated_fn_sigs()[id];
6969
let fn_def_id = tcx.hir().local_def_id(id);
7070

7171
let ty = tcx.type_of(fn_def_id);

src/librustc_passes/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
9191
// deprecated_since and its reason.
9292
if let Some(parent_stab) = self.parent_stab {
9393
if parent_stab.rustc_depr.is_some() && stab.rustc_depr.is_none() {
94-
stab.rustc_depr = parent_stab.rustc_depr.clone()
94+
stab.rustc_depr = parent_stab.rustc_depr
9595
}
9696
}
9797

src/librustc_traits/chalk_context/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl context::UnificationOps<ChalkArenas<'tcx>, ChalkArenas<'tcx>>
400400
&mut self,
401401
value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>,
402402
) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) {
403-
(value.clone(), UniverseMap)
403+
(*value, UniverseMap)
404404
}
405405

406406
fn invert_goal(

src/librustc_typeck/check/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
175175
}
176176
ty::Infer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid),
177177
ty::FnPtr(sig) => {
178-
let expected_sig = ExpectedSig { cause_span: None, sig: sig.skip_binder().clone() };
178+
let expected_sig = ExpectedSig { cause_span: None, sig: *sig.skip_binder() };
179179
(Some(expected_sig), Some(ty::ClosureKind::Fn))
180180
}
181181
_ => (None, None),

src/librustdoc/clean/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
239239
// constraint, and add it to our list. Since we make sure to never re-add
240240
// deleted items, this process will always finish.
241241
while !vid_map.is_empty() {
242-
let target = vid_map.keys().next().expect("Keys somehow empty").clone();
242+
let target = *vid_map.keys().next().expect("Keys somehow empty");
243243
let deps = vid_map.remove(&target).expect("Entry somehow missing");
244244

245245
for smaller in deps.smaller.iter() {

src/libtest/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,7 @@ pub fn run_test(
485485
}
486486
StaticBenchFn(benchfn) => {
487487
// Benchmarks aren't expected to panic, so we run them all in-process.
488-
crate::bench::benchmark(desc, monitor_ch, opts.nocapture, |harness| {
489-
(benchfn.clone())(harness)
490-
});
488+
crate::bench::benchmark(desc, monitor_ch, opts.nocapture, benchfn);
491489
}
492490
DynTestFn(f) => {
493491
match strategy {

0 commit comments

Comments
 (0)