Rollup merge of #68459 - matthiaskrgr:clone_on_copy2, r=eddyb

don't clone types that are copy, round two.

Apparently fixing some of these issues makes clippy find even more so I did a couple of rounds now.

r? @eddyb
This commit is contained in:
Mark Rousskov 2020-01-27 13:42:00 -05:00 committed by GitHub
commit aa6e58b352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 155 additions and 192 deletions

View File

@ -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(),
)
}

View File

@ -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: {:?}",

View File

@ -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(),
)
}

View File

@ -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(),
)
}

View File

@ -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<F: TypeFolder<'tcx>>(&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<R, C> {
impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(&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),
}

View File

@ -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()))
}
}

View File

@ -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() {

View File

@ -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();

View File

@ -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,

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>`.
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<Vec<PredicateObligation<'tcx>>, 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)

View File

@ -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()
}

View File

@ -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();

View File

@ -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),

View File

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

View File

@ -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() })
}
}

View File

@ -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<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:
// 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 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(

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);
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,
));

View File

@ -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,

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
// 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

View File

@ -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

View File

@ -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),
}
}
}

View File

@ -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));
}
};
}

View File

@ -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(

View File

@ -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))),
))),
];

View File

@ -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 },

View File

@ -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,

View File

@ -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

View File

@ -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) },
);
}
}

View File

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

View File

@ -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)

View File

@ -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

View File

@ -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,
});

View File

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

View File

@ -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)) },
);
}

View File

@ -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,
&lt,
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);

View File

@ -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,
},

View File

@ -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);

View File

@ -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);

View File

@ -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,

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 = 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 = <N>
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,
},

View File

@ -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
}
}

View File

@ -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);

View File

@ -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();
{

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 {
assert_eq!(crate_num, LOCAL_CRATE);
tcx.crate_name.clone()
tcx.crate_name
}
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;
}
}
tr.clone()
*tr
}
_ => {
coercion.obligations.push(obligation);

View File

@ -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 {

View File

@ -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(),

View File

@ -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<hir::Movability>,
) -> (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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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(),

View File

@ -1417,7 +1417,7 @@ impl Clean<Type> 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;

View File

@ -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 {

View File

@ -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.