Skip to content

Commit 294f9f3

Browse files
authoredApr 16, 2020
Rollup merge of #71179 - matthiaskrgr:cl6ppy, r=Dylan-DPC
fix more clippy warnings
·
1.88.01.44.0
2 parents 7da24a2 + 3837df2 commit 294f9f3

File tree

30 files changed

+111
-124
lines changed

30 files changed

+111
-124
lines changed
 

‎src/liballoc/vec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ impl<T> Vec<T> {
971971
}
972972

973973
let len = self.len();
974-
if !(index < len) {
974+
if index >= len {
975975
assert_failed(index, len);
976976
}
977977
unsafe {
@@ -1010,7 +1010,7 @@ impl<T> Vec<T> {
10101010
}
10111011

10121012
let len = self.len();
1013-
if !(index <= len) {
1013+
if index > len {
10141014
assert_failed(index, len);
10151015
}
10161016

@@ -1058,7 +1058,7 @@ impl<T> Vec<T> {
10581058
}
10591059

10601060
let len = self.len();
1061-
if !(index < len) {
1061+
if index >= len {
10621062
assert_failed(index, len);
10631063
}
10641064
unsafe {
@@ -1331,10 +1331,10 @@ impl<T> Vec<T> {
13311331
panic!("end drain index (is {}) should be <= len (is {})", end, len);
13321332
}
13331333

1334-
if !(start <= end) {
1334+
if start > end {
13351335
start_assert_failed(start, end);
13361336
}
1337-
if !(end <= len) {
1337+
if end > len {
13381338
end_assert_failed(end, len);
13391339
}
13401340

@@ -1432,7 +1432,7 @@ impl<T> Vec<T> {
14321432
panic!("`at` split index (is {}) should be <= len (is {})", at, len);
14331433
}
14341434

1435-
if !(at <= self.len()) {
1435+
if at > self.len() {
14361436
assert_failed(at, self.len());
14371437
}
14381438

‎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_infer/infer/outlives/verify.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
297297
self.collect_outlives_from_predicate_list(
298298
move |ty| ty == identity_proj,
299299
traits::elaborate_predicates(tcx, trait_predicates)
300-
.into_iter()
301300
.map(|o| o.predicate)
302301
.collect::<Vec<_>>(),
303302
)

‎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/borrow_check/region_infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
495495
// to store those. Otherwise, we'll pass in `None` to the
496496
// functions below, which will trigger them to report errors
497497
// eagerly.
498-
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(|| vec![]);
498+
let mut outlives_requirements = infcx.tcx.is_closure(mir_def_id).then(Vec::new);
499499

500500
self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);
501501

‎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/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ where
549549
let n = base.len(self)?;
550550
if n < u64::from(min_length) {
551551
// This can only be reached in ConstProp and non-rustc-MIR.
552-
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n.into() });
552+
throw_ub!(BoundsCheckFailed { len: min_length.into(), index: n });
553553
}
554554

555555
let index = if from_end {

‎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
})

‎src/librustc_mir/util/elaborate_drops.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ where
212212
assert_eq!(self.elaborator.param_env().reveal, Reveal::All);
213213
let field_ty =
214214
tcx.normalize_erasing_regions(self.elaborator.param_env(), f.ty(tcx, substs));
215-
(tcx.mk_place_field(base_place.clone(), field, field_ty), subpath)
215+
(tcx.mk_place_field(base_place, field, field_ty), subpath)
216216
})
217217
.collect()
218218
}
@@ -340,7 +340,7 @@ where
340340
.enumerate()
341341
.map(|(i, &ty)| {
342342
(
343-
self.tcx().mk_place_field(self.place.clone(), Field::new(i), ty),
343+
self.tcx().mk_place_field(self.place, Field::new(i), ty),
344344
self.elaborator.field_subpath(self.path, Field::new(i)),
345345
)
346346
})
@@ -353,7 +353,7 @@ where
353353
fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock {
354354
debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs);
355355

356-
let interior = self.tcx().mk_place_deref(self.place.clone());
356+
let interior = self.tcx().mk_place_deref(self.place);
357357
let interior_path = self.elaborator.deref_subpath(self.path);
358358

359359
let succ = self.succ; // FIXME(#43234)
@@ -434,7 +434,7 @@ where
434434

435435
if let Some(variant_path) = subpath {
436436
let base_place = tcx.mk_place_elem(
437-
self.place.clone(),
437+
self.place,
438438
ProjectionElem::Downcast(Some(variant.ident.name), variant_index),
439439
);
440440
let fields = self.move_paths_for_fields(base_place, variant_path, &variant, substs);
@@ -622,7 +622,7 @@ where
622622
(Rvalue::Use(copy(cur.into())), Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one))
623623
} else {
624624
(
625-
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place.clone(), cur)),
625+
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
626626
Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one),
627627
)
628628
};
@@ -654,7 +654,7 @@ where
654654
self.elaborator.patch().patch_terminator(
655655
drop_block,
656656
TerminatorKind::Drop {
657-
location: tcx.mk_place_deref(ptr.clone()),
657+
location: tcx.mk_place_deref(ptr),
658658
target: loop_block,
659659
unwind: unwind.into_option(),
660660
},
@@ -682,7 +682,7 @@ where
682682
.map(|i| {
683683
(
684684
tcx.mk_place_elem(
685-
self.place.clone(),
685+
self.place,
686686
ProjectionElem::ConstantIndex {
687687
offset: i,
688688
min_length: size,
@@ -719,8 +719,8 @@ where
719719
switch_ty: tcx.types.usize,
720720
values: From::from(USIZE_SWITCH_ZERO),
721721
targets: vec![
722-
self.drop_loop_pair(ety, false, len.clone()),
723-
self.drop_loop_pair(ety, true, len.clone()),
722+
self.drop_loop_pair(ety, false, len),
723+
self.drop_loop_pair(ety, true, len),
724724
],
725725
},
726726
}),
@@ -912,7 +912,7 @@ where
912912
.map(|(i, f)| {
913913
let field = Field::new(i);
914914
let field_ty = f.ty(tcx, substs);
915-
Operand::Move(tcx.mk_place_field(self.place.clone(), field, field_ty))
915+
Operand::Move(tcx.mk_place_field(self.place, field, field_ty))
916916
})
917917
.collect();
918918

‎src/librustc_mir_build/build/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::build::matches::ArmHasGuard;
22
use crate::build::ForGuard::OutsideGuard;
33
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
44
use crate::hair::*;
5-
use rustc_middle::mir::*;
65
use rustc_hir as hir;
6+
use rustc_middle::mir::*;
77
use rustc_span::Span;
88

99
impl<'a, 'tcx> Builder<'a, 'tcx> {
@@ -29,7 +29,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2929
// This is a `break`-able block
3030
let exit_block = this.cfg.start_new_block();
3131
let block_exit =
32-
this.in_breakable_scope(None, exit_block, destination.clone(), |this| {
32+
this.in_breakable_scope(None, exit_block, destination, |this| {
3333
this.ast_block_stmts(destination, block, span, stmts, expr, safety_mode)
3434
});
3535
this.cfg.goto(unpack!(block_exit), source_info, exit_block);

‎src/librustc_mir_build/build/expr/into.rs

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
use crate::build::expr::category::{Category, RvalueFunc};
44
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
55
use crate::hair::*;
6-
use rustc_middle::mir::*;
7-
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
86
use rustc_data_structures::fx::FxHashMap;
97
use rustc_hir as hir;
8+
use rustc_middle::mir::*;
9+
use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
1010
use rustc_span::symbol::sym;
1111

1212
use rustc_target::spec::abi::Abi;
@@ -139,31 +139,26 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
139139
// Start the loop.
140140
this.cfg.goto(block, source_info, loop_block);
141141

142-
this.in_breakable_scope(
143-
Some(loop_block),
144-
exit_block,
145-
destination.clone(),
146-
move |this| {
147-
// conduct the test, if necessary
148-
let body_block = this.cfg.start_new_block();
149-
let diverge_cleanup = this.diverge_cleanup();
150-
this.cfg.terminate(
151-
loop_block,
152-
source_info,
153-
TerminatorKind::FalseUnwind {
154-
real_target: body_block,
155-
unwind: Some(diverge_cleanup),
156-
},
157-
);
158-
159-
// The “return” value of the loop body must always be an unit. We therefore
160-
// introduce a unit temporary as the destination for the loop body.
161-
let tmp = this.get_unit_temp();
162-
// Execute the body, branching back to the test.
163-
let body_block_end = unpack!(this.into(tmp, body_block, body));
164-
this.cfg.goto(body_block_end, source_info, loop_block);
165-
},
166-
);
142+
this.in_breakable_scope(Some(loop_block), exit_block, destination, move |this| {
143+
// conduct the test, if necessary
144+
let body_block = this.cfg.start_new_block();
145+
let diverge_cleanup = this.diverge_cleanup();
146+
this.cfg.terminate(
147+
loop_block,
148+
source_info,
149+
TerminatorKind::FalseUnwind {
150+
real_target: body_block,
151+
unwind: Some(diverge_cleanup),
152+
},
153+
);
154+
155+
// The “return” value of the loop body must always be an unit. We therefore
156+
// introduce a unit temporary as the destination for the loop body.
157+
let tmp = this.get_unit_temp();
158+
// Execute the body, branching back to the test.
159+
let body_block_end = unpack!(this.into(tmp, body_block, body));
160+
this.cfg.goto(body_block_end, source_info, loop_block);
161+
});
167162
exit_block.unit()
168163
}
169164
ExprKind::Call { ty, fun, args, from_hir_call } => {
@@ -278,26 +273,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
278273

279274
let field_names = this.hir.all_fields(adt_def, variant_index);
280275

281-
let fields =
282-
if let Some(FruInfo { base, field_types }) = base {
283-
let base = unpack!(block = this.as_place(block, base));
284-
285-
// MIR does not natively support FRU, so for each
286-
// base-supplied field, generate an operand that
287-
// reads it from the base.
288-
field_names
289-
.into_iter()
290-
.zip(field_types.into_iter())
291-
.map(|(n, ty)| match fields_map.get(&n) {
292-
Some(v) => v.clone(),
293-
None => this.consume_by_copy_or_move(
294-
this.hir.tcx().mk_place_field(base.clone(), n, ty),
295-
),
296-
})
297-
.collect()
298-
} else {
299-
field_names.iter().filter_map(|n| fields_map.get(n).cloned()).collect()
300-
};
276+
let fields = if let Some(FruInfo { base, field_types }) = base {
277+
let base = unpack!(block = this.as_place(block, base));
278+
279+
// MIR does not natively support FRU, so for each
280+
// base-supplied field, generate an operand that
281+
// reads it from the base.
282+
field_names
283+
.into_iter()
284+
.zip(field_types.into_iter())
285+
.map(|(n, ty)| match fields_map.get(&n) {
286+
Some(v) => v.clone(),
287+
None => this.consume_by_copy_or_move(
288+
this.hir.tcx().mk_place_field(base, n, ty),
289+
),
290+
})
291+
.collect()
292+
} else {
293+
field_names.iter().filter_map(|n| fields_map.get(n).cloned()).collect()
294+
};
301295

302296
let inferred_ty = expr.ty;
303297
let user_ty = user_ty.map(|ty| {

‎src/librustc_mir_build/build/matches/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,9 +1903,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
19031903
self.schedule_drop_for_binding(binding.var_id, binding.span, OutsideGuard);
19041904
}
19051905
let rvalue = match binding.binding_mode {
1906-
BindingMode::ByValue => {
1907-
Rvalue::Use(self.consume_by_copy_or_move(binding.source.clone()))
1908-
}
1906+
BindingMode::ByValue => Rvalue::Use(self.consume_by_copy_or_move(binding.source)),
19091907
BindingMode::ByRef(borrow_kind) => {
19101908
Rvalue::Ref(re_erased, borrow_kind, binding.source)
19111909
}

‎src/librustc_mir_build/build/matches/util.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1515
subpatterns
1616
.iter()
1717
.map(|fieldpat| {
18-
let place = self.hir.tcx().mk_place_field(
19-
place.clone(),
20-
fieldpat.field,
21-
fieldpat.pattern.ty,
22-
);
18+
let place =
19+
self.hir.tcx().mk_place_field(place, fieldpat.field, fieldpat.pattern.ty);
2320
MatchPair::new(place, &fieldpat.pattern)
2421
})
2522
.collect()
@@ -44,14 +41,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4441
match_pairs.extend(prefix.iter().enumerate().map(|(idx, subpattern)| {
4542
let elem =
4643
ProjectionElem::ConstantIndex { offset: idx as u32, min_length, from_end: false };
47-
let place = tcx.mk_place_elem(place.clone(), elem);
44+
let place = tcx.mk_place_elem(*place, elem);
4845
MatchPair::new(place, subpattern)
4946
}));
5047

5148
if let Some(subslice_pat) = opt_slice {
5249
let suffix_len = suffix.len() as u32;
5350
let subslice = tcx.mk_place_elem(
54-
place.clone(),
51+
*place,
5552
ProjectionElem::Subslice {
5653
from: prefix.len() as u32,
5754
to: if exact_size { min_length - suffix_len } else { suffix_len },
@@ -68,7 +65,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6865
min_length,
6966
from_end: !exact_size,
7067
};
71-
let place = tcx.mk_place_elem(place.clone(), elem);
68+
let place = tcx.mk_place_elem(*place, elem);
7269
MatchPair::new(place, subpattern)
7370
}));
7471
}

‎src/librustc_passes/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
610610
// Warn if the user enables a lib feature multiple times.
611611
duplicate_feature_err(tcx.sess, *span, *feature);
612612
}
613-
remaining_lib_features.insert(feature, span.clone());
613+
remaining_lib_features.insert(feature, *span);
614614
}
615615
// `stdbuild` has special handling for `libc`, so we need to
616616
// recognise the feature when building std.

‎src/librustc_query_system/dep_graph/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl<K: DepKind> DepGraphQuery<K> {
1515
let mut graph = Graph::with_capacity(nodes.len(), edges.len());
1616
let mut indices = FxHashMap::default();
1717
for node in nodes {
18-
indices.insert(node.clone(), graph.add_node(node.clone()));
18+
indices.insert(*node, graph.add_node(*node));
1919
}
2020

2121
for &(ref source, ref target) in edges {

‎src/librustc_resolve/late/lifetimes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,13 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
643643
if param_name.name == kw::UnderscoreLifetime {
644644
// Pick the elided lifetime "definition" if one exists
645645
// and use it to make an elision scope.
646-
self.lifetime_uses.insert(def_id.clone(), LifetimeUseSet::Many);
646+
self.lifetime_uses.insert(def_id, LifetimeUseSet::Many);
647647
elision = Some(reg);
648648
} else {
649649
lifetimes.insert(name, reg);
650650
}
651651
} else {
652-
self.lifetime_uses.insert(def_id.clone(), LifetimeUseSet::Many);
652+
self.lifetime_uses.insert(def_id, LifetimeUseSet::Many);
653653
lifetimes.insert(name, reg);
654654
}
655655
}

‎src/librustc_trait_selection/traits/error_reporting/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
126126
.borrow_mut()
127127
.entry(span)
128128
.or_default()
129-
.push(error.obligation.predicate.clone());
129+
.push(error.obligation.predicate);
130130
}
131131

132132
// We do this in 2 passes because we want to display errors in order, though
@@ -1409,7 +1409,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
14091409
(self.tcx.sess.source_map().span_to_snippet(span), &obligation.cause.code)
14101410
{
14111411
let generics = self.tcx.generics_of(*def_id);
1412-
if generics.params.iter().filter(|p| p.name.as_str() != "Self").next().is_some()
1412+
if generics.params.iter().any(|p| p.name.as_str() != "Self")
14131413
&& !snippet.ends_with('>')
14141414
{
14151415
// FIXME: To avoid spurious suggestions in functions where type arguments
@@ -1838,7 +1838,7 @@ pub fn suggest_constraining_type_param(
18381838
// Account for `fn foo<T>(t: T) where T: Foo,` so we don't suggest two trailing commas.
18391839
let mut trailing_comma = false;
18401840
if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(where_clause_span) {
1841-
trailing_comma = snippet.ends_with(",");
1841+
trailing_comma = snippet.ends_with(',');
18421842
}
18431843
let where_clause_span = if trailing_comma {
18441844
let hi = where_clause_span.hi();

‎src/librustc_trait_selection/traits/fulfill.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
314314

315315
match obligation.predicate {
316316
ty::Predicate::Trait(ref data, _) => {
317-
let trait_obligation = obligation.with(data.clone());
317+
let trait_obligation = obligation.with(*data);
318318

319319
if data.is_global() {
320320
// no type variables present, can use evaluation for better caching.
@@ -420,7 +420,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
420420
}
421421

422422
ty::Predicate::Projection(ref data) => {
423-
let project_obligation = obligation.with(data.clone());
423+
let project_obligation = obligation.with(*data);
424424
match project::poly_project_and_unify_type(self.selcx, &project_obligation) {
425425
Ok(None) => {
426426
let tcx = self.selcx.tcx();

‎src/librustc_trait_selection/traits/select.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
413413
match obligation.predicate {
414414
ty::Predicate::Trait(ref t, _) => {
415415
debug_assert!(!t.has_escaping_bound_vars());
416-
let obligation = obligation.with(t.clone());
416+
let obligation = obligation.with(*t);
417417
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
418418
}
419419

@@ -460,7 +460,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
460460
}
461461

462462
ty::Predicate::Projection(ref data) => {
463-
let project_obligation = obligation.with(data.clone());
463+
let project_obligation = obligation.with(*data);
464464
match project::poly_project_and_unify_type(self, &project_obligation) {
465465
Ok(Some(mut subobligations)) => {
466466
self.add_depth(subobligations.iter_mut(), obligation.recursion_depth);
@@ -910,7 +910,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
910910
// separately rather than using `stack.fresh_trait_ref` --
911911
// this is because we want the unbound variables to be
912912
// replaced with fresh types starting from index 0.
913-
let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate.clone());
913+
let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate);
914914
debug!(
915915
"candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})",
916916
cache_fresh_trait_pred, stack
@@ -1448,8 +1448,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14481448
self.infcx.probe(|_| {
14491449
self.match_projection(
14501450
obligation,
1451-
bound.clone(),
1452-
placeholder_trait_predicate.trait_ref.clone(),
1451+
*bound,
1452+
placeholder_trait_predicate.trait_ref,
14531453
&placeholder_map,
14541454
snapshot,
14551455
)
@@ -1468,7 +1468,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14681468
let result = self.match_projection(
14691469
obligation,
14701470
bound,
1471-
placeholder_trait_predicate.trait_ref.clone(),
1471+
placeholder_trait_predicate.trait_ref,
14721472
&placeholder_map,
14731473
snapshot,
14741474
);
@@ -1520,7 +1520,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15201520
// Keep only those bounds which may apply, and propagate overflow if it occurs.
15211521
let mut param_candidates = vec![];
15221522
for bound in matching_bounds {
1523-
let wc = self.evaluate_where_clause(stack, bound.clone())?;
1523+
let wc = self.evaluate_where_clause(stack, bound)?;
15241524
if wc.may_apply() {
15251525
param_candidates.push(ParamCandidate(bound));
15261526
}
@@ -2496,7 +2496,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
24962496
// where-clause trait-ref could be unified with the obligation
24972497
// trait-ref. Repeat that unification now without any
24982498
// transactional boundary; it should not fail.
2499-
match self.match_where_clause_trait_ref(obligation, param.clone()) {
2499+
match self.match_where_clause_trait_ref(obligation, param) {
25002500
Ok(obligations) => obligations,
25012501
Err(()) => {
25022502
bug!(

‎src/librustc_typeck/check/writeback.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
373373
);
374374
};
375375

376-
self.tables.user_provided_types_mut().insert(hir_id, c_ty.clone());
376+
self.tables.user_provided_types_mut().insert(hir_id, *c_ty);
377377

378378
if let ty::UserType::TypeOf(_, user_substs) = c_ty.value {
379379
if self.rustc_dump_user_substs {
@@ -411,7 +411,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
411411
);
412412
};
413413

414-
self.tables.user_provided_sigs.insert(def_id, c_sig.clone());
414+
self.tables.user_provided_sigs.insert(def_id, *c_sig);
415415
}
416416
}
417417

@@ -562,7 +562,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
562562
for (&local_id, fn_sig) in fcx_tables.liberated_fn_sigs().iter() {
563563
let hir_id = hir::HirId { owner: common_hir_owner, local_id };
564564
let fn_sig = self.resolve(fn_sig, &hir_id);
565-
self.tables.liberated_fn_sigs_mut().insert(hir_id, fn_sig.clone());
565+
self.tables.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
566566
}
567567
}
568568

‎src/librustdoc/clean/auto_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
509509
continue;
510510
}
511511

512-
let mut for_generics = self.extract_for_generics(tcx, orig_p.clone());
512+
let mut for_generics = self.extract_for_generics(tcx, orig_p);
513513

514514
assert!(bounds.len() == 1);
515515
let mut b = bounds.pop().expect("bounds were empty");

‎src/librustdoc/clean/inline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn try_inline(
4747
}
4848
let mut ret = Vec::new();
4949

50-
let attrs_clone = attrs.clone();
50+
let attrs_clone = attrs;
5151

5252
let inner = match res {
5353
Res::Def(DefKind::Trait, did) => {
@@ -292,7 +292,7 @@ pub fn build_impls(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>) ->
292292
let mut impls = Vec::new();
293293

294294
for &did in tcx.inherent_impls(did).iter() {
295-
build_impl(cx, did, attrs.clone(), &mut impls);
295+
build_impl(cx, did, attrs, &mut impls);
296296
}
297297

298298
impls

‎src/librustdoc/docfs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use std::sync::mpsc::{channel, Receiver, Sender};
1616
use std::sync::Arc;
1717

1818
macro_rules! try_err {
19-
($e:expr, $file:expr) => {{
19+
($e:expr, $file:expr) => {
2020
match $e {
2121
Ok(e) => e,
2222
Err(e) => return Err(E::new(e, $file)),
2323
}
24-
}};
24+
};
2525
}
2626

2727
pub trait PathError {

‎src/librustdoc/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl Tester for Collector {
683683
let name = self.generate_name(line, &filename);
684684
let cratename = self.cratename.to_string();
685685
let opts = self.opts.clone();
686-
let edition = config.edition.unwrap_or(self.options.edition.clone());
686+
let edition = config.edition.unwrap_or(self.options.edition);
687687
let options = self.options.clone();
688688
let runtool = self.options.runtool.clone();
689689
let runtool_args = self.options.runtool_args.clone();

0 commit comments

Comments
 (0)
Please sign in to comment.