diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index df265bf0147b6..265e45635cf53 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -19,7 +19,7 @@ fn const_vars_since_snapshot<'tcx>( ( range.start..range.end, (range.start.index..range.end.index) - .map(|index| table.probe_value(ConstVid::from_index(index)).origin.clone()) + .map(|index| table.probe_value(ConstVid::from_index(index)).origin) .collect(), ) } diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index 18c25ef0dd9e1..4b1f8a5be14f3 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -611,7 +611,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { errors.push(RegionResolutionError::GenericBoundFailure( verify.origin.clone(), - verify.kind.clone(), + verify.kind, sub, )); } @@ -761,7 +761,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> { for upper_bound in &upper_bounds { if !self.region_rels.is_subregion_of(effective_lower_bound, upper_bound.region) { - let origin = self.var_infos[node_idx].origin.clone(); + let origin = self.var_infos[node_idx].origin; debug!( "region inference error at {:?} for {:?}: SubSupConflict sub: {:?} \ sup: {:?}", diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index f218bf1134f7f..27ed3c7813892 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -832,7 +832,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { ( range.clone(), (range.start.index()..range.end.index()) - .map(|index| self.var_infos[ty::RegionVid::from(index)].origin.clone()) + .map(|index| self.var_infos[ty::RegionVid::from(index)].origin) .collect(), ) } diff --git a/src/librustc/infer/type_variable.rs b/src/librustc/infer/type_variable.rs index 089c6dd723bce..8ea1b705d443d 100644 --- a/src/librustc/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -306,7 +306,7 @@ impl<'tcx> TypeVariableTable<'tcx> { ( range.start.vid..range.end.vid, (range.start.vid.index..range.end.vid.index) - .map(|index| self.values.get(index as usize).origin.clone()) + .map(|index| self.values.get(index as usize).origin) .collect(), ) } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 3a7c650c4618c..c9a89aae86fd8 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1988,7 +1988,7 @@ impl<'tcx> Operand<'tcx> { pub fn to_copy(&self) -> Self { match *self { Operand::Copy(_) | Operand::Constant(_) => self.clone(), - Operand::Move(ref place) => Operand::Copy(place.clone()), + Operand::Move(place) => Operand::Copy(place), } } } @@ -2462,11 +2462,15 @@ impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection { let projs: Vec<_> = self .projs .iter() - .map(|elem| match elem { + .map(|&elem| match elem { Deref => Deref, - Field(f, ()) => Field(f.clone(), ()), + Field(f, ()) => Field(f, ()), Index(()) => Index(()), - elem => elem.clone(), + Downcast(symbol, variantidx) => Downcast(symbol, variantidx), + ConstantIndex { offset, min_length, from_end } => { + ConstantIndex { offset, min_length, from_end } + } + Subslice { from, to, from_end } => Subslice { from, to, from_end }, }) .collect(); @@ -2862,11 +2866,15 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> { fn super_fold_with>(&self, folder: &mut F) -> Self { use crate::mir::ProjectionElem::*; - match self { + match *self { Deref => Deref, - Field(f, ty) => Field(*f, ty.fold_with(folder)), + Field(f, ty) => Field(f, ty.fold_with(folder)), Index(v) => Index(v.fold_with(folder)), - elem => elem.clone(), + Downcast(symbol, variantidx) => Downcast(symbol, variantidx), + ConstantIndex { offset, min_length, from_end } => { + ConstantIndex { offset, min_length, from_end } + } + Subslice { from, to, from_end } => Subslice { from, to, from_end }, } } @@ -2911,7 +2919,7 @@ impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix { impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> { fn super_fold_with>(&self, folder: &mut F) -> Self { Constant { - span: self.span.clone(), + span: self.span, user_ty: self.user_ty.fold_with(folder), literal: self.literal.fold_with(folder), } diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 475c77adebd10..d19732664635f 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> { } pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode { - DepNode::new(tcx, DepConstructor::CompileCodegenUnit(self.name().clone())) + DepNode::new(tcx, DepConstructor::CompileCodegenUnit(self.name())) } } diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index c97c5c2077f85..fdb6432f7c9e1 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -535,7 +535,7 @@ impl AutoTraitFinder<'tcx> { } 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/librustc/traits/error_reporting/mod.rs b/src/librustc/traits/error_reporting/mod.rs index cdb50779e00cc..28084c9d4ac49 100644 --- a/src/librustc/traits/error_reporting/mod.rs +++ b/src/librustc/traits/error_reporting/mod.rs @@ -54,10 +54,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { span, predicates .iter() - .map(|predicate| ErrorDescriptor { - predicate: predicate.clone(), - index: None, - }) + .map(|&predicate| ErrorDescriptor { predicate, index: None }) .collect(), ) }) @@ -73,7 +70,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } error_map.entry(span).or_default().push(ErrorDescriptor { - predicate: error.obligation.predicate.clone(), + predicate: error.obligation.predicate, index: Some(index), }); @@ -137,7 +134,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } }; - for implication in super::elaborate_predicates(self.tcx, vec![cond.clone()]) { + for implication in super::elaborate_predicates(self.tcx, vec![*cond]) { if let ty::Predicate::Trait(implication, _) = implication { let error = error.to_poly_trait_ref(); let implication = implication.to_poly_trait_ref(); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 62672a7810480..3085837335abe 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -377,7 +377,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> { let normalized_ty = normalize_projection_type( self.selcx, self.param_env, - data.clone(), + *data, self.cause.clone(), self.depth, &mut self.obligations, @@ -433,7 +433,7 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>( opt_normalize_projection_type( selcx, param_env, - projection_ty.clone(), + projection_ty, cause.clone(), depth, obligations, diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index ac1ca4db9d6bb..ba0a270638cd1 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -2068,7 +2068,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } - _ => candidates.vec.push(AutoImplCandidate(def_id.clone())), + _ => candidates.vec.push(AutoImplCandidate(def_id)), } } @@ -2132,10 +2132,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // but `Foo` is declared as `trait Foo: Bar`. let upcast_trait_refs = util::supertraits(self.tcx(), poly_trait_ref) .filter(|upcast_trait_ref| { - self.infcx.probe(|_| { - let upcast_trait_ref = upcast_trait_ref.clone(); - self.match_poly_trait_ref(obligation, upcast_trait_ref).is_ok() - }) + self.infcx + .probe(|_| self.match_poly_trait_ref(obligation, *upcast_trait_ref).is_ok()) }) .count(); @@ -2243,7 +2241,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let def_id = obligation.predicate.def_id(); if self.tcx().is_trait_alias(def_id) { - candidates.vec.push(TraitAliasCandidate(def_id.clone())); + candidates.vec.push(TraitAliasCandidate(def_id)); } Ok(()) @@ -3249,7 +3247,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation_trait_ref: ty::PolyTraitRef<'tcx>, expected_trait_ref: ty::PolyTraitRef<'tcx>, ) -> Result>, SelectionError<'tcx>> { - let obligation_trait_ref = obligation_trait_ref.clone(); self.infcx .at(&obligation_cause, obligation_param_env) .sup(obligation_trait_ref, expected_trait_ref) diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index f3bd98b855190..ae1a5e3efa2a7 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -526,11 +526,11 @@ pub fn predicates_for_generics<'tcx>( generic_bounds .predicates .iter() - .map(|predicate| Obligation { + .map(|&predicate| Obligation { cause: cause.clone(), recursion_depth, param_env, - predicate: predicate.clone(), + predicate, }) .collect() } diff --git a/src/librustc/traits/wf.rs b/src/librustc/traits/wf.rs index a0cb8446c9217..9fa3c87477951 100644 --- a/src/librustc/traits/wf.rs +++ b/src/librustc/traits/wf.rs @@ -318,8 +318,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { if let Elaborate::All = elaborate { let trait_assoc_items = tcx.associated_items(trait_ref.def_id); - let predicates = - obligations.iter().map(|obligation| obligation.predicate.clone()).collect(); + let predicates = obligations.iter().map(|obligation| obligation.predicate).collect(); let implied_obligations = traits::elaborate_predicates(tcx, predicates); let implied_obligations = implied_obligations.map(|pred| { let mut cause = cause.clone(); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index a51f0f7f24c36..355df86046f43 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1294,7 +1294,7 @@ impl<'tcx> TyCtxt<'tcx> { // statements within the query system and we'd run into endless // recursion otherwise. let (crate_name, crate_disambiguator) = if def_id.is_local() { - (self.crate_name.clone(), self.sess.local_crate_disambiguator()) + (self.crate_name, self.sess.local_crate_disambiguator()) } else { ( self.cstore.crate_name_untracked(def_id.krate), diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index e67131b916413..4889f751f601b 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1326,7 +1326,7 @@ pub trait ToPolyTraitRef<'tcx> { impl<'tcx> ToPolyTraitRef<'tcx> for TraitRef<'tcx> { fn to_poly_trait_ref(&self) -> PolyTraitRef<'tcx> { - ty::Binder::dummy(self.clone()) + ty::Binder::dummy(*self) } } @@ -1372,19 +1372,19 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&PolyTraitRef<'tcx>> { impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> { fn to_predicate(&self) -> Predicate<'tcx> { - Predicate::RegionOutlives(self.clone()) + Predicate::RegionOutlives(*self) } } impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> { fn to_predicate(&self) -> Predicate<'tcx> { - Predicate::TypeOutlives(self.clone()) + Predicate::TypeOutlives(*self) } } impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> { fn to_predicate(&self) -> Predicate<'tcx> { - Predicate::Projection(self.clone()) + Predicate::Projection(*self) } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 837b2fcc50068..dffe86d946212 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -838,7 +838,7 @@ impl<'tcx> PolyTraitRef<'tcx> { pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> { // Note that we preserve binding levels - Binder(ty::TraitPredicate { trait_ref: self.skip_binder().clone() }) + Binder(ty::TraitPredicate { trait_ref: *self.skip_binder() }) } } diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index 3f4e24ca993db..a9298abe2d759 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -708,7 +708,7 @@ impl<'a, 'b> Context<'a, 'b> { // Before consuming the expressions, we have to remember spans for // count arguments as they are now generated separate from other // arguments, hence have no access to the `P`'s. - let spans_pos: Vec<_> = self.args.iter().map(|e| e.span.clone()).collect(); + let spans_pos: Vec<_> = self.args.iter().map(|e| e.span).collect(); // Right now there is a bug such that for the expression: // foo(bar(&1)) diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index f9e23e96fa8a8..bf660d188b287 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -400,7 +400,7 @@ pub trait Emitter { } if sm.span_to_filename(sp_label.span.clone()).is_macros() && !always_backtrace { if let Some(use_site) = sp_label.span.macro_backtrace().last() { - before_after.push((sp_label.span.clone(), use_site.call_site.clone())); + before_after.push((sp_label.span, use_site.call_site)); } } } @@ -1184,13 +1184,13 @@ impl EmitterWriter { let level_str = level.to_string(); // The failure note level itself does not provide any useful diagnostic information if *level != Level::FailureNote && !level_str.is_empty() { - buffer.append(0, &level_str, Style::Level(level.clone())); + buffer.append(0, &level_str, Style::Level(*level)); } // only render error codes, not lint codes if let Some(DiagnosticId::Error(ref code)) = *code { - buffer.append(0, "[", Style::Level(level.clone())); - buffer.append(0, &code, Style::Level(level.clone())); - buffer.append(0, "]", Style::Level(level.clone())); + buffer.append(0, "[", Style::Level(*level)); + buffer.append(0, &code, Style::Level(*level)); + buffer.append(0, "]", Style::Level(*level)); } if *level != Level::FailureNote && !level_str.is_empty() { buffer.append(0, ": ", header_style); @@ -1495,7 +1495,7 @@ impl EmitterWriter { // Render the suggestion message let level_str = level.to_string(); if !level_str.is_empty() { - buffer.append(0, &level_str, Style::Level(level.clone())); + buffer.append(0, &level_str, Style::Level(*level)); buffer.append(0, ": ", Style::HeaderMsg); } self.msg_to_buffer( diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs index 08333ae423da7..521657ea49ca8 100644 --- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs @@ -691,7 +691,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection); if self.access_place_error_reported.contains(&( - Place { local: root_place.local.clone(), projection: root_place_projection }, + Place { local: *root_place.local, projection: root_place_projection }, borrow_span, )) { debug!( @@ -702,7 +702,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { } self.access_place_error_reported.insert(( - Place { local: root_place.local.clone(), projection: root_place_projection }, + Place { local: *root_place.local, projection: root_place_projection }, borrow_span, )); diff --git a/src/librustc_mir/borrow_check/diagnostics/move_errors.rs b/src/librustc_mir/borrow_check/diagnostics/move_errors.rs index 43121b38da01a..c3ad6834dc890 100644 --- a/src/librustc_mir/borrow_check/diagnostics/move_errors.rs +++ b/src/librustc_mir/borrow_check/diagnostics/move_errors.rs @@ -178,7 +178,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { }; grouped_errors.push(GroupedMoveError::MovesFromPlace { span, - move_from: match_place.clone(), + move_from: *match_place, original_path, kind, binds_to, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 90927069242b1..3bfe510a72b71 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -883,7 +883,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // Check is_empty() first because it's the common case, and doing that // way we avoid the clone() call. if !self.access_place_error_reported.is_empty() - && self.access_place_error_reported.contains(&(place_span.0.clone(), place_span.1)) + && self.access_place_error_reported.contains(&(*place_span.0, place_span.1)) { debug!( "access_place: suppressing error place_span=`{:?}` kind=`{:?}`", @@ -911,7 +911,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if conflict_error || mutability_error { debug!("access_place: logging error place_span=`{:?}` kind=`{:?}`", place_span, kind); - self.access_place_error_reported.insert((place_span.0.clone(), place_span.1)); + self.access_place_error_reported.insert((*place_span.0, place_span.1)); } } @@ -1011,10 +1011,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { // the 2018 edition so we emit it as a warning. We buffer // these sepately so that we only emit a warning if borrow // checking was otherwise successful. - this.reservation_warnings.insert( - bi, - (place_span.0.clone(), place_span.1, location, bk, borrow.clone()), - ); + this.reservation_warnings + .insert(bi, (*place_span.0, place_span.1, location, bk, borrow.clone())); // Don't suppress actual errors. Control::Continue diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index 442baf85f2baf..428db8356b122 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -226,7 +226,7 @@ pub fn const_eval_validated_provider<'tcx>( ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { // see comment in const_eval_raw_provider for what we're doing here if key.param_env.reveal == Reveal::All { - let mut key = key.clone(); + let mut key = key; key.param_env.reveal = Reveal::UserFacing; match tcx.const_eval_validated(key) { // try again with reveal all as requested @@ -267,7 +267,7 @@ pub fn const_eval_raw_provider<'tcx>( // In case we fail in the `UserFacing` variant, we just do the real computation. if key.param_env.reveal == Reveal::All { - let mut key = key.clone(); + let mut key = key; key.param_env.reveal = Reveal::UserFacing; match tcx.const_eval_raw(key) { // try again with reveal all as requested diff --git a/src/librustc_mir/dataflow/move_paths/abs_domain.rs b/src/librustc_mir/dataflow/move_paths/abs_domain.rs index 0665c0fb72c46..0ecf22ae23361 100644 --- a/src/librustc_mir/dataflow/move_paths/abs_domain.rs +++ b/src/librustc_mir/dataflow/move_paths/abs_domain.rs @@ -47,7 +47,7 @@ impl<'tcx> Lift for PlaceElem<'tcx> { fn lift(&self) -> Self::Abstract { match *self { ProjectionElem::Deref => ProjectionElem::Deref, - ProjectionElem::Field(ref f, ty) => ProjectionElem::Field(f.clone(), ty.lift()), + ProjectionElem::Field(f, ty) => ProjectionElem::Field(f, ty.lift()), ProjectionElem::Index(ref i) => ProjectionElem::Index(i.lift()), ProjectionElem::Subslice { from, to, from_end } => { ProjectionElem::Subslice { from, to, from_end } @@ -55,7 +55,7 @@ impl<'tcx> Lift for PlaceElem<'tcx> { ProjectionElem::ConstantIndex { offset, min_length, from_end } => { ProjectionElem::ConstantIndex { offset, min_length, from_end } } - ProjectionElem::Downcast(a, u) => ProjectionElem::Downcast(a, u.clone()), + ProjectionElem::Downcast(a, u) => ProjectionElem::Downcast(a, u), } } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 271bcce6ca53c..adba38d2a816a 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -158,7 +158,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { if union_path.is_none() { base = self.add_move_path(base, elem, |tcx| Place { - local: place.local.clone(), + local: place.local, projection: tcx.intern_place_elems(&place.projection[..i + 1]), }); } @@ -430,10 +430,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { // Split `Subslice` patterns into the corresponding list of // `ConstIndex` patterns. This is done to ensure that all move paths // are disjoint, which is expected by drop elaboration. - let base_place = Place { - local: place.local.clone(), - projection: self.builder.tcx.intern_place_elems(base), - }; + let base_place = + Place { local: place.local, projection: self.builder.tcx.intern_place_elems(base) }; let base_path = match self.move_path_for(&base_place) { Ok(path) => path, Err(MoveError::UnionMove { path }) => { @@ -467,7 +465,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { match self.move_path_for(place) { Ok(path) | Err(MoveError::UnionMove { path }) => self.record_move(place, path), Err(error @ MoveError::IllegalMove { .. }) => { - self.builder.errors.push((place.clone(), error)); + self.builder.errors.push((*place, error)); } }; } diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index 8bcf420e2aa37..de45808a4816c 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -740,18 +740,15 @@ fn compute_codegen_unit_name( let cgu_def_id = cgu_def_id.unwrap(); - cache - .entry((cgu_def_id, volatile)) - .or_insert_with(|| { - let def_path = tcx.def_path(cgu_def_id); + *cache.entry((cgu_def_id, volatile)).or_insert_with(|| { + let def_path = tcx.def_path(cgu_def_id); - let components = def_path.data.iter().map(|part| part.data.as_symbol()); + let components = def_path.data.iter().map(|part| part.data.as_symbol()); - let volatile_suffix = volatile.then_some("volatile"); + let volatile_suffix = volatile.then_some("volatile"); - name_builder.build_cgu_name(def_path.krate, components, volatile_suffix) - }) - .clone() + name_builder.build_cgu_name(def_path.krate, components, volatile_suffix) + }) } fn numbered_codegen_unit_name( diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index b84616142cb07..94a5f2b3bf86d 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -207,7 +207,7 @@ fn build_drop_shim<'tcx>( 0, Statement { source_info, - kind: StatementKind::Retag(RetagKind::Raw, box (dropee_ptr.clone())), + kind: StatementKind::Retag(RetagKind::Raw, box (dropee_ptr)), }, ); } @@ -445,7 +445,7 @@ impl CloneShimBuilder<'tcx> { // `let ref_loc: &ty = &src;` let statement = self.make_statement(StatementKind::Assign(box ( - ref_loc.clone(), + ref_loc, Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src), ))); @@ -475,7 +475,7 @@ impl CloneShimBuilder<'tcx> { let cond = self.make_place(Mutability::Mut, tcx.types.bool); let compute_cond = self.make_statement(StatementKind::Assign(box ( - cond.clone(), + cond, Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)), ))); @@ -512,7 +512,7 @@ impl CloneShimBuilder<'tcx> { Rvalue::Use(Operand::Constant(self.make_usize(0))), ))), self.make_statement(StatementKind::Assign(box ( - end.clone(), + end, Rvalue::Use(Operand::Constant(self.make_usize(len))), ))), ]; diff --git a/src/librustc_mir/transform/add_moves_for_packed_drops.rs b/src/librustc_mir/transform/add_moves_for_packed_drops.rs index 33eafeca5b17e..38db9e5195937 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -108,7 +108,7 @@ fn add_move_for_packed_drop<'tcx>( }); patch.add_statement(loc, StatementKind::StorageLive(temp)); - patch.add_assign(loc, Place::from(temp), Rvalue::Use(Operand::Move(location.clone()))); + patch.add_assign(loc, Place::from(temp), Rvalue::Use(Operand::Move(*location))); patch.patch_terminator( loc.block, TerminatorKind::Drop { location: Place::from(temp), target: storage_dead_block, unwind }, diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index d7ab3ea517b5f..a5b467c1e101f 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -108,7 +108,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag { if needs_retag(&destination.0) { returns.push(( block_data.terminator().source_info, - destination.0.clone(), + destination.0, destination.1, )); } @@ -141,8 +141,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag { for i in (0..block_data.statements.len()).rev() { let (retag_kind, place) = match block_data.statements[i].kind { // Retag-as-raw after escaping to a raw pointer. - StatementKind::Assign(box (ref place, Rvalue::AddressOf(..))) => { - (RetagKind::Raw, place.clone()) + StatementKind::Assign(box (place, Rvalue::AddressOf(..))) => { + (RetagKind::Raw, place) } // Assignments of reference or ptr type are the ones where we may have // to update tags. This includes `x = &[mut] ...` and hence @@ -156,7 +156,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag { } _ => RetagKind::Default, }; - (kind, place.clone()) + (kind, *place) } // Do nothing for the rest _ => continue, diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index 59d370abc71c5..73bd6c1c6c242 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -348,7 +348,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { // `unsafe` blocks are required in safe code Safety::Safe => { for violation in violations { - let mut violation = violation.clone(); + let mut violation = *violation; match violation.kind { UnsafetyViolationKind::GeneralAndConstFn | UnsafetyViolationKind::General => {} @@ -383,7 +383,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { // these things are forbidden in const fns UnsafetyViolationKind::General | UnsafetyViolationKind::BorrowPacked(_) => { - let mut violation = violation.clone(); + let mut violation = *violation; // const fns don't need to be backwards compatible and can // emit these violations as a hard error instead of a backwards // compat lint diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index b9d9ed592fc72..1c0b1b8c13767 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -459,7 +459,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported"); let assign = Statement { - kind: StatementKind::Assign(box (location.clone(), Rvalue::Use(value.clone()))), + kind: StatementKind::Assign(box (*location, Rvalue::Use(value.clone()))), source_info: terminator.source_info, }; @@ -512,11 +512,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent); self.patch.patch_terminator( bb, - TerminatorKind::Drop { - location: location.clone(), - target, - unwind: Some(unwind), - }, + TerminatorKind::Drop { location: *location, target, unwind: Some(unwind) }, ); } } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 8ac7772ea4818..1c86d6f3f65f2 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -260,7 +260,7 @@ impl TransformVisitor<'tcx> { let self_place = Place::from(self_arg()); let assign = Statement { source_info: source_info(body), - kind: StatementKind::Assign(box (temp.clone(), Rvalue::Discriminant(self_place))), + kind: StatementKind::Assign(box (temp, Rvalue::Discriminant(self_place))), }; (assign, temp) } diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 2dd00fe2fee19..96cd8fc135441 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -354,7 +354,7 @@ impl Inliner<'tcx> { let ty = v.ty.subst(tcx, callsite.substs); // Cost of the var is the size in machine-words, if we know // it. - if let Some(size) = type_size_of(tcx, param_env.clone(), ty) { + if let Some(size) = type_size_of(tcx, param_env, ty) { cost += (size / ptr_size) as usize; } else { cost += UNKNOWN_SIZE_COST; @@ -450,7 +450,7 @@ impl Inliner<'tcx> { let stmt = Statement { source_info: callsite.location, - kind: StatementKind::Assign(box (tmp.clone(), dest)), + kind: StatementKind::Assign(box (tmp, dest)), }; caller_body[callsite.bb].statements.push(stmt); self.tcx.mk_place_deref(tmp) diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index afe42e6357128..48b4d00a2e9b6 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -51,7 +51,7 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> { let new_place = match rvalue { Rvalue::Ref(_, _, place) => { if let &[ref proj_l @ .., proj_r] = place.projection.as_ref() { - place.projection = self.tcx().intern_place_elems(&[proj_r.clone()]); + place.projection = self.tcx().intern_place_elems(&[proj_r]); Place { // Replace with dummy diff --git a/src/librustc_mir/util/aggregate.rs b/src/librustc_mir/util/aggregate.rs index 28c1c52841172..be515ef571368 100644 --- a/src/librustc_mir/util/aggregate.rs +++ b/src/librustc_mir/util/aggregate.rs @@ -24,10 +24,7 @@ pub fn expand_aggregate<'tcx>( AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => { if adt_def.is_enum() { set_discriminant = Some(Statement { - kind: StatementKind::SetDiscriminant { - place: box (lhs.clone()), - variant_index, - }, + kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index }, source_info, }); lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index); @@ -39,7 +36,7 @@ pub fn expand_aggregate<'tcx>( // variant 0 (Unresumed). let variant_index = VariantIdx::new(0); set_discriminant = Some(Statement { - kind: StatementKind::SetDiscriminant { place: box (lhs.clone()), variant_index }, + kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index }, source_info, }); diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index aacefeb75136e..1be3da4b3d85a 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -168,7 +168,7 @@ where self.elaborator.patch().patch_terminator( bb, TerminatorKind::Drop { - location: self.place.clone(), + location: *self.place, target: self.succ, unwind: self.unwind.into_option(), }, @@ -517,7 +517,7 @@ where // way lies only trouble. let discr_ty = adt.repr.discr_type().to_ty(self.tcx()); let discr = Place::from(self.new_temp(discr_ty)); - let discr_rv = Rvalue::Discriminant(self.place.clone()); + let discr_rv = Rvalue::Discriminant(*self.place); let switch_block = BasicBlockData { statements: vec![self.assign(&discr, discr_rv)], terminator: Some(Terminator { @@ -554,7 +554,7 @@ where Rvalue::Ref( tcx.lifetimes.re_erased, BorrowKind::Mut { allow_two_phase_borrow: false }, - self.place.clone(), + *self.place, ), )], terminator: Some(Terminator { @@ -634,7 +634,7 @@ where let loop_block = BasicBlockData { statements: vec![self.assign( &can_go, - Rvalue::BinaryOp(BinOp::Eq, copy(Place::from(cur)), copy(length_or_end.clone())), + Rvalue::BinaryOp(BinOp::Eq, copy(Place::from(cur)), copy(*length_or_end)), )], is_cleanup: unwind.is_cleanup(), terminator: Some(Terminator { @@ -693,7 +693,7 @@ where } } - let move_ = |place: &Place<'tcx>| Operand::Move(place.clone()); + let move_ = |place: &Place<'tcx>| Operand::Move(*place); let elem_size = &Place::from(self.new_temp(tcx.types.usize)); let len = &Place::from(self.new_temp(tcx.types.usize)); @@ -702,7 +702,7 @@ where let base_block = BasicBlockData { statements: vec![ self.assign(elem_size, Rvalue::NullaryOp(NullOp::SizeOf, ety)), - self.assign(len, Rvalue::Len(self.place.clone())), + self.assign(len, Rvalue::Len(*self.place)), ], is_cleanup: self.unwind.is_cleanup(), terminator: Some(Terminator { @@ -735,8 +735,7 @@ where let iter_ty = if ptr_based { tcx.mk_mut_ptr(ety) } else { tcx.types.usize }; let cur = self.new_temp(iter_ty); - let length_or_end = - if ptr_based { Place::from(self.new_temp(iter_ty)) } else { length.clone() }; + let length_or_end = if ptr_based { Place::from(self.new_temp(iter_ty)) } else { length }; let unwind = self.unwind.map(|unwind| { self.drop_loop(unwind, cur, &length_or_end, ety, Unwind::InCleanup, ptr_based) @@ -752,7 +751,7 @@ where // cur = tmp as *mut T; // end = Offset(cur, len); vec![ - self.assign(&tmp, Rvalue::AddressOf(Mutability::Mut, self.place.clone())), + self.assign(&tmp, Rvalue::AddressOf(Mutability::Mut, *self.place)), self.assign(&cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)), self.assign( &length_or_end, @@ -925,11 +924,8 @@ where } fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { - let block = TerminatorKind::Drop { - location: self.place.clone(), - target, - unwind: unwind.into_option(), - }; + let block = + TerminatorKind::Drop { location: *self.place, target, unwind: unwind.into_option() }; self.new_block(unwind, block) } @@ -982,9 +978,6 @@ where } fn assign(&self, lhs: &Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> { - Statement { - source_info: self.source_info, - kind: StatementKind::Assign(box (lhs.clone(), rhs)), - } + Statement { source_info: self.source_info, kind: StatementKind::Assign(box (*lhs, rhs)) } } } diff --git a/src/librustc_mir_build/build/cfg.rs b/src/librustc_mir_build/build/cfg.rs index e1971102832b5..883aba18ec547 100644 --- a/src/librustc_mir_build/build/cfg.rs +++ b/src/librustc_mir_build/build/cfg.rs @@ -39,7 +39,7 @@ impl<'tcx> CFG<'tcx> { ) { self.push( block, - Statement { source_info, kind: StatementKind::Assign(box (place.clone(), rvalue)) }, + Statement { source_info, kind: StatementKind::Assign(box (*place, rvalue)) }, ); } diff --git a/src/librustc_mir_build/build/expr/as_place.rs b/src/librustc_mir_build/build/expr/as_place.rs index fd6882fa19fdf..f27760f692088 100644 --- a/src/librustc_mir_build/build/expr/as_place.rs +++ b/src/librustc_mir_build/build/expr/as_place.rs @@ -219,7 +219,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info, kind: StatementKind::AscribeUserType( box ( - Place::from(temp.clone()), + Place::from(temp), UserTypeProjection { base: annotation_index, projs: vec![] }, ), Variance::Invariant, @@ -347,11 +347,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, source_info, <, - Rvalue::BinaryOp( - BinOp::Lt, - Operand::Copy(Place::from(index)), - Operand::Copy(len.clone()), - ), + Rvalue::BinaryOp(BinOp::Lt, Operand::Copy(Place::from(index)), Operand::Copy(len)), ); let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) }; // assert!(lt, "...") @@ -396,7 +392,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Rvalue::Ref( tcx.lifetimes.re_erased, BorrowKind::Shallow, - Place { local: base_place.local.clone(), projection }, + Place { local: base_place.local, projection }, ), ); fake_borrow_temps.push(fake_borrow_temp); diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index 503dfb6ef5b61..5ef338c624da2 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -228,7 +228,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { destination: if expr.ty.is_never() { None } else { - Some((destination.clone(), success)) + Some((*destination, success)) }, from_hir_call, }, diff --git a/src/librustc_mir_build/build/expr/stmt.rs b/src/librustc_mir_build/build/expr/stmt.rs index fd61cb833b1bc..882c5e85bb0ac 100644 --- a/src/librustc_mir_build/build/expr/stmt.rs +++ b/src/librustc_mir_build/build/expr/stmt.rs @@ -79,14 +79,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // because AssignOp is only legal for Copy types // (overloaded ops should be desugared into a call). let result = unpack!( - block = this.build_binary_op( - block, - op, - expr_span, - lhs_ty, - Operand::Copy(lhs.clone()), - rhs - ) + block = + this.build_binary_op(block, op, expr_span, lhs_ty, Operand::Copy(lhs), rhs) ); this.cfg.push_assign(block, source_info, &lhs, result); diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index f9f10b55495fa..801e50eab8a16 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -166,7 +166,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .zip(candidate_pre_binding_blocks.by_ref()) .map(|(pattern, pre_binding_block)| Candidate { span: pattern.span, - match_pairs: smallvec![MatchPair::new(scrutinee.clone(), pattern)], + match_pairs: smallvec![MatchPair::new(*scrutinee, pattern)], bindings: vec![], ascriptions: vec![], otherwise_block: if arm_has_guard { @@ -427,7 +427,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // create a dummy candidate let mut candidate = Candidate { span: irrefutable_pat.span, - match_pairs: smallvec![MatchPair::new(initializer.clone(), &irrefutable_pat)], + match_pairs: smallvec![MatchPair::new(*initializer, &irrefutable_pat)], bindings: vec![], ascriptions: vec![], @@ -469,7 +469,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .. }))) = self.local_decls[local].local_info { - *match_place = Some(initializer.clone()); + *match_place = Some(*initializer); } else { bug!("Let binding to non-user variable.") } @@ -890,7 +890,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let proj_base = &source.projection[..i]; fake_borrows.insert(Place { - local: source.local.clone(), + local: source.local, projection: self.hir.tcx().intern_place_elems(proj_base), }); } @@ -1084,7 +1084,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // extract the match-pair from the highest priority candidate let match_pair = &candidates.first().unwrap().match_pairs[0]; let mut test = self.test(match_pair); - let match_place = match_pair.place.clone(); + let match_place = match_pair.place; // most of the time, the test to perform is simply a function // of the main candidate; but for a test like SwitchInt, we @@ -1258,7 +1258,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .into_iter() .map(|matched_place_ref| { let matched_place = Place { - local: matched_place_ref.local.clone(), + local: *matched_place_ref.local, projection: tcx.intern_place_elems(matched_place_ref.projection), }; let fake_borrow_deref_ty = matched_place.ty(&self.local_decls, tcx).ty; @@ -1416,7 +1416,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let re_erased = tcx.lifetimes.re_erased; let scrutinee_source_info = self.source_info(scrutinee_span); for (place, temp) in fake_borrows { - let borrow = Rvalue::Ref(re_erased, BorrowKind::Shallow, place.clone()); + let borrow = Rvalue::Ref(re_erased, BorrowKind::Shallow, *place); self.cfg.push_assign(block, scrutinee_source_info, &Place::from(*temp), borrow); } @@ -1514,7 +1514,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Statement { source_info, kind: StatementKind::AscribeUserType( - box (ascription.source.clone(), user_ty), + box (ascription.source, user_ty), ascription.variance, ), }, @@ -1540,7 +1540,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.storage_live_binding(block, binding.var_id, binding.span, RefWithinGuard); match binding.binding_mode { BindingMode::ByValue => { - let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, binding.source.clone()); + let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, binding.source); self.cfg.push_assign(block, source_info, &ref_for_guard, rvalue); } BindingMode::ByRef(borrow_kind) => { @@ -1551,7 +1551,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { OutsideGuard, ); - let rvalue = Rvalue::Ref(re_erased, borrow_kind, binding.source.clone()); + let rvalue = Rvalue::Ref(re_erased, borrow_kind, binding.source); self.cfg.push_assign(block, source_info, &value_for_arm, rvalue); let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, value_for_arm); self.cfg.push_assign(block, source_info, &ref_for_guard, rvalue); @@ -1581,7 +1581,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Rvalue::Use(self.consume_by_copy_or_move(binding.source.clone())) } BindingMode::ByRef(borrow_kind) => { - Rvalue::Ref(re_erased, borrow_kind, binding.source.clone()) + Rvalue::Ref(re_erased, borrow_kind, binding.source) } }; self.cfg.push_assign(block, source_info, &local, rvalue); diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index a5f691add65c1..fb3babca32b95 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -59,14 +59,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { match *match_pair.pattern.kind { PatKind::AscribeUserType { ref subpattern, - ascription: hair::pattern::Ascription { variance, ref user_ty, user_ty_span }, + ascription: hair::pattern::Ascription { variance, user_ty, user_ty_span }, } => { // Apply the type ascription to the value at `match_pair.place`, which is the // value being matched, taking the variance field into account. candidate.ascriptions.push(Ascription { span: user_ty_span, - user_ty: user_ty.clone(), - source: match_pair.place.clone(), + user_ty: user_ty, + source: match_pair.place, variance, }); @@ -85,7 +85,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { name, mutability, span: match_pair.pattern.span, - source: match_pair.place.clone(), + source: match_pair.place, var_id: var, var_ty: ty, binding_mode: mode, diff --git a/src/librustc_mir_build/build/matches/test.rs b/src/librustc_mir_build/build/matches/test.rs index 31fc0d121052a..1f97f5f1b7281 100644 --- a/src/librustc_mir_build/build/matches/test.rs +++ b/src/librustc_mir_build/build/matches/test.rs @@ -209,12 +209,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ); let discr_ty = adt_def.repr.discr_type().to_ty(tcx); let discr = self.temp(discr_ty, test.span); - self.cfg.push_assign( - block, - source_info, - &discr, - Rvalue::Discriminant(place.clone()), - ); + self.cfg.push_assign(block, source_info, &discr, Rvalue::Discriminant(*place)); assert_eq!(values.len() + 1, targets.len()); self.cfg.terminate( block, @@ -240,7 +235,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; TerminatorKind::if_( self.hir.tcx(), - Operand::Copy(place.clone()), + Operand::Copy(*place), true_bb, false_bb, ) @@ -251,7 +246,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // The switch may be inexhaustive so we have a catch all block debug_assert_eq!(options.len() + 1, target_blocks.len()); TerminatorKind::SwitchInt { - discr: Operand::Copy(place.clone()), + discr: Operand::Copy(*place), switch_ty, values: options.clone().into(), targets: target_blocks, @@ -276,7 +271,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let [success, fail] = *make_target_blocks(self) { assert_eq!(value.ty, ty); let expect = self.literal_operand(test.span, value); - let val = Operand::Copy(place.clone()); + let val = Operand::Copy(*place); self.compare(block, success, fail, source_info, BinOp::Eq, expect, val); } else { bug!("`TestKind::Eq` should have two target blocks"); @@ -291,7 +286,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons. let lo = self.literal_operand(test.span, lo); let hi = self.literal_operand(test.span, hi); - let val = Operand::Copy(place.clone()); + let val = Operand::Copy(*place); if let [success, fail] = *target_blocks { self.compare( @@ -320,7 +315,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let actual = self.temp(usize_ty, test.span); // actual = len(place) - self.cfg.push_assign(block, source_info, &actual, Rvalue::Len(place.clone())); + self.cfg.push_assign(block, source_info, &actual, Rvalue::Len(*place)); // expected = let expected = self.push_usize(block, source_info, len); @@ -382,7 +377,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { use rustc::middle::lang_items::EqTraitLangItem; let mut expect = self.literal_operand(source_info.span, value); - let mut val = Operand::Copy(place.clone()); + let mut val = Operand::Copy(*place); // If we're using `b"..."` as a pattern, we need to insert an // unsizing coercion, as the byte string has the type `&[u8; N]`. @@ -457,7 +452,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { literal: method, }), args: vec![val, expect], - destination: Some((eq_result.clone(), eq_block)), + destination: Some((eq_result, eq_block)), cleanup: Some(cleanup), from_hir_call: false, }, diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 44ff493b5b4f0..fa5f266c76b14 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -884,7 +884,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { VarBindingForm { binding_mode, opt_ty_info, - opt_match_place: Some((Some(place.clone()), span)), + opt_match_place: Some((Some(place), span)), pat_span: span, }, ))) @@ -939,12 +939,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn get_unit_temp(&mut self) -> Place<'tcx> { match self.unit_temp { - Some(ref tmp) => tmp.clone(), + Some(tmp) => tmp, None => { let ty = self.hir.unit_ty(); let fn_span = self.fn_span; let tmp = self.temp(ty, fn_span); - self.unit_temp = Some(tmp.clone()); + self.unit_temp = Some(tmp); tmp } } diff --git a/src/librustc_mir_build/build/scope.rs b/src/librustc_mir_build/build/scope.rs index d994b870853c1..a63ac06ec3fe9 100644 --- a/src/librustc_mir_build/build/scope.rs +++ b/src/librustc_mir_build/build/scope.rs @@ -318,11 +318,11 @@ impl<'tcx> Scopes<'tcx> { if scope.break_destination != Place::return_place() { span_bug!(span, "`return` in item with no return scope"); } - (scope.break_block, scope.region_scope, Some(scope.break_destination.clone())) + (scope.break_block, scope.region_scope, Some(scope.break_destination)) } BreakableTarget::Break(scope) => { let scope = get_scope(scope); - (scope.break_block, scope.region_scope, Some(scope.break_destination.clone())) + (scope.break_block, scope.region_scope, Some(scope.break_destination)) } BreakableTarget::Continue(scope) => { let scope = get_scope(scope); diff --git a/src/librustc_passes/stability.rs b/src/librustc_passes/stability.rs index 320b433190e5e..db8109c285980 100644 --- a/src/librustc_passes/stability.rs +++ b/src/librustc_passes/stability.rs @@ -366,8 +366,8 @@ fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> { // Put the active features into a map for quick lookup. index.active_features = active_lib_features .iter() - .map(|&(ref s, ..)| s.clone()) - .chain(active_lang_features.iter().map(|&(ref s, ..)| s.clone())) + .map(|&(s, ..)| s) + .chain(active_lang_features.iter().map(|&(s, ..)| s)) .collect(); { diff --git a/src/librustc_ty/ty.rs b/src/librustc_ty/ty.rs index 8b62403e6ce52..8f882be1a090e 100644 --- a/src/librustc_ty/ty.rs +++ b/src/librustc_ty/ty.rs @@ -263,7 +263,7 @@ fn crate_disambiguator(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateDisambiguat fn original_crate_name(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Symbol { assert_eq!(crate_num, LOCAL_CRATE); - tcx.crate_name.clone() + tcx.crate_name } fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 54b32c3a50fcd..bedef5042fdb6 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -572,7 +572,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { has_unsized_tuple_coercion = true; } } - tr.clone() + *tr } _ => { coercion.obligations.push(obligation); diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 2012a2a1526b1..832aa9f62ff4d 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -596,7 +596,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { target_trait_def_id: DefId, ) -> ty::PolyTraitRef<'tcx> { let upcast_trait_refs = - traits::upcast_choices(self.tcx, source_trait_ref.clone(), target_trait_def_id); + traits::upcast_choices(self.tcx, source_trait_ref, target_trait_def_id); // must be exactly one trait ref or we'd get an ambig error etc if upcast_trait_refs.len() != 1 { diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 2adf125f048d0..2444fc60f77ba 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1491,7 +1491,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // FIXME: check the return type here somehow. // If so, just use this trait and call it a day. Some(Pick { - item: probes[0].0.item.clone(), + item: probes[0].0.item, kind: TraitPick, import_ids: probes[0].0.import_ids.clone(), autoderefs: 0, @@ -1715,7 +1715,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { impl<'tcx> Candidate<'tcx> { fn to_unadjusted_pick(&self) -> Pick<'tcx> { Pick { - item: self.item.clone(), + item: self.item, kind: match self.kind { InherentImplCandidate(..) => InherentImplPick, ObjectCandidate => ObjectPick, @@ -1731,7 +1731,7 @@ impl<'tcx> Candidate<'tcx> { && !trait_ref.skip_binder().substs.has_placeholders() ); - WhereClausePick(trait_ref.clone()) + WhereClausePick(*trait_ref) } }, import_ids: self.import_ids.clone(), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1b60de92e4bc9..4d1f92d19ce09 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1208,8 +1208,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { debug!( "local variable {:?} is assigned type {}", local.pat, - self.fcx - .ty_to_string(self.fcx.locals.borrow().get(&local.hir_id).unwrap().clone().decl_ty) + self.fcx.ty_to_string(&*self.fcx.locals.borrow().get(&local.hir_id).unwrap().decl_ty) ); intravisit::walk_local(self, local); } @@ -1226,8 +1225,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { debug!( "pattern binding {} is assigned to {} with type {:?}", ident, - self.fcx - .ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().clone().decl_ty), + self.fcx.ty_to_string(&*self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty), var_ty ); } @@ -1275,7 +1273,7 @@ fn check_fn<'a, 'tcx>( body: &'tcx hir::Body<'tcx>, can_be_generator: Option, ) -> (FnCtxt<'a, 'tcx>, Option>) { - let mut fn_sig = fn_sig.clone(); + let mut fn_sig = fn_sig; debug!("check_fn(sig={:?}, fn_id={}, param_env={:?})", fn_sig, fn_id, param_env); diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 1ab8f05db1266..028c39b80e426 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -499,7 +499,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let fn_sig = { match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(hir_id) { - Some(f) => f.clone(), + Some(f) => *f, None => { bug!("No fn-sig entry for def_id={:?}", def_id); } diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 967741092febe..af2ccb4517664 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -306,7 +306,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> { let fn_sig = { match self.tables.borrow().liberated_fn_sigs().get(id) { - Some(f) => f.clone(), + Some(f) => *f, None => { bug!("No fn-sig entry for id={:?}", id); } diff --git a/src/librustc_typeck/constrained_generic_params.rs b/src/librustc_typeck/constrained_generic_params.rs index a281c0ae67d24..9b187d461cdeb 100644 --- a/src/librustc_typeck/constrained_generic_params.rs +++ b/src/librustc_typeck/constrained_generic_params.rs @@ -181,7 +181,7 @@ pub fn setup_constraining_predicates<'tcx>( // to project out an associated type defined by this very // trait. let unbound_trait_ref = projection.projection_ty.trait_ref(tcx); - if Some(unbound_trait_ref.clone()) == impl_trait_ref { + if Some(unbound_trait_ref) == impl_trait_ref { continue; } diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 27f8059691a14..8edd0591c8556 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -393,7 +393,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { Type::ResolvedPath { path: new_path, param_names: param_names.clone(), - did: did.clone(), + did: *did, is_generic: *is_generic, } } @@ -468,7 +468,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { }) .map(|p| { let replaced = p.fold_with(&mut replacer); - (replaced.clone(), replaced.clean(self.cx)) + (replaced, replaced.clean(self.cx)) }); let mut generic_params = @@ -614,7 +614,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { trait_: Type::ResolvedPath { path: new_trait_path, param_names: param_names.clone(), - did: did.clone(), + did: *did, is_generic: *is_generic, }, generic_params: Vec::new(), diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7a7d69c68a585..281306cc0c591 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1417,7 +1417,7 @@ impl Clean for hir::Ty<'_> { }); if let Some(ty) = type_ { ty_substs.insert(ty_param_def_id, ty.clean(cx)); - } else if let Some(default) = default.clone() { + } else if let Some(default) = *default { ty_substs.insert(ty_param_def_id, default.clean(cx)); } indices.types += 1; diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 8058536d60b31..07381eddea707 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -319,7 +319,7 @@ pub fn strip_path(path: &Path) -> Path { }) .collect(); - Path { global: path.global, res: path.res.clone(), segments } + Path { global: path.global, res: path.res, segments } } pub fn qpath_to_string(p: &hir::QPath) -> String { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 4c8b8112fa85a..1c0e0b3bf410b 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -125,7 +125,7 @@ impl<'tcx> DocContext<'tcx> { let mut fake_ids = self.fake_def_ids.borrow_mut(); - let def_id = fake_ids.entry(crate_num).or_insert(start_def_id).clone(); + let def_id = *fake_ids.entry(crate_num).or_insert(start_def_id); fake_ids.insert( crate_num, DefId { krate: crate_num, index: DefIndex::from(def_id.index.index() + 1) }, @@ -137,7 +137,7 @@ impl<'tcx> DocContext<'tcx> { self.all_fake_def_ids.borrow_mut().insert(def_id); - def_id.clone() + def_id } /// Like the function of the same name on the HIR map, but skips calling it on fake DefIds. diff --git a/src/tools/cargo b/src/tools/cargo index b68b0978ab801..9d32b7b014090 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit b68b0978ab8012f871c80736fb910d14b89c4498 +Subproject commit 9d32b7b01409024b165545c568b1525d86e2b7cb diff --git a/src/tools/miri b/src/tools/miri index 6a0f14bef7784..83403581bb7a2 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 6a0f14bef7784e57a57a996cae3f94dbd2490e7a +Subproject commit 83403581bb7a2156f4752fc2d0ceef4b3ec75554