1
Fork 0

Auto merge of #68580 - Mark-Simulacrum:rollup-r80xhus, r=Mark-Simulacrum

Rollup of 3 pull requests

Successful merges:

 - #68459 (don't clone types that are copy, round two.)
 - #68576 (update miri)
 - #68579 (Update cargo)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-01-27 22:59:38 +00:00
commit 0859451592
58 changed files with 157 additions and 194 deletions

View file

@ -19,7 +19,7 @@ fn const_vars_since_snapshot<'tcx>(
( (
range.start..range.end, range.start..range.end,
(range.start.index..range.end.index) (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(), .collect(),
) )
} }

View file

@ -611,7 +611,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
errors.push(RegionResolutionError::GenericBoundFailure( errors.push(RegionResolutionError::GenericBoundFailure(
verify.origin.clone(), verify.origin.clone(),
verify.kind.clone(), verify.kind,
sub, sub,
)); ));
} }
@ -761,7 +761,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
for upper_bound in &upper_bounds { for upper_bound in &upper_bounds {
if !self.region_rels.is_subregion_of(effective_lower_bound, upper_bound.region) { 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!( debug!(
"region inference error at {:?} for {:?}: SubSupConflict sub: {:?} \ "region inference error at {:?} for {:?}: SubSupConflict sub: {:?} \
sup: {:?}", sup: {:?}",

View file

@ -832,7 +832,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
( (
range.clone(), range.clone(),
(range.start.index()..range.end.index()) (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(), .collect(),
) )
} }

View file

@ -306,7 +306,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
( (
range.start.vid..range.end.vid, range.start.vid..range.end.vid,
(range.start.vid.index..range.end.vid.index) (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(), .collect(),
) )
} }

View file

@ -1988,7 +1988,7 @@ impl<'tcx> Operand<'tcx> {
pub fn to_copy(&self) -> Self { pub fn to_copy(&self) -> Self {
match *self { match *self {
Operand::Copy(_) | Operand::Constant(_) => self.clone(), 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 let projs: Vec<_> = self
.projs .projs
.iter() .iter()
.map(|elem| match elem { .map(|&elem| match elem {
Deref => Deref, Deref => Deref,
Field(f, ()) => Field(f.clone(), ()), Field(f, ()) => Field(f, ()),
Index(()) => Index(()), 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(); .collect();
@ -2862,11 +2866,15 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
use crate::mir::ProjectionElem::*; use crate::mir::ProjectionElem::*;
match self { match *self {
Deref => Deref, 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)), 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<R, C> {
impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
Constant { Constant {
span: self.span.clone(), span: self.span,
user_ty: self.user_ty.fold_with(folder), user_ty: self.user_ty.fold_with(folder),
literal: self.literal.fold_with(folder), literal: self.literal.fold_with(folder),
} }

View file

@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> {
} }
pub fn codegen_dep_node(&self, tcx: TyCtxt<'tcx>) -> DepNode { 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()))
} }
} }

View file

@ -535,7 +535,7 @@ impl AutoTraitFinder<'tcx> {
} }
while !vid_map.is_empty() { 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"); let deps = vid_map.remove(&target).expect("Entry somehow missing");
for smaller in deps.smaller.iter() { for smaller in deps.smaller.iter() {

View file

@ -54,10 +54,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
span, span,
predicates predicates
.iter() .iter()
.map(|predicate| ErrorDescriptor { .map(|&predicate| ErrorDescriptor { predicate, index: None })
predicate: predicate.clone(),
index: None,
})
.collect(), .collect(),
) )
}) })
@ -73,7 +70,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
} }
error_map.entry(span).or_default().push(ErrorDescriptor { error_map.entry(span).or_default().push(ErrorDescriptor {
predicate: error.obligation.predicate.clone(), predicate: error.obligation.predicate,
index: Some(index), 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 { if let ty::Predicate::Trait(implication, _) = implication {
let error = error.to_poly_trait_ref(); let error = error.to_poly_trait_ref();
let implication = implication.to_poly_trait_ref(); let implication = implication.to_poly_trait_ref();

View file

@ -377,7 +377,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
let normalized_ty = normalize_projection_type( let normalized_ty = normalize_projection_type(
self.selcx, self.selcx,
self.param_env, self.param_env,
data.clone(), *data,
self.cause.clone(), self.cause.clone(),
self.depth, self.depth,
&mut self.obligations, &mut self.obligations,
@ -433,7 +433,7 @@ pub fn normalize_projection_type<'a, 'b, 'tcx>(
opt_normalize_projection_type( opt_normalize_projection_type(
selcx, selcx,
param_env, param_env,
projection_ty.clone(), projection_ty,
cause.clone(), cause.clone(),
depth, depth,
obligations, obligations,

View file

@ -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<u32>`. // but `Foo` is declared as `trait Foo: Bar<u32>`.
let upcast_trait_refs = util::supertraits(self.tcx(), poly_trait_ref) let upcast_trait_refs = util::supertraits(self.tcx(), poly_trait_ref)
.filter(|upcast_trait_ref| { .filter(|upcast_trait_ref| {
self.infcx.probe(|_| { self.infcx
let upcast_trait_ref = upcast_trait_ref.clone(); .probe(|_| self.match_poly_trait_ref(obligation, *upcast_trait_ref).is_ok())
self.match_poly_trait_ref(obligation, upcast_trait_ref).is_ok()
})
}) })
.count(); .count();
@ -2243,7 +2241,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let def_id = obligation.predicate.def_id(); let def_id = obligation.predicate.def_id();
if self.tcx().is_trait_alias(def_id) { if self.tcx().is_trait_alias(def_id) {
candidates.vec.push(TraitAliasCandidate(def_id.clone())); candidates.vec.push(TraitAliasCandidate(def_id));
} }
Ok(()) Ok(())
@ -3249,7 +3247,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
obligation_trait_ref: ty::PolyTraitRef<'tcx>, obligation_trait_ref: ty::PolyTraitRef<'tcx>,
expected_trait_ref: ty::PolyTraitRef<'tcx>, expected_trait_ref: ty::PolyTraitRef<'tcx>,
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> { ) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
let obligation_trait_ref = obligation_trait_ref.clone();
self.infcx self.infcx
.at(&obligation_cause, obligation_param_env) .at(&obligation_cause, obligation_param_env)
.sup(obligation_trait_ref, expected_trait_ref) .sup(obligation_trait_ref, expected_trait_ref)

View file

@ -526,11 +526,11 @@ pub fn predicates_for_generics<'tcx>(
generic_bounds generic_bounds
.predicates .predicates
.iter() .iter()
.map(|predicate| Obligation { .map(|&predicate| Obligation {
cause: cause.clone(), cause: cause.clone(),
recursion_depth, recursion_depth,
param_env, param_env,
predicate: predicate.clone(), predicate,
}) })
.collect() .collect()
} }

View file

@ -318,8 +318,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
if let Elaborate::All = elaborate { if let Elaborate::All = elaborate {
let trait_assoc_items = tcx.associated_items(trait_ref.def_id); let trait_assoc_items = tcx.associated_items(trait_ref.def_id);
let predicates = let predicates = obligations.iter().map(|obligation| obligation.predicate).collect();
obligations.iter().map(|obligation| obligation.predicate.clone()).collect();
let implied_obligations = traits::elaborate_predicates(tcx, predicates); let implied_obligations = traits::elaborate_predicates(tcx, predicates);
let implied_obligations = implied_obligations.map(|pred| { let implied_obligations = implied_obligations.map(|pred| {
let mut cause = cause.clone(); let mut cause = cause.clone();

View file

@ -1294,7 +1294,7 @@ impl<'tcx> TyCtxt<'tcx> {
// statements within the query system and we'd run into endless // statements within the query system and we'd run into endless
// recursion otherwise. // recursion otherwise.
let (crate_name, crate_disambiguator) = if def_id.is_local() { 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 { } else {
( (
self.cstore.crate_name_untracked(def_id.krate), self.cstore.crate_name_untracked(def_id.krate),

View file

@ -1326,7 +1326,7 @@ pub trait ToPolyTraitRef<'tcx> {
impl<'tcx> ToPolyTraitRef<'tcx> for TraitRef<'tcx> { impl<'tcx> ToPolyTraitRef<'tcx> for TraitRef<'tcx> {
fn to_poly_trait_ref(&self) -> PolyTraitRef<'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> { impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> { fn to_predicate(&self) -> Predicate<'tcx> {
Predicate::RegionOutlives(self.clone()) Predicate::RegionOutlives(*self)
} }
} }
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> { impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> { fn to_predicate(&self) -> Predicate<'tcx> {
Predicate::TypeOutlives(self.clone()) Predicate::TypeOutlives(*self)
} }
} }
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> { impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> { fn to_predicate(&self) -> Predicate<'tcx> {
Predicate::Projection(self.clone()) Predicate::Projection(*self)
} }
} }

View file

@ -838,7 +838,7 @@ impl<'tcx> PolyTraitRef<'tcx> {
pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> { pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
// Note that we preserve binding levels // Note that we preserve binding levels
Binder(ty::TraitPredicate { trait_ref: self.skip_binder().clone() }) Binder(ty::TraitPredicate { trait_ref: *self.skip_binder() })
} }
} }

View file

@ -708,7 +708,7 @@ impl<'a, 'b> Context<'a, 'b> {
// Before consuming the expressions, we have to remember spans for // Before consuming the expressions, we have to remember spans for
// count arguments as they are now generated separate from other // count arguments as they are now generated separate from other
// arguments, hence have no access to the `P<ast::Expr>`'s. // arguments, hence have no access to the `P<ast::Expr>`'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: // Right now there is a bug such that for the expression:
// foo(bar(&1)) // foo(bar(&1))

View file

@ -400,7 +400,7 @@ pub trait Emitter {
} }
if sm.span_to_filename(sp_label.span.clone()).is_macros() && !always_backtrace { if sm.span_to_filename(sp_label.span.clone()).is_macros() && !always_backtrace {
if let Some(use_site) = sp_label.span.macro_backtrace().last() { 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(); let level_str = level.to_string();
// The failure note level itself does not provide any useful diagnostic information // The failure note level itself does not provide any useful diagnostic information
if *level != Level::FailureNote && !level_str.is_empty() { 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 // only render error codes, not lint codes
if let Some(DiagnosticId::Error(ref code)) = *code { if let Some(DiagnosticId::Error(ref code)) = *code {
buffer.append(0, "[", Style::Level(level.clone())); buffer.append(0, "[", Style::Level(*level));
buffer.append(0, &code, Style::Level(level.clone())); buffer.append(0, &code, Style::Level(*level));
buffer.append(0, "]", Style::Level(level.clone())); buffer.append(0, "]", Style::Level(*level));
} }
if *level != Level::FailureNote && !level_str.is_empty() { if *level != Level::FailureNote && !level_str.is_empty() {
buffer.append(0, ": ", header_style); buffer.append(0, ": ", header_style);
@ -1495,7 +1495,7 @@ impl EmitterWriter {
// Render the suggestion message // Render the suggestion message
let level_str = level.to_string(); let level_str = level.to_string();
if !level_str.is_empty() { 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); buffer.append(0, ": ", Style::HeaderMsg);
} }
self.msg_to_buffer( self.msg_to_buffer(

View file

@ -691,7 +691,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection); let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection);
if self.access_place_error_reported.contains(&( 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, borrow_span,
)) { )) {
debug!( debug!(
@ -702,7 +702,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} }
self.access_place_error_reported.insert(( 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, borrow_span,
)); ));

View file

@ -178,7 +178,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}; };
grouped_errors.push(GroupedMoveError::MovesFromPlace { grouped_errors.push(GroupedMoveError::MovesFromPlace {
span, span,
move_from: match_place.clone(), move_from: *match_place,
original_path, original_path,
kind, kind,
binds_to, binds_to,

View file

@ -883,7 +883,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// Check is_empty() first because it's the common case, and doing that // Check is_empty() first because it's the common case, and doing that
// way we avoid the clone() call. // way we avoid the clone() call.
if !self.access_place_error_reported.is_empty() 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!( debug!(
"access_place: suppressing error place_span=`{:?}` kind=`{:?}`", "access_place: suppressing error place_span=`{:?}` kind=`{:?}`",
@ -911,7 +911,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if conflict_error || mutability_error { if conflict_error || mutability_error {
debug!("access_place: logging error place_span=`{:?}` kind=`{:?}`", place_span, kind); 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 // the 2018 edition so we emit it as a warning. We buffer
// these sepately so that we only emit a warning if borrow // these sepately so that we only emit a warning if borrow
// checking was otherwise successful. // checking was otherwise successful.
this.reservation_warnings.insert( this.reservation_warnings
bi, .insert(bi, (*place_span.0, place_span.1, location, bk, borrow.clone()));
(place_span.0.clone(), place_span.1, location, bk, borrow.clone()),
);
// Don't suppress actual errors. // Don't suppress actual errors.
Control::Continue Control::Continue

View file

@ -226,7 +226,7 @@ pub fn const_eval_validated_provider<'tcx>(
) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
// see comment in const_eval_raw_provider for what we're doing here // see comment in const_eval_raw_provider for what we're doing here
if key.param_env.reveal == Reveal::All { if key.param_env.reveal == Reveal::All {
let mut key = key.clone(); let mut key = key;
key.param_env.reveal = Reveal::UserFacing; key.param_env.reveal = Reveal::UserFacing;
match tcx.const_eval_validated(key) { match tcx.const_eval_validated(key) {
// try again with reveal all as requested // 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. // In case we fail in the `UserFacing` variant, we just do the real computation.
if key.param_env.reveal == Reveal::All { if key.param_env.reveal == Reveal::All {
let mut key = key.clone(); let mut key = key;
key.param_env.reveal = Reveal::UserFacing; key.param_env.reveal = Reveal::UserFacing;
match tcx.const_eval_raw(key) { match tcx.const_eval_raw(key) {
// try again with reveal all as requested // try again with reveal all as requested

View file

@ -47,7 +47,7 @@ impl<'tcx> Lift for PlaceElem<'tcx> {
fn lift(&self) -> Self::Abstract { fn lift(&self) -> Self::Abstract {
match *self { match *self {
ProjectionElem::Deref => ProjectionElem::Deref, 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::Index(ref i) => ProjectionElem::Index(i.lift()),
ProjectionElem::Subslice { from, to, from_end } => { ProjectionElem::Subslice { from, to, from_end } => {
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::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),
} }
} }
} }

View file

@ -158,7 +158,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
if union_path.is_none() { if union_path.is_none() {
base = self.add_move_path(base, elem, |tcx| Place { 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]), 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 // Split `Subslice` patterns into the corresponding list of
// `ConstIndex` patterns. This is done to ensure that all move paths // `ConstIndex` patterns. This is done to ensure that all move paths
// are disjoint, which is expected by drop elaboration. // are disjoint, which is expected by drop elaboration.
let base_place = Place { let base_place =
local: place.local.clone(), Place { local: place.local, projection: self.builder.tcx.intern_place_elems(base) };
projection: self.builder.tcx.intern_place_elems(base),
};
let base_path = match self.move_path_for(&base_place) { let base_path = match self.move_path_for(&base_place) {
Ok(path) => path, Ok(path) => path,
Err(MoveError::UnionMove { path }) => { Err(MoveError::UnionMove { path }) => {
@ -467,7 +465,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
match self.move_path_for(place) { match self.move_path_for(place) {
Ok(path) | Err(MoveError::UnionMove { path }) => self.record_move(place, path), Ok(path) | Err(MoveError::UnionMove { path }) => self.record_move(place, path),
Err(error @ MoveError::IllegalMove { .. }) => { Err(error @ MoveError::IllegalMove { .. }) => {
self.builder.errors.push((place.clone(), error)); self.builder.errors.push((*place, error));
} }
}; };
} }

View file

@ -740,18 +740,15 @@ fn compute_codegen_unit_name(
let cgu_def_id = cgu_def_id.unwrap(); let cgu_def_id = cgu_def_id.unwrap();
cache *cache.entry((cgu_def_id, volatile)).or_insert_with(|| {
.entry((cgu_def_id, volatile)) let def_path = tcx.def_path(cgu_def_id);
.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) name_builder.build_cgu_name(def_path.krate, components, volatile_suffix)
}) })
.clone()
} }
fn numbered_codegen_unit_name( fn numbered_codegen_unit_name(

View file

@ -207,7 +207,7 @@ fn build_drop_shim<'tcx>(
0, 0,
Statement { Statement {
source_info, 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 ref_loc: &ty = &src;`
let statement = self.make_statement(StatementKind::Assign(box ( let statement = self.make_statement(StatementKind::Assign(box (
ref_loc.clone(), ref_loc,
Rvalue::Ref(tcx.lifetimes.re_erased, BorrowKind::Shared, src), 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 cond = self.make_place(Mutability::Mut, tcx.types.bool);
let compute_cond = self.make_statement(StatementKind::Assign(box ( let compute_cond = self.make_statement(StatementKind::Assign(box (
cond.clone(), cond,
Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)), 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))), Rvalue::Use(Operand::Constant(self.make_usize(0))),
))), ))),
self.make_statement(StatementKind::Assign(box ( self.make_statement(StatementKind::Assign(box (
end.clone(), end,
Rvalue::Use(Operand::Constant(self.make_usize(len))), Rvalue::Use(Operand::Constant(self.make_usize(len))),
))), ))),
]; ];

View file

@ -108,7 +108,7 @@ fn add_move_for_packed_drop<'tcx>(
}); });
patch.add_statement(loc, StatementKind::StorageLive(temp)); 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( patch.patch_terminator(
loc.block, loc.block,
TerminatorKind::Drop { location: Place::from(temp), target: storage_dead_block, unwind }, TerminatorKind::Drop { location: Place::from(temp), target: storage_dead_block, unwind },

View file

@ -108,7 +108,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
if needs_retag(&destination.0) { if needs_retag(&destination.0) {
returns.push(( returns.push((
block_data.terminator().source_info, block_data.terminator().source_info,
destination.0.clone(), destination.0,
destination.1, destination.1,
)); ));
} }
@ -141,8 +141,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
for i in (0..block_data.statements.len()).rev() { for i in (0..block_data.statements.len()).rev() {
let (retag_kind, place) = match block_data.statements[i].kind { let (retag_kind, place) = match block_data.statements[i].kind {
// Retag-as-raw after escaping to a raw pointer. // Retag-as-raw after escaping to a raw pointer.
StatementKind::Assign(box (ref place, Rvalue::AddressOf(..))) => { StatementKind::Assign(box (place, Rvalue::AddressOf(..))) => {
(RetagKind::Raw, place.clone()) (RetagKind::Raw, place)
} }
// Assignments of reference or ptr type are the ones where we may have // Assignments of reference or ptr type are the ones where we may have
// to update tags. This includes `x = &[mut] ...` and hence // to update tags. This includes `x = &[mut] ...` and hence
@ -156,7 +156,7 @@ impl<'tcx> MirPass<'tcx> for AddRetag {
} }
_ => RetagKind::Default, _ => RetagKind::Default,
}; };
(kind, place.clone()) (kind, *place)
} }
// Do nothing for the rest // Do nothing for the rest
_ => continue, _ => continue,

View file

@ -348,7 +348,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
// `unsafe` blocks are required in safe code // `unsafe` blocks are required in safe code
Safety::Safe => { Safety::Safe => {
for violation in violations { for violation in violations {
let mut violation = violation.clone(); let mut violation = *violation;
match violation.kind { match violation.kind {
UnsafetyViolationKind::GeneralAndConstFn UnsafetyViolationKind::GeneralAndConstFn
| UnsafetyViolationKind::General => {} | UnsafetyViolationKind::General => {}
@ -383,7 +383,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> {
// these things are forbidden in const fns // these things are forbidden in const fns
UnsafetyViolationKind::General UnsafetyViolationKind::General
| UnsafetyViolationKind::BorrowPacked(_) => { | UnsafetyViolationKind::BorrowPacked(_) => {
let mut violation = violation.clone(); let mut violation = *violation;
// const fns don't need to be backwards compatible and can // const fns don't need to be backwards compatible and can
// emit these violations as a hard error instead of a backwards // emit these violations as a hard error instead of a backwards
// compat lint // compat lint

View file

@ -459,7 +459,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported"); assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported");
let assign = Statement { 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, source_info: terminator.source_info,
}; };
@ -512,11 +512,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent); debug!("elaborate_drop_and_replace({:?}) - untracked {:?}", terminator, parent);
self.patch.patch_terminator( self.patch.patch_terminator(
bb, bb,
TerminatorKind::Drop { TerminatorKind::Drop { location: *location, target, unwind: Some(unwind) },
location: location.clone(),
target,
unwind: Some(unwind),
},
); );
} }
} }

View file

@ -260,7 +260,7 @@ impl TransformVisitor<'tcx> {
let self_place = Place::from(self_arg()); let self_place = Place::from(self_arg());
let assign = Statement { let assign = Statement {
source_info: source_info(body), 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) (assign, temp)
} }

View file

@ -354,7 +354,7 @@ impl Inliner<'tcx> {
let ty = v.ty.subst(tcx, callsite.substs); let ty = v.ty.subst(tcx, callsite.substs);
// Cost of the var is the size in machine-words, if we know // Cost of the var is the size in machine-words, if we know
// it. // 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; cost += (size / ptr_size) as usize;
} else { } else {
cost += UNKNOWN_SIZE_COST; cost += UNKNOWN_SIZE_COST;
@ -450,7 +450,7 @@ impl Inliner<'tcx> {
let stmt = Statement { let stmt = Statement {
source_info: callsite.location, source_info: callsite.location,
kind: StatementKind::Assign(box (tmp.clone(), dest)), kind: StatementKind::Assign(box (tmp, dest)),
}; };
caller_body[callsite.bb].statements.push(stmt); caller_body[callsite.bb].statements.push(stmt);
self.tcx.mk_place_deref(tmp) self.tcx.mk_place_deref(tmp)

View file

@ -51,7 +51,7 @@ impl<'tcx> MutVisitor<'tcx> for InstCombineVisitor<'tcx> {
let new_place = match rvalue { let new_place = match rvalue {
Rvalue::Ref(_, _, place) => { Rvalue::Ref(_, _, place) => {
if let &[ref proj_l @ .., proj_r] = place.projection.as_ref() { 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 { Place {
// Replace with dummy // Replace with dummy

View file

@ -24,10 +24,7 @@ pub fn expand_aggregate<'tcx>(
AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => { AggregateKind::Adt(adt_def, variant_index, _, _, active_field_index) => {
if adt_def.is_enum() { if adt_def.is_enum() {
set_discriminant = Some(Statement { set_discriminant = Some(Statement {
kind: StatementKind::SetDiscriminant { kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index },
place: box (lhs.clone()),
variant_index,
},
source_info, source_info,
}); });
lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index); lhs = tcx.mk_place_downcast(lhs, adt_def, variant_index);
@ -39,7 +36,7 @@ pub fn expand_aggregate<'tcx>(
// variant 0 (Unresumed). // variant 0 (Unresumed).
let variant_index = VariantIdx::new(0); let variant_index = VariantIdx::new(0);
set_discriminant = Some(Statement { set_discriminant = Some(Statement {
kind: StatementKind::SetDiscriminant { place: box (lhs.clone()), variant_index }, kind: StatementKind::SetDiscriminant { place: box (lhs), variant_index },
source_info, source_info,
}); });

View file

@ -168,7 +168,7 @@ where
self.elaborator.patch().patch_terminator( self.elaborator.patch().patch_terminator(
bb, bb,
TerminatorKind::Drop { TerminatorKind::Drop {
location: self.place.clone(), location: *self.place,
target: self.succ, target: self.succ,
unwind: self.unwind.into_option(), unwind: self.unwind.into_option(),
}, },
@ -517,7 +517,7 @@ where
// way lies only trouble. // way lies only trouble.
let discr_ty = adt.repr.discr_type().to_ty(self.tcx()); let discr_ty = adt.repr.discr_type().to_ty(self.tcx());
let discr = Place::from(self.new_temp(discr_ty)); 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 { let switch_block = BasicBlockData {
statements: vec![self.assign(&discr, discr_rv)], statements: vec![self.assign(&discr, discr_rv)],
terminator: Some(Terminator { terminator: Some(Terminator {
@ -554,7 +554,7 @@ where
Rvalue::Ref( Rvalue::Ref(
tcx.lifetimes.re_erased, tcx.lifetimes.re_erased,
BorrowKind::Mut { allow_two_phase_borrow: false }, BorrowKind::Mut { allow_two_phase_borrow: false },
self.place.clone(), *self.place,
), ),
)], )],
terminator: Some(Terminator { terminator: Some(Terminator {
@ -634,7 +634,7 @@ where
let loop_block = BasicBlockData { let loop_block = BasicBlockData {
statements: vec![self.assign( statements: vec![self.assign(
&can_go, &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(), is_cleanup: unwind.is_cleanup(),
terminator: Some(Terminator { 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 elem_size = &Place::from(self.new_temp(tcx.types.usize));
let len = &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 { let base_block = BasicBlockData {
statements: vec![ statements: vec![
self.assign(elem_size, Rvalue::NullaryOp(NullOp::SizeOf, ety)), 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(), is_cleanup: self.unwind.is_cleanup(),
terminator: Some(Terminator { terminator: Some(Terminator {
@ -735,8 +735,7 @@ where
let iter_ty = if ptr_based { tcx.mk_mut_ptr(ety) } else { tcx.types.usize }; let iter_ty = if ptr_based { tcx.mk_mut_ptr(ety) } else { tcx.types.usize };
let cur = self.new_temp(iter_ty); let cur = self.new_temp(iter_ty);
let length_or_end = let length_or_end = if ptr_based { Place::from(self.new_temp(iter_ty)) } else { length };
if ptr_based { Place::from(self.new_temp(iter_ty)) } else { length.clone() };
let unwind = self.unwind.map(|unwind| { let unwind = self.unwind.map(|unwind| {
self.drop_loop(unwind, cur, &length_or_end, ety, Unwind::InCleanup, ptr_based) self.drop_loop(unwind, cur, &length_or_end, ety, Unwind::InCleanup, ptr_based)
@ -752,7 +751,7 @@ where
// cur = tmp as *mut T; // cur = tmp as *mut T;
// end = Offset(cur, len); // end = Offset(cur, len);
vec![ 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(&cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)),
self.assign( self.assign(
&length_or_end, &length_or_end,
@ -925,11 +924,8 @@ where
} }
fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock { fn drop_block(&mut self, target: BasicBlock, unwind: Unwind) -> BasicBlock {
let block = TerminatorKind::Drop { let block =
location: self.place.clone(), TerminatorKind::Drop { location: *self.place, target, unwind: unwind.into_option() };
target,
unwind: unwind.into_option(),
};
self.new_block(unwind, block) self.new_block(unwind, block)
} }
@ -982,9 +978,6 @@ where
} }
fn assign(&self, lhs: &Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> { fn assign(&self, lhs: &Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> {
Statement { Statement { source_info: self.source_info, kind: StatementKind::Assign(box (*lhs, rhs)) }
source_info: self.source_info,
kind: StatementKind::Assign(box (lhs.clone(), rhs)),
}
} }
} }

View file

@ -39,7 +39,7 @@ impl<'tcx> CFG<'tcx> {
) { ) {
self.push( self.push(
block, block,
Statement { source_info, kind: StatementKind::Assign(box (place.clone(), rvalue)) }, Statement { source_info, kind: StatementKind::Assign(box (*place, rvalue)) },
); );
} }

View file

@ -219,7 +219,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
source_info, source_info,
kind: StatementKind::AscribeUserType( kind: StatementKind::AscribeUserType(
box ( box (
Place::from(temp.clone()), Place::from(temp),
UserTypeProjection { base: annotation_index, projs: vec![] }, UserTypeProjection { base: annotation_index, projs: vec![] },
), ),
Variance::Invariant, Variance::Invariant,
@ -347,11 +347,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block, block,
source_info, source_info,
&lt, &lt,
Rvalue::BinaryOp( Rvalue::BinaryOp(BinOp::Lt, Operand::Copy(Place::from(index)), Operand::Copy(len)),
BinOp::Lt,
Operand::Copy(Place::from(index)),
Operand::Copy(len.clone()),
),
); );
let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) }; let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };
// assert!(lt, "...") // assert!(lt, "...")
@ -396,7 +392,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Rvalue::Ref( Rvalue::Ref(
tcx.lifetimes.re_erased, tcx.lifetimes.re_erased,
BorrowKind::Shallow, BorrowKind::Shallow,
Place { local: base_place.local.clone(), projection }, Place { local: base_place.local, projection },
), ),
); );
fake_borrow_temps.push(fake_borrow_temp); fake_borrow_temps.push(fake_borrow_temp);

View file

@ -228,7 +228,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
destination: if expr.ty.is_never() { destination: if expr.ty.is_never() {
None None
} else { } else {
Some((destination.clone(), success)) Some((*destination, success))
}, },
from_hir_call, from_hir_call,
}, },

View file

@ -79,14 +79,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// because AssignOp is only legal for Copy types // because AssignOp is only legal for Copy types
// (overloaded ops should be desugared into a call). // (overloaded ops should be desugared into a call).
let result = unpack!( let result = unpack!(
block = this.build_binary_op( block =
block, this.build_binary_op(block, op, expr_span, lhs_ty, Operand::Copy(lhs), rhs)
op,
expr_span,
lhs_ty,
Operand::Copy(lhs.clone()),
rhs
)
); );
this.cfg.push_assign(block, source_info, &lhs, result); this.cfg.push_assign(block, source_info, &lhs, result);

View file

@ -166,7 +166,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.zip(candidate_pre_binding_blocks.by_ref()) .zip(candidate_pre_binding_blocks.by_ref())
.map(|(pattern, pre_binding_block)| Candidate { .map(|(pattern, pre_binding_block)| Candidate {
span: pattern.span, span: pattern.span,
match_pairs: smallvec![MatchPair::new(scrutinee.clone(), pattern)], match_pairs: smallvec![MatchPair::new(*scrutinee, pattern)],
bindings: vec![], bindings: vec![],
ascriptions: vec![], ascriptions: vec![],
otherwise_block: if arm_has_guard { otherwise_block: if arm_has_guard {
@ -427,7 +427,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// create a dummy candidate // create a dummy candidate
let mut candidate = Candidate { let mut candidate = Candidate {
span: irrefutable_pat.span, span: irrefutable_pat.span,
match_pairs: smallvec![MatchPair::new(initializer.clone(), &irrefutable_pat)], match_pairs: smallvec![MatchPair::new(*initializer, &irrefutable_pat)],
bindings: vec![], bindings: vec![],
ascriptions: vec![], ascriptions: vec![],
@ -469,7 +469,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.. ..
}))) = self.local_decls[local].local_info }))) = self.local_decls[local].local_info
{ {
*match_place = Some(initializer.clone()); *match_place = Some(*initializer);
} else { } else {
bug!("Let binding to non-user variable.") bug!("Let binding to non-user variable.")
} }
@ -890,7 +890,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let proj_base = &source.projection[..i]; let proj_base = &source.projection[..i];
fake_borrows.insert(Place { fake_borrows.insert(Place {
local: source.local.clone(), local: source.local,
projection: self.hir.tcx().intern_place_elems(proj_base), 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 // extract the match-pair from the highest priority candidate
let match_pair = &candidates.first().unwrap().match_pairs[0]; let match_pair = &candidates.first().unwrap().match_pairs[0];
let mut test = self.test(match_pair); 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 // most of the time, the test to perform is simply a function
// of the main candidate; but for a test like SwitchInt, we // of the main candidate; but for a test like SwitchInt, we
@ -1258,7 +1258,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.into_iter() .into_iter()
.map(|matched_place_ref| { .map(|matched_place_ref| {
let matched_place = Place { let matched_place = Place {
local: matched_place_ref.local.clone(), local: *matched_place_ref.local,
projection: tcx.intern_place_elems(matched_place_ref.projection), projection: tcx.intern_place_elems(matched_place_ref.projection),
}; };
let fake_borrow_deref_ty = matched_place.ty(&self.local_decls, tcx).ty; 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 re_erased = tcx.lifetimes.re_erased;
let scrutinee_source_info = self.source_info(scrutinee_span); let scrutinee_source_info = self.source_info(scrutinee_span);
for (place, temp) in fake_borrows { 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); self.cfg.push_assign(block, scrutinee_source_info, &Place::from(*temp), borrow);
} }
@ -1514,7 +1514,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Statement { Statement {
source_info, source_info,
kind: StatementKind::AscribeUserType( kind: StatementKind::AscribeUserType(
box (ascription.source.clone(), user_ty), box (ascription.source, user_ty),
ascription.variance, ascription.variance,
), ),
}, },
@ -1540,7 +1540,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.storage_live_binding(block, binding.var_id, binding.span, RefWithinGuard); self.storage_live_binding(block, binding.var_id, binding.span, RefWithinGuard);
match binding.binding_mode { match binding.binding_mode {
BindingMode::ByValue => { 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); self.cfg.push_assign(block, source_info, &ref_for_guard, rvalue);
} }
BindingMode::ByRef(borrow_kind) => { BindingMode::ByRef(borrow_kind) => {
@ -1551,7 +1551,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
OutsideGuard, 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); self.cfg.push_assign(block, source_info, &value_for_arm, rvalue);
let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, value_for_arm); let rvalue = Rvalue::Ref(re_erased, BorrowKind::Shared, value_for_arm);
self.cfg.push_assign(block, source_info, &ref_for_guard, rvalue); 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())) Rvalue::Use(self.consume_by_copy_or_move(binding.source.clone()))
} }
BindingMode::ByRef(borrow_kind) => { 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); self.cfg.push_assign(block, source_info, &local, rvalue);

View file

@ -59,14 +59,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
match *match_pair.pattern.kind { match *match_pair.pattern.kind {
PatKind::AscribeUserType { PatKind::AscribeUserType {
ref subpattern, 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 // Apply the type ascription to the value at `match_pair.place`, which is the
// value being matched, taking the variance field into account. // value being matched, taking the variance field into account.
candidate.ascriptions.push(Ascription { candidate.ascriptions.push(Ascription {
span: user_ty_span, span: user_ty_span,
user_ty: user_ty.clone(), user_ty: user_ty,
source: match_pair.place.clone(), source: match_pair.place,
variance, variance,
}); });
@ -85,7 +85,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
name, name,
mutability, mutability,
span: match_pair.pattern.span, span: match_pair.pattern.span,
source: match_pair.place.clone(), source: match_pair.place,
var_id: var, var_id: var,
var_ty: ty, var_ty: ty,
binding_mode: mode, binding_mode: mode,

View file

@ -209,12 +209,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
); );
let discr_ty = adt_def.repr.discr_type().to_ty(tcx); let discr_ty = adt_def.repr.discr_type().to_ty(tcx);
let discr = self.temp(discr_ty, test.span); let discr = self.temp(discr_ty, test.span);
self.cfg.push_assign( self.cfg.push_assign(block, source_info, &discr, Rvalue::Discriminant(*place));
block,
source_info,
&discr,
Rvalue::Discriminant(place.clone()),
);
assert_eq!(values.len() + 1, targets.len()); assert_eq!(values.len() + 1, targets.len());
self.cfg.terminate( self.cfg.terminate(
block, block,
@ -240,7 +235,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}; };
TerminatorKind::if_( TerminatorKind::if_(
self.hir.tcx(), self.hir.tcx(),
Operand::Copy(place.clone()), Operand::Copy(*place),
true_bb, true_bb,
false_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 // The switch may be inexhaustive so we have a catch all block
debug_assert_eq!(options.len() + 1, target_blocks.len()); debug_assert_eq!(options.len() + 1, target_blocks.len());
TerminatorKind::SwitchInt { TerminatorKind::SwitchInt {
discr: Operand::Copy(place.clone()), discr: Operand::Copy(*place),
switch_ty, switch_ty,
values: options.clone().into(), values: options.clone().into(),
targets: target_blocks, targets: target_blocks,
@ -276,7 +271,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if let [success, fail] = *make_target_blocks(self) { if let [success, fail] = *make_target_blocks(self) {
assert_eq!(value.ty, ty); assert_eq!(value.ty, ty);
let expect = self.literal_operand(test.span, value); 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); self.compare(block, success, fail, source_info, BinOp::Eq, expect, val);
} else { } else {
bug!("`TestKind::Eq` should have two target blocks"); 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. // Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
let lo = self.literal_operand(test.span, lo); let lo = self.literal_operand(test.span, lo);
let hi = self.literal_operand(test.span, hi); 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 { if let [success, fail] = *target_blocks {
self.compare( self.compare(
@ -320,7 +315,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let actual = self.temp(usize_ty, test.span); let actual = self.temp(usize_ty, test.span);
// actual = len(place) // 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 = <N> // expected = <N>
let expected = self.push_usize(block, source_info, len); 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; use rustc::middle::lang_items::EqTraitLangItem;
let mut expect = self.literal_operand(source_info.span, value); 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 // If we're using `b"..."` as a pattern, we need to insert an
// unsizing coercion, as the byte string has the type `&[u8; N]`. // unsizing coercion, as the byte string has the type `&[u8; N]`.
@ -457,7 +452,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
literal: method, literal: method,
}), }),
args: vec![val, expect], args: vec![val, expect],
destination: Some((eq_result.clone(), eq_block)), destination: Some((eq_result, eq_block)),
cleanup: Some(cleanup), cleanup: Some(cleanup),
from_hir_call: false, from_hir_call: false,
}, },

View file

@ -884,7 +884,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
VarBindingForm { VarBindingForm {
binding_mode, binding_mode,
opt_ty_info, opt_ty_info,
opt_match_place: Some((Some(place.clone()), span)), opt_match_place: Some((Some(place), span)),
pat_span: span, pat_span: span,
}, },
))) )))
@ -939,12 +939,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn get_unit_temp(&mut self) -> Place<'tcx> { fn get_unit_temp(&mut self) -> Place<'tcx> {
match self.unit_temp { match self.unit_temp {
Some(ref tmp) => tmp.clone(), Some(tmp) => tmp,
None => { None => {
let ty = self.hir.unit_ty(); let ty = self.hir.unit_ty();
let fn_span = self.fn_span; let fn_span = self.fn_span;
let tmp = self.temp(ty, fn_span); let tmp = self.temp(ty, fn_span);
self.unit_temp = Some(tmp.clone()); self.unit_temp = Some(tmp);
tmp tmp
} }
} }

View file

@ -318,11 +318,11 @@ impl<'tcx> Scopes<'tcx> {
if scope.break_destination != Place::return_place() { if scope.break_destination != Place::return_place() {
span_bug!(span, "`return` in item with no return scope"); 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) => { BreakableTarget::Break(scope) => {
let scope = get_scope(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) => { BreakableTarget::Continue(scope) => {
let scope = get_scope(scope); let scope = get_scope(scope);

View file

@ -366,8 +366,8 @@ fn new_index(tcx: TyCtxt<'tcx>) -> Index<'tcx> {
// Put the active features into a map for quick lookup. // Put the active features into a map for quick lookup.
index.active_features = active_lib_features index.active_features = active_lib_features
.iter() .iter()
.map(|&(ref s, ..)| s.clone()) .map(|&(s, ..)| s)
.chain(active_lang_features.iter().map(|&(ref s, ..)| s.clone())) .chain(active_lang_features.iter().map(|&(s, ..)| s))
.collect(); .collect();
{ {

View file

@ -263,7 +263,7 @@ fn crate_disambiguator(tcx: TyCtxt<'_>, crate_num: CrateNum) -> CrateDisambiguat
fn original_crate_name(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Symbol { fn original_crate_name(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Symbol {
assert_eq!(crate_num, LOCAL_CRATE); assert_eq!(crate_num, LOCAL_CRATE);
tcx.crate_name.clone() tcx.crate_name
} }
fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {

View file

@ -572,7 +572,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
has_unsized_tuple_coercion = true; has_unsized_tuple_coercion = true;
} }
} }
tr.clone() *tr
} }
_ => { _ => {
coercion.obligations.push(obligation); coercion.obligations.push(obligation);

View file

@ -596,7 +596,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
target_trait_def_id: DefId, target_trait_def_id: DefId,
) -> ty::PolyTraitRef<'tcx> { ) -> ty::PolyTraitRef<'tcx> {
let upcast_trait_refs = 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 // must be exactly one trait ref or we'd get an ambig error etc
if upcast_trait_refs.len() != 1 { if upcast_trait_refs.len() != 1 {

View file

@ -1491,7 +1491,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
// FIXME: check the return type here somehow. // FIXME: check the return type here somehow.
// If so, just use this trait and call it a day. // If so, just use this trait and call it a day.
Some(Pick { Some(Pick {
item: probes[0].0.item.clone(), item: probes[0].0.item,
kind: TraitPick, kind: TraitPick,
import_ids: probes[0].0.import_ids.clone(), import_ids: probes[0].0.import_ids.clone(),
autoderefs: 0, autoderefs: 0,
@ -1715,7 +1715,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
impl<'tcx> Candidate<'tcx> { impl<'tcx> Candidate<'tcx> {
fn to_unadjusted_pick(&self) -> Pick<'tcx> { fn to_unadjusted_pick(&self) -> Pick<'tcx> {
Pick { Pick {
item: self.item.clone(), item: self.item,
kind: match self.kind { kind: match self.kind {
InherentImplCandidate(..) => InherentImplPick, InherentImplCandidate(..) => InherentImplPick,
ObjectCandidate => ObjectPick, ObjectCandidate => ObjectPick,
@ -1731,7 +1731,7 @@ impl<'tcx> Candidate<'tcx> {
&& !trait_ref.skip_binder().substs.has_placeholders() && !trait_ref.skip_binder().substs.has_placeholders()
); );
WhereClausePick(trait_ref.clone()) WhereClausePick(*trait_ref)
} }
}, },
import_ids: self.import_ids.clone(), import_ids: self.import_ids.clone(),

View file

@ -1208,8 +1208,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
debug!( debug!(
"local variable {:?} is assigned type {}", "local variable {:?} is assigned type {}",
local.pat, local.pat,
self.fcx self.fcx.ty_to_string(&*self.fcx.locals.borrow().get(&local.hir_id).unwrap().decl_ty)
.ty_to_string(self.fcx.locals.borrow().get(&local.hir_id).unwrap().clone().decl_ty)
); );
intravisit::walk_local(self, local); intravisit::walk_local(self, local);
} }
@ -1226,8 +1225,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
debug!( debug!(
"pattern binding {} is assigned to {} with type {:?}", "pattern binding {} is assigned to {} with type {:?}",
ident, ident,
self.fcx self.fcx.ty_to_string(&*self.fcx.locals.borrow().get(&p.hir_id).unwrap().decl_ty),
.ty_to_string(self.fcx.locals.borrow().get(&p.hir_id).unwrap().clone().decl_ty),
var_ty var_ty
); );
} }
@ -1275,7 +1273,7 @@ fn check_fn<'a, 'tcx>(
body: &'tcx hir::Body<'tcx>, body: &'tcx hir::Body<'tcx>,
can_be_generator: Option<hir::Movability>, can_be_generator: Option<hir::Movability>,
) -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) { ) -> (FnCtxt<'a, 'tcx>, Option<GeneratorTypes<'tcx>>) {
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); debug!("check_fn(sig={:?}, fn_id={}, param_env={:?})", fn_sig, fn_id, param_env);

View file

@ -499,7 +499,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
let fn_sig = { let fn_sig = {
match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(hir_id) { match self.tcx.typeck_tables_of(def_id).liberated_fn_sigs().get(hir_id) {
Some(f) => f.clone(), Some(f) => *f,
None => { None => {
bug!("No fn-sig entry for def_id={:?}", def_id); bug!("No fn-sig entry for def_id={:?}", def_id);
} }

View file

@ -306,7 +306,7 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
let fn_sig = { let fn_sig = {
match self.tables.borrow().liberated_fn_sigs().get(id) { match self.tables.borrow().liberated_fn_sigs().get(id) {
Some(f) => f.clone(), Some(f) => *f,
None => { None => {
bug!("No fn-sig entry for id={:?}", id); bug!("No fn-sig entry for id={:?}", id);
} }

View file

@ -181,7 +181,7 @@ pub fn setup_constraining_predicates<'tcx>(
// to project out an associated type defined by this very // to project out an associated type defined by this very
// trait. // trait.
let unbound_trait_ref = projection.projection_ty.trait_ref(tcx); 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; continue;
} }

View file

@ -393,7 +393,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
Type::ResolvedPath { Type::ResolvedPath {
path: new_path, path: new_path,
param_names: param_names.clone(), param_names: param_names.clone(),
did: did.clone(), did: *did,
is_generic: *is_generic, is_generic: *is_generic,
} }
} }
@ -468,7 +468,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
}) })
.map(|p| { .map(|p| {
let replaced = p.fold_with(&mut replacer); let replaced = p.fold_with(&mut replacer);
(replaced.clone(), replaced.clean(self.cx)) (replaced, replaced.clean(self.cx))
}); });
let mut generic_params = let mut generic_params =
@ -614,7 +614,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
trait_: Type::ResolvedPath { trait_: Type::ResolvedPath {
path: new_trait_path, path: new_trait_path,
param_names: param_names.clone(), param_names: param_names.clone(),
did: did.clone(), did: *did,
is_generic: *is_generic, is_generic: *is_generic,
}, },
generic_params: Vec::new(), generic_params: Vec::new(),

View file

@ -1417,7 +1417,7 @@ impl Clean<Type> for hir::Ty<'_> {
}); });
if let Some(ty) = type_ { if let Some(ty) = type_ {
ty_substs.insert(ty_param_def_id, ty.clean(cx)); 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)); ty_substs.insert(ty_param_def_id, default.clean(cx));
} }
indices.types += 1; indices.types += 1;

View file

@ -319,7 +319,7 @@ pub fn strip_path(path: &Path) -> Path {
}) })
.collect(); .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 { pub fn qpath_to_string(p: &hir::QPath) -> String {

View file

@ -125,7 +125,7 @@ impl<'tcx> DocContext<'tcx> {
let mut fake_ids = self.fake_def_ids.borrow_mut(); 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( fake_ids.insert(
crate_num, crate_num,
DefId { krate: crate_num, index: DefIndex::from(def_id.index.index() + 1) }, 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); 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. /// Like the function of the same name on the HIR map, but skips calling it on fake DefIds.

@ -1 +1 @@
Subproject commit b68b0978ab8012f871c80736fb910d14b89c4498 Subproject commit 9d32b7b01409024b165545c568b1525d86e2b7cb

@ -1 +1 @@
Subproject commit 6a0f14bef7784e57a57a996cae3f94dbd2490e7a Subproject commit 83403581bb7a2156f4752fc2d0ceef4b3ec75554