]> git.lizzy.rs Git - rust.git/commitdiff
don't clone types that are copy (clippy::clone_on_copy)
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 15 Apr 2020 22:00:22 +0000 (00:00 +0200)
committerMatthias Krüger <matthias.krueger@famsik.de>
Wed, 15 Apr 2020 22:17:38 +0000 (00:17 +0200)
25 files changed:
src/librustc_builtin_macros/deriving/debug.rs
src/librustc_errors/emitter.rs
src/librustc_infer/infer/error_reporting/mod.rs
src/librustc_infer/infer/outlives/obligations.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/dataflow/move_paths/builder.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/inline.rs
src/librustc_mir/util/aggregate.rs
src/librustc_mir/util/elaborate_drops.rs
src/librustc_mir_build/build/block.rs
src/librustc_mir_build/build/expr/into.rs
src/librustc_mir_build/build/matches/mod.rs
src/librustc_mir_build/build/matches/util.rs
src/librustc_passes/stability.rs
src/librustc_query_system/dep_graph/query.rs
src/librustc_resolve/late/lifetimes.rs
src/librustc_trait_selection/traits/error_reporting/mod.rs
src/librustc_trait_selection/traits/fulfill.rs
src/librustc_trait_selection/traits/select.rs
src/librustc_typeck/check/writeback.rs
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/inline.rs
src/librustdoc/test.rs

index f47be3c3c197503bc493f9c9f08eaf67be622c52..71f6eb4485845d55c6ece9bf41f229e3c926c1b7 100644 (file)
@@ -63,7 +63,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
     let span = cx.with_def_site_ctxt(span);
     let name = cx.expr_lit(span, ast::LitKind::Str(ident.name, ast::StrStyle::Cooked));
     let builder = cx.ident_of("debug_trait_builder", span);
-    let builder_expr = cx.expr_ident(span, builder.clone());
+    let builder_expr = cx.expr_ident(span, builder);
 
     let fmt = substr.nonself_args[0].clone();
 
index 3f5738a93a96d8f64e0347efed242e18e186ff45..0023ff595fc543db2c340fec3311e74f1851d727 100644 (file)
@@ -2005,7 +2005,7 @@ fn emit_to_destination(
     let _buffer_lock = lock::acquire_global_lock("rustc_errors");
     for (pos, line) in rendered_buffer.iter().enumerate() {
         for part in line {
-            dst.apply_style(lvl.clone(), part.style)?;
+            dst.apply_style(*lvl, part.style)?;
             write!(dst, "{}", part.text)?;
             dst.reset()?;
         }
index 4189570a0da58d5f163705b50050da72b279440a..2aed0b7490cabf934a9a334540f32dc31c94bb6a 100644 (file)
@@ -871,7 +871,7 @@ fn cmp_type_arg(
                 return Some(());
             }
             if let &ty::Adt(def, _) = &ta.kind {
-                let path_ = self.tcx.def_path_str(def.did.clone());
+                let path_ = self.tcx.def_path_str(def.did);
                 if path_ == other_path {
                     self.highlight_outer(&mut t1_out, &mut t2_out, path, sub, i, &other_ty);
                     return Some(());
@@ -1091,8 +1091,8 @@ fn push_ty_ref<'tcx>(
                 let sub_no_defaults_1 = self.strip_generic_default_params(def1.did, sub1);
                 let sub_no_defaults_2 = self.strip_generic_default_params(def2.did, sub2);
                 let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new());
-                let path1 = self.tcx.def_path_str(def1.did.clone());
-                let path2 = self.tcx.def_path_str(def2.did.clone());
+                let path1 = self.tcx.def_path_str(def1.did);
+                let path2 = self.tcx.def_path_str(def2.did);
                 if def1.did == def2.did {
                     // Easy case. Replace same types with `_` to shorten the output and highlight
                     // the differing ones.
index e6feb5e1edcb56902ddd0d353e2f9805d7f02c75..c904926e9d93cb6f89019a3d6a36d43f50179458 100644 (file)
@@ -452,7 +452,7 @@ fn projection_must_outlive(
         // even though a satisfactory solution exists.
         let generic = GenericKind::Projection(projection_ty);
         let verify_bound = self.verify_bound.generic_bound(generic);
-        self.delegate.push_verify(origin, generic.clone(), region, verify_bound);
+        self.delegate.push_verify(origin, generic, region, verify_bound);
     }
 }
 
index 52847af214f6c760e90cb5dfbfcfdc09d2a92bbe..6aefd86c49a253dbdf793a88727bebbc0ecb46e7 100644 (file)
@@ -1056,7 +1056,7 @@ fn check_access_for_conflict(
                                  place: {:?}",
                                 place_span.0
                             );
-                            this.reservation_error_reported.insert(place_span.0.clone());
+                            this.reservation_error_reported.insert(place_span.0);
                         }
                         Activation(_, activating) => {
                             debug!(
index fabe575c28904e2715eda7492a6fc1da924e1abf..a5f46c28cd6744ee28d716a5db8934c3ea255645 100644 (file)
@@ -286,7 +286,7 @@ fn gather_statement(&mut self, stmt: &Statement<'tcx>) {
                     // Box starts out uninitialized - need to create a separate
                     // move-path for the interior so it will be separate from
                     // the exterior.
-                    self.create_move_path(self.builder.tcx.mk_place_deref(place.clone()));
+                    self.create_move_path(self.builder.tcx.mk_place_deref(*place));
                     self.gather_init(place.as_ref(), InitKind::Shallow);
                 } else {
                     self.gather_init(place.as_ref(), InitKind::Deep);
@@ -458,9 +458,8 @@ fn gather_move(&mut self, place: Place<'tcx>) {
             for offset in from..to {
                 let elem =
                     ProjectionElem::ConstantIndex { offset, min_length: len, from_end: false };
-                let path = self.add_move_path(base_path, &elem, |tcx| {
-                    tcx.mk_place_elem(base_place.clone(), elem)
-                });
+                let path =
+                    self.add_move_path(base_path, &elem, |tcx| tcx.mk_place_elem(base_place, elem));
                 self.record_move(place, path);
             }
         } else {
index d8ceda96a25e1d4984188e94f38ea13870000b03..ebed96c758d5b7c9a2c9837663ea784f5e1ad312 100644 (file)
@@ -335,7 +335,7 @@ fn collect_items_rec<'tcx>(
     recursion_depths: &mut DefIdMap<usize>,
     inlining_map: MTRef<'_, MTLock<InliningMap<'tcx>>>,
 ) {
-    if !visited.lock_mut().insert(starting_point.clone()) {
+    if !visited.lock_mut().insert(starting_point) {
         // We've been here already, no need to search again.
         return;
     }
index e1473cbfb6328500c4dfe8a1fba85c5eb1e1af43..a5034baa78e626b36d6156321bce8152bc455f4a 100644 (file)
@@ -538,7 +538,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         // BB #2
         // `dest[i] = Clone::clone(src[beg])`;
         // Goto #3 if ok, #5 if unwinding happens.
-        let dest_field = self.tcx.mk_place_index(dest.clone(), beg);
+        let dest_field = self.tcx.mk_place_index(dest, beg);
         let src_field = self.tcx.mk_place_index(src, beg);
         self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), BasicBlock::new(5));
 
@@ -620,9 +620,9 @@ fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>, src: Place<'tcx>, tys: I)
         let mut previous_field = None;
         for (i, ity) in tys.enumerate() {
             let field = Field::new(i);
-            let src_field = self.tcx.mk_place_field(src.clone(), field, ity);
+            let src_field = self.tcx.mk_place_field(src, field, ity);
 
-            let dest_field = self.tcx.mk_place_field(dest.clone(), field, ity);
+            let dest_field = self.tcx.mk_place_field(dest, field, ity);
 
             // #(2i + 1) is the cleanup block for the previous clone operation
             let cleanup_block = self.block_index_offset(1);
@@ -633,7 +633,7 @@ fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>, src: Place<'tcx>, tys: I)
             // BB #(2i)
             // `dest.i = Clone::clone(&src.i);`
             // Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens.
-            self.make_clone_call(dest_field.clone(), src_field, ity, next_block, cleanup_block);
+            self.make_clone_call(dest_field, src_field, ity, next_block, cleanup_block);
 
             // BB #(2i + 1) (cleanup)
             if let Some((previous_field, previous_cleanup)) = previous_field.take() {
index 8121d4ead13943dfd5c0fc543cc2ff661802d765..bfa13abb871c285b41398aa4510d30519b2f9ca9 100644 (file)
@@ -582,7 +582,7 @@ fn make_call_args(
             let tuple_tmp_args = tuple_tys.iter().enumerate().map(|(i, ty)| {
                 // This is e.g., `tuple_tmp.0` in our example above.
                 let tuple_field =
-                    Operand::Move(tcx.mk_place_field(tuple.clone(), Field::new(i), ty.expect_ty()));
+                    Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty.expect_ty()));
 
                 // Spill to a local to make e.g., `tmp0`.
                 self.create_temp_if_necessary(tuple_field, callsite, caller_body)
index e77d264b7ce5cfa0e25eb936183279c96c54b61f..1a22eee3a0371379823c70db890160590a973d5b 100644 (file)
@@ -56,7 +56,7 @@ pub fn expand_aggregate<'tcx>(
                 let offset = i as u32;
                 assert_eq!(offset as usize, i);
                 tcx.mk_place_elem(
-                    lhs.clone(),
+                    lhs,
                     ProjectionElem::ConstantIndex {
                         offset,
                         // FIXME(eddyb) `min_length` doesn't appear to be used.
@@ -66,7 +66,7 @@ pub fn expand_aggregate<'tcx>(
                 )
             } else {
                 let field = Field::new(active_field_index.unwrap_or(i));
-                tcx.mk_place_field(lhs.clone(), field, ty)
+                tcx.mk_place_field(lhs, field, ty)
             };
             Statement { source_info, kind: StatementKind::Assign(box (lhs_field, Rvalue::Use(op))) }
         })
index e3a96ca78967efb89137b6ea4b50d371e690682a..8286793b532309c404a19aa728dc04cc2f0a0f8b 100644 (file)
@@ -212,7 +212,7 @@ fn move_paths_for_fields(
                 assert_eq!(self.elaborator.param_env().reveal, Reveal::All);
                 let field_ty =
                     tcx.normalize_erasing_regions(self.elaborator.param_env(), f.ty(tcx, substs));
-                (tcx.mk_place_field(base_place.clone(), field, field_ty), subpath)
+                (tcx.mk_place_field(base_place, field, field_ty), subpath)
             })
             .collect()
     }
@@ -340,7 +340,7 @@ fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock {
             .enumerate()
             .map(|(i, &ty)| {
                 (
-                    self.tcx().mk_place_field(self.place.clone(), Field::new(i), ty),
+                    self.tcx().mk_place_field(self.place, Field::new(i), ty),
                     self.elaborator.field_subpath(self.path, Field::new(i)),
                 )
             })
@@ -353,7 +353,7 @@ fn open_drop_for_tuple(&mut self, tys: &[Ty<'tcx>]) -> BasicBlock {
     fn open_drop_for_box(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>) -> BasicBlock {
         debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs);
 
-        let interior = self.tcx().mk_place_deref(self.place.clone());
+        let interior = self.tcx().mk_place_deref(self.place);
         let interior_path = self.elaborator.deref_subpath(self.path);
 
         let succ = self.succ; // FIXME(#43234)
@@ -434,7 +434,7 @@ fn open_drop_for_multivariant(
 
             if let Some(variant_path) = subpath {
                 let base_place = tcx.mk_place_elem(
-                    self.place.clone(),
+                    self.place,
                     ProjectionElem::Downcast(Some(variant.ident.name), variant_index),
                 );
                 let fields = self.move_paths_for_fields(base_place, variant_path, &variant, substs);
@@ -622,7 +622,7 @@ fn drop_loop(
             (Rvalue::Use(copy(cur.into())), Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one))
         } else {
             (
-                Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place.clone(), cur)),
+                Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
                 Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one),
             )
         };
@@ -654,7 +654,7 @@ fn drop_loop(
         self.elaborator.patch().patch_terminator(
             drop_block,
             TerminatorKind::Drop {
-                location: tcx.mk_place_deref(ptr.clone()),
+                location: tcx.mk_place_deref(ptr),
                 target: loop_block,
                 unwind: unwind.into_option(),
             },
@@ -682,7 +682,7 @@ fn open_drop_for_array(&mut self, ety: Ty<'tcx>, opt_size: Option<u64>) -> Basic
                 .map(|i| {
                     (
                         tcx.mk_place_elem(
-                            self.place.clone(),
+                            self.place,
                             ProjectionElem::ConstantIndex {
                                 offset: i,
                                 min_length: size,
@@ -719,8 +719,8 @@ fn open_drop_for_array(&mut self, ety: Ty<'tcx>, opt_size: Option<u64>) -> Basic
                     switch_ty: tcx.types.usize,
                     values: From::from(USIZE_SWITCH_ZERO),
                     targets: vec![
-                        self.drop_loop_pair(ety, false, len.clone()),
-                        self.drop_loop_pair(ety, true, len.clone()),
+                        self.drop_loop_pair(ety, false, len),
+                        self.drop_loop_pair(ety, true, len),
                     ],
                 },
             }),
@@ -912,7 +912,7 @@ fn unelaborated_free_block(
             .map(|(i, f)| {
                 let field = Field::new(i);
                 let field_ty = f.ty(tcx, substs);
-                Operand::Move(tcx.mk_place_field(self.place.clone(), field, field_ty))
+                Operand::Move(tcx.mk_place_field(self.place, field, field_ty))
             })
             .collect();
 
index 4e8d5e04a63505d0269815e608e41acfe01ee466..3f94fb828903113866f465bf16b804ebfdabc862 100644 (file)
@@ -2,8 +2,8 @@
 use crate::build::ForGuard::OutsideGuard;
 use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
 use crate::hair::*;
-use rustc_middle::mir::*;
 use rustc_hir as hir;
+use rustc_middle::mir::*;
 use rustc_span::Span;
 
 impl<'a, 'tcx> Builder<'a, 'tcx> {
@@ -29,7 +29,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     // This is a `break`-able block
                     let exit_block = this.cfg.start_new_block();
                     let block_exit =
-                        this.in_breakable_scope(None, exit_block, destination.clone(), |this| {
+                        this.in_breakable_scope(None, exit_block, destination, |this| {
                             this.ast_block_stmts(destination, block, span, stmts, expr, safety_mode)
                         });
                     this.cfg.goto(unpack!(block_exit), source_info, exit_block);
index cd5bb738aedf8eb27e044187794a97eb7c8fd6da..093e5a8d6a28d81cb73d7a322447cf6c78ae9adc 100644 (file)
@@ -3,10 +3,10 @@
 use crate::build::expr::category::{Category, RvalueFunc};
 use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
 use crate::hair::*;
-use rustc_middle::mir::*;
-use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_hir as hir;
+use rustc_middle::mir::*;
+use rustc_middle::ty::{self, CanonicalUserTypeAnnotation};
 use rustc_span::symbol::sym;
 
 use rustc_target::spec::abi::Abi;
@@ -139,31 +139,26 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 // Start the loop.
                 this.cfg.goto(block, source_info, loop_block);
 
-                this.in_breakable_scope(
-                    Some(loop_block),
-                    exit_block,
-                    destination.clone(),
-                    move |this| {
-                        // conduct the test, if necessary
-                        let body_block = this.cfg.start_new_block();
-                        let diverge_cleanup = this.diverge_cleanup();
-                        this.cfg.terminate(
-                            loop_block,
-                            source_info,
-                            TerminatorKind::FalseUnwind {
-                                real_target: body_block,
-                                unwind: Some(diverge_cleanup),
-                            },
-                        );
-
-                        // The “return” value of the loop body must always be an unit. We therefore
-                        // introduce a unit temporary as the destination for the loop body.
-                        let tmp = this.get_unit_temp();
-                        // Execute the body, branching back to the test.
-                        let body_block_end = unpack!(this.into(tmp, body_block, body));
-                        this.cfg.goto(body_block_end, source_info, loop_block);
-                    },
-                );
+                this.in_breakable_scope(Some(loop_block), exit_block, destination, move |this| {
+                    // conduct the test, if necessary
+                    let body_block = this.cfg.start_new_block();
+                    let diverge_cleanup = this.diverge_cleanup();
+                    this.cfg.terminate(
+                        loop_block,
+                        source_info,
+                        TerminatorKind::FalseUnwind {
+                            real_target: body_block,
+                            unwind: Some(diverge_cleanup),
+                        },
+                    );
+
+                    // The “return” value of the loop body must always be an unit. We therefore
+                    // introduce a unit temporary as the destination for the loop body.
+                    let tmp = this.get_unit_temp();
+                    // Execute the body, branching back to the test.
+                    let body_block_end = unpack!(this.into(tmp, body_block, body));
+                    this.cfg.goto(body_block_end, source_info, loop_block);
+                });
                 exit_block.unit()
             }
             ExprKind::Call { ty, fun, args, from_hir_call } => {
@@ -278,26 +273,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
 
                 let field_names = this.hir.all_fields(adt_def, variant_index);
 
-                let fields =
-                    if let Some(FruInfo { base, field_types }) = base {
-                        let base = unpack!(block = this.as_place(block, base));
-
-                        // MIR does not natively support FRU, so for each
-                        // base-supplied field, generate an operand that
-                        // reads it from the base.
-                        field_names
-                            .into_iter()
-                            .zip(field_types.into_iter())
-                            .map(|(n, ty)| match fields_map.get(&n) {
-                                Some(v) => v.clone(),
-                                None => this.consume_by_copy_or_move(
-                                    this.hir.tcx().mk_place_field(base.clone(), n, ty),
-                                ),
-                            })
-                            .collect()
-                    } else {
-                        field_names.iter().filter_map(|n| fields_map.get(n).cloned()).collect()
-                    };
+                let fields = if let Some(FruInfo { base, field_types }) = base {
+                    let base = unpack!(block = this.as_place(block, base));
+
+                    // MIR does not natively support FRU, so for each
+                    // base-supplied field, generate an operand that
+                    // reads it from the base.
+                    field_names
+                        .into_iter()
+                        .zip(field_types.into_iter())
+                        .map(|(n, ty)| match fields_map.get(&n) {
+                            Some(v) => v.clone(),
+                            None => this.consume_by_copy_or_move(
+                                this.hir.tcx().mk_place_field(base, n, ty),
+                            ),
+                        })
+                        .collect()
+                } else {
+                    field_names.iter().filter_map(|n| fields_map.get(n).cloned()).collect()
+                };
 
                 let inferred_ty = expr.ty;
                 let user_ty = user_ty.map(|ty| {
index a4a9271669e4ea45869fb06bb23b795cbe49e8b9..10ffc81f179d1c8474e8fbe0e71e83c9567f2499 100644 (file)
@@ -1903,9 +1903,7 @@ fn bind_matched_candidate_for_arm_body<'b>(
                 self.schedule_drop_for_binding(binding.var_id, binding.span, OutsideGuard);
             }
             let rvalue = match binding.binding_mode {
-                BindingMode::ByValue => {
-                    Rvalue::Use(self.consume_by_copy_or_move(binding.source.clone()))
-                }
+                BindingMode::ByValue => Rvalue::Use(self.consume_by_copy_or_move(binding.source)),
                 BindingMode::ByRef(borrow_kind) => {
                     Rvalue::Ref(re_erased, borrow_kind, binding.source)
                 }
index 393af108a6e461983cdecd65607aa5558ab7c736..a97ddeb0600120ca676e1ee483ca87c379dfb56f 100644 (file)
@@ -15,11 +15,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         subpatterns
             .iter()
             .map(|fieldpat| {
-                let place = self.hir.tcx().mk_place_field(
-                    place.clone(),
-                    fieldpat.field,
-                    fieldpat.pattern.ty,
-                );
+                let place =
+                    self.hir.tcx().mk_place_field(place, fieldpat.field, fieldpat.pattern.ty);
                 MatchPair::new(place, &fieldpat.pattern)
             })
             .collect()
@@ -44,14 +41,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         match_pairs.extend(prefix.iter().enumerate().map(|(idx, subpattern)| {
             let elem =
                 ProjectionElem::ConstantIndex { offset: idx as u32, min_length, from_end: false };
-            let place = tcx.mk_place_elem(place.clone(), elem);
+            let place = tcx.mk_place_elem(*place, elem);
             MatchPair::new(place, subpattern)
         }));
 
         if let Some(subslice_pat) = opt_slice {
             let suffix_len = suffix.len() as u32;
             let subslice = tcx.mk_place_elem(
-                place.clone(),
+                *place,
                 ProjectionElem::Subslice {
                     from: prefix.len() as u32,
                     to: if exact_size { min_length - suffix_len } else { suffix_len },
@@ -68,7 +65,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                 min_length,
                 from_end: !exact_size,
             };
-            let place = tcx.mk_place_elem(place.clone(), elem);
+            let place = tcx.mk_place_elem(*place, elem);
             MatchPair::new(place, subpattern)
         }));
     }
index ad81aa306857b121ac28922b2e4c4387b3ca7990..2e48fd9d659bdeafa7655f6022c286a48e01f4ba 100644 (file)
@@ -610,7 +610,7 @@ pub fn check_unused_or_stable_features(tcx: TyCtxt<'_>) {
             // Warn if the user enables a lib feature multiple times.
             duplicate_feature_err(tcx.sess, *span, *feature);
         }
-        remaining_lib_features.insert(feature, span.clone());
+        remaining_lib_features.insert(feature, *span);
     }
     // `stdbuild` has special handling for `libc`, so we need to
     // recognise the feature when building std.
index 4a4283b2a0cbbd05f8083fdb4ba5e038db37019b..fb313d2658ff40d1748d4e7df6c1da8360f853ec 100644 (file)
@@ -15,7 +15,7 @@ pub fn new(nodes: &[DepNode<K>], edges: &[(DepNode<K>, DepNode<K>)]) -> DepGraph
         let mut graph = Graph::with_capacity(nodes.len(), edges.len());
         let mut indices = FxHashMap::default();
         for node in nodes {
-            indices.insert(node.clone(), graph.add_node(node.clone()));
+            indices.insert(*node, graph.add_node(*node));
         }
 
         for &(ref source, ref target) in edges {
index 5bfb5aa2440b731e6ec4bcee67371944266ca781..5b6a50f88db45ac410a2d9b7f3a7f63df4b85627 100644 (file)
@@ -643,13 +643,13 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
                                 if param_name.name == kw::UnderscoreLifetime {
                                     // Pick the elided lifetime "definition" if one exists
                                     // and use it to make an elision scope.
-                                    self.lifetime_uses.insert(def_id.clone(), LifetimeUseSet::Many);
+                                    self.lifetime_uses.insert(def_id, LifetimeUseSet::Many);
                                     elision = Some(reg);
                                 } else {
                                     lifetimes.insert(name, reg);
                                 }
                             } else {
-                                self.lifetime_uses.insert(def_id.clone(), LifetimeUseSet::Many);
+                                self.lifetime_uses.insert(def_id, LifetimeUseSet::Many);
                                 lifetimes.insert(name, reg);
                             }
                         }
index 0f527419d03174b694782e36433aa8a3ce0ca161..adc16d77790e419d6ad4babec713634b3cf64779 100644 (file)
@@ -126,7 +126,7 @@ struct ErrorDescriptor<'tcx> {
                 .borrow_mut()
                 .entry(span)
                 .or_default()
-                .push(error.obligation.predicate.clone());
+                .push(error.obligation.predicate);
         }
 
         // We do this in 2 passes because we want to display errors in order, though
index 49a4b96f8b7a1ca9563630214548b0899dd51992..300acf95c9973ab5f21a18536122d7705a97a5a9 100644 (file)
@@ -314,7 +314,7 @@ fn process_obligation(
 
         match obligation.predicate {
             ty::Predicate::Trait(ref data, _) => {
-                let trait_obligation = obligation.with(data.clone());
+                let trait_obligation = obligation.with(*data);
 
                 if data.is_global() {
                     // no type variables present, can use evaluation for better caching.
@@ -420,7 +420,7 @@ fn process_obligation(
             }
 
             ty::Predicate::Projection(ref data) => {
-                let project_obligation = obligation.with(data.clone());
+                let project_obligation = obligation.with(*data);
                 match project::poly_project_and_unify_type(self.selcx, &project_obligation) {
                     Ok(None) => {
                         let tcx = self.selcx.tcx();
index 0a85999c60da75fd77c27ff0900bd38fb7626078..41847a9218ca6a524eceecf597bbec7ef1c7b739 100644 (file)
@@ -413,7 +413,7 @@ fn evaluate_predicate_recursively<'o>(
         match obligation.predicate {
             ty::Predicate::Trait(ref t, _) => {
                 debug_assert!(!t.has_escaping_bound_vars());
-                let obligation = obligation.with(t.clone());
+                let obligation = obligation.with(*t);
                 self.evaluate_trait_predicate_recursively(previous_stack, obligation)
             }
 
@@ -460,7 +460,7 @@ fn evaluate_predicate_recursively<'o>(
             }
 
             ty::Predicate::Projection(ref data) => {
-                let project_obligation = obligation.with(data.clone());
+                let project_obligation = obligation.with(*data);
                 match project::poly_project_and_unify_type(self, &project_obligation) {
                     Ok(Some(mut subobligations)) => {
                         self.add_depth(subobligations.iter_mut(), obligation.recursion_depth);
@@ -910,7 +910,7 @@ fn candidate_from_obligation<'o>(
         // separately rather than using `stack.fresh_trait_ref` --
         // this is because we want the unbound variables to be
         // replaced with fresh types starting from index 0.
-        let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate.clone());
+        let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate);
         debug!(
             "candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})",
             cache_fresh_trait_pred, stack
@@ -1448,8 +1448,8 @@ fn match_projection_obligation_against_definition_bounds(
             self.infcx.probe(|_| {
                 self.match_projection(
                     obligation,
-                    bound.clone(),
-                    placeholder_trait_predicate.trait_ref.clone(),
+                    *bound,
+                    placeholder_trait_predicate.trait_ref,
                     &placeholder_map,
                     snapshot,
                 )
@@ -1468,7 +1468,7 @@ fn match_projection_obligation_against_definition_bounds(
                 let result = self.match_projection(
                     obligation,
                     bound,
-                    placeholder_trait_predicate.trait_ref.clone(),
+                    placeholder_trait_predicate.trait_ref,
                     &placeholder_map,
                     snapshot,
                 );
@@ -1520,7 +1520,7 @@ fn assemble_candidates_from_caller_bounds<'o>(
         // Keep only those bounds which may apply, and propagate overflow if it occurs.
         let mut param_candidates = vec![];
         for bound in matching_bounds {
-            let wc = self.evaluate_where_clause(stack, bound.clone())?;
+            let wc = self.evaluate_where_clause(stack, bound)?;
             if wc.may_apply() {
                 param_candidates.push(ParamCandidate(bound));
             }
@@ -2496,7 +2496,7 @@ fn confirm_param_candidate(
         // where-clause trait-ref could be unified with the obligation
         // trait-ref. Repeat that unification now without any
         // transactional boundary; it should not fail.
-        match self.match_where_clause_trait_ref(obligation, param.clone()) {
+        match self.match_where_clause_trait_ref(obligation, param) {
             Ok(obligations) => obligations,
             Err(()) => {
                 bug!(
index f9100300e3add1043fbee8964fd47838b8a78c70..31d147b460f0ca83114a7b878f5d5d8f9443750f 100644 (file)
@@ -373,7 +373,7 @@ fn visit_user_provided_tys(&mut self) {
                 );
             };
 
-            self.tables.user_provided_types_mut().insert(hir_id, c_ty.clone());
+            self.tables.user_provided_types_mut().insert(hir_id, *c_ty);
 
             if let ty::UserType::TypeOf(_, user_substs) = c_ty.value {
                 if self.rustc_dump_user_substs {
@@ -411,7 +411,7 @@ fn visit_user_provided_sigs(&mut self) {
                 );
             };
 
-            self.tables.user_provided_sigs.insert(def_id, c_sig.clone());
+            self.tables.user_provided_sigs.insert(def_id, *c_sig);
         }
     }
 
@@ -562,7 +562,7 @@ fn visit_liberated_fn_sigs(&mut self) {
         for (&local_id, fn_sig) in fcx_tables.liberated_fn_sigs().iter() {
             let hir_id = hir::HirId { owner: common_hir_owner, local_id };
             let fn_sig = self.resolve(fn_sig, &hir_id);
-            self.tables.liberated_fn_sigs_mut().insert(hir_id, fn_sig.clone());
+            self.tables.liberated_fn_sigs_mut().insert(hir_id, fn_sig);
         }
     }
 
index eb8aec708a63993bc284b491e0b43dda6fdee84f..144c1699a3ca86edc3b9ee1fd183efb004acd0b7 100644 (file)
@@ -509,7 +509,7 @@ fn param_env_to_generics(
                         continue;
                     }
 
-                    let mut for_generics = self.extract_for_generics(tcx, orig_p.clone());
+                    let mut for_generics = self.extract_for_generics(tcx, orig_p);
 
                     assert!(bounds.len() == 1);
                     let mut b = bounds.pop().expect("bounds were empty");
index a82015dea5fc8daf465c7645877b705f60a5a387..e9af0ee5c2343d2c15d85fcf014566ead74c73e7 100644 (file)
@@ -47,7 +47,7 @@ pub fn try_inline(
     }
     let mut ret = Vec::new();
 
-    let attrs_clone = attrs.clone();
+    let attrs_clone = attrs;
 
     let inner = match res {
         Res::Def(DefKind::Trait, did) => {
@@ -292,7 +292,7 @@ pub fn build_impls(cx: &DocContext<'_>, did: DefId, attrs: Option<Attrs<'_>>) ->
     let mut impls = Vec::new();
 
     for &did in tcx.inherent_impls(did).iter() {
-        build_impl(cx, did, attrs.clone(), &mut impls);
+        build_impl(cx, did, attrs, &mut impls);
     }
 
     impls
index fbbe172afb81f2abded48c31bf56b96899641f6a..afc1501d7b6134641ebe780e2ff6468844a71fe0 100644 (file)
@@ -683,7 +683,7 @@ fn add_test(&mut self, test: String, config: LangString, line: usize) {
         let name = self.generate_name(line, &filename);
         let cratename = self.cratename.to_string();
         let opts = self.opts.clone();
-        let edition = config.edition.unwrap_or(self.options.edition.clone());
+        let edition = config.edition.unwrap_or(self.options.edition);
         let options = self.options.clone();
         let runtool = self.options.runtool.clone();
         let runtool_args = self.options.runtool_args.clone();