Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3837df2

Browse files
committed
don't clone types that are copy (clippy::clone_on_copy)
1 parent 139c646 commit 3837df2

File tree

25 files changed

+99
-111
lines changed

25 files changed

+99
-111
lines changed

src/librustc_builtin_macros/deriving/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
6363
let span = cx.with_def_site_ctxt(span);
6464
let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
6565
let builder = cx.ident_of("debug_trait_builder", span);
66-
let builder_expr = cx.expr_ident(span, builder.clone());
66+
let builder_expr = cx.expr_ident(span, builder);
6767

6868
let fmt = substr.nonself_args[0].clone();
6969

src/librustc_errors/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,7 @@ fn emit_to_destination(
20052005
let _buffer_lock = lock::acquire_global_lock("rustc_errors");
20062006
for (pos, line) in rendered_buffer.iter().enumerate() {
20072007
for part in line {
2008-
dst.apply_style(lvl.clone(), part.style)?;
2008+
dst.apply_style(*lvl, part.style)?;
20092009
write!(dst, "{}", part.text)?;
20102010
dst.reset()?;
20112011
}

src/librustc_infer/infer/error_reporting/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
871871
return Some(());
872872
}
873873
if let &ty::Adt(def, _) = &ta.kind {
874-
let path_ = self.tcx.def_path_str(def.did.clone());
874+
let path_ = self.tcx.def_path_str(def.did);
875875
if path_ == other_path {
876876
self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
877877
return Some(());
@@ -1091,8 +1091,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10911091
let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
10921092
let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
10931093
let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
1094-
let path1 = self.tcx.def_path_str(def1.did.clone());
1095-
let path2 = self.tcx.def_path_str(def2.did.clone());
1094+
let path1 = self.tcx.def_path_str(def1.did);
1095+
let path2 = self.tcx.def_path_str(def2.did);
10961096
if def1.did == def2.did {
10971097
// Easy case. Replace same types with `_` to shorten the output and highlight
10981098
// the differing ones.

src/librustc_infer/infer/outlives/obligations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ where
452452
// even though a satisfactory solution exists.
453453
let generic = GenericKind::Projection(projection_ty);
454454
let verify_bound = self.verify_bound.generic_bound(generic);
455-
self.delegate.push_verify(origin, generic.clone(), region, verify_bound);
455+
self.delegate.push_verify(origin, generic, region, verify_bound);
456456
}
457457
}
458458

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10561056
place: {:?}",
10571057
place_span.0
10581058
);
1059-
this.reservation_error_reported.insert(place_span.0.clone());
1059+
this.reservation_error_reported.insert(place_span.0);
10601060
}
10611061
Activation(_, activating) => {
10621062
debug!(

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
286286
// Box starts out uninitialized - need to create a separate
287287
// move-path for the interior so it will be separate from
288288
// the exterior.
289-
self.create_move_path(self.builder.tcx.mk_place_deref(place.clone()));
289+
self.create_move_path(self.builder.tcx.mk_place_deref(*place));
290290
self.gather_init(place.as_ref(), InitKind::Shallow);
291291
} else {
292292
self.gather_init(place.as_ref(), InitKind::Deep);
@@ -458,9 +458,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
458458
for offset in from..to {
459459
let elem =
460460
ProjectionElem::ConstantIndex { offset, min_length: len, from_end: false };
461-
let path = self.add_move_path(base_path, &elem, |tcx| {
462-
tcx.mk_place_elem(base_place.clone(), elem)
463-
});
461+
let path =
462+
self.add_move_path(base_path, &elem, |tcx| tcx.mk_place_elem(base_place, elem));
464463
self.record_move(place, path);
465464
}
466465
} else {

src/librustc_mir/monomorphize/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn collect_items_rec<'tcx>(
335335
recursion_depths: &mut DefIdMap<usize>,
336336
inlining_map: MTRef<'_, MTLock<InliningMap<'tcx>>>,
337337
) {
338-
if !visited.lock_mut().insert(starting_point.clone()) {
338+
if !visited.lock_mut().insert(starting_point) {
339339
// We've been here already, no need to search again.
340340
return;
341341
}

src/librustc_mir/shim.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl CloneShimBuilder<'tcx> {
538538
// BB #2
539539
// `dest[i] = Clone::clone(src[beg])`;
540540
// Goto #3 if ok, #5 if unwinding happens.
541-
let dest_field = self.tcx.mk_place_index(dest.clone(), beg);
541+
let dest_field = self.tcx.mk_place_index(dest, beg);
542542
let src_field = self.tcx.mk_place_index(src, beg);
543543
self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), BasicBlock::new(5));
544544

@@ -620,9 +620,9 @@ impl CloneShimBuilder<'tcx> {
620620
let mut previous_field = None;
621621
for (i, ity) in tys.enumerate() {
622622
let field = Field::new(i);
623-
let src_field = self.tcx.mk_place_field(src.clone(), field, ity);
623+
let src_field = self.tcx.mk_place_field(src, field, ity);
624624

625-
let dest_field = self.tcx.mk_place_field(dest.clone(), field, ity);
625+
let dest_field = self.tcx.mk_place_field(dest, field, ity);
626626

627627
// #(2i + 1) is the cleanup block for the previous clone operation
628628
let cleanup_block = self.block_index_offset(1);
@@ -633,7 +633,7 @@ impl CloneShimBuilder<'tcx> {
633633
// BB #(2i)
634634
// `dest.i = Clone::clone(&src.i);`
635635
// Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens.
636-
self.make_clone_call(dest_field.clone(), src_field, ity, next_block, cleanup_block);
636+
self.make_clone_call(dest_field, src_field, ity, next_block, cleanup_block);
637637

638638
// BB #(2i + 1) (cleanup)
639639
if let Some((previous_field, previous_cleanup)) = previous_field.take() {

src/librustc_mir/transform/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ impl Inliner<'tcx> {
582582
let tuple_tmp_args = tuple_tys.iter().enumerate().map(|(i, ty)| {
583583
// This is e.g., `tuple_tmp.0` in our example above.
584584
let tuple_field =
585-
Operand::Move(tcx.mk_place_field(tuple.clone(), Field::new(i), ty.expect_ty()));
585+
Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty.expect_ty()));
586586

587587
// Spill to a local to make e.g., `tmp0`.
588588
self.create_temp_if_necessary(tuple_field, callsite, caller_body)

src/librustc_mir/util/aggregate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn expand_aggregate<'tcx>(
5656
let offset = i as u32;
5757
assert_eq!(offset as usize, i);
5858
tcx.mk_place_elem(
59-
lhs.clone(),
59+
lhs,
6060
ProjectionElem::ConstantIndex {
6161
offset,
6262
// FIXME(eddyb) `min_length` doesn't appear to be used.
@@ -66,7 +66,7 @@ pub fn expand_aggregate<'tcx>(
6666
)
6767
} else {
6868
let field = Field::new(active_field_index.unwrap_or(i));
69-
tcx.mk_place_field(lhs.clone(), field, ty)
69+
tcx.mk_place_field(lhs, field, ty)
7070
};
7171
Statement { source_info, kind: StatementKind::Assign(box (lhs_field, Rvalue::Use(op))) }
7272
})

0 commit comments

Comments
 (0)