don't clone types that are copy

found via clippy
This commit is contained in:
Matthias Krüger 2020-01-16 23:15:52 +01:00
parent 4884061838
commit 7fbd30b1ae
15 changed files with 18 additions and 20 deletions

View File

@ -2008,7 +2008,7 @@ fn as_failure_code(&self, terr: &TypeError<'tcx>) -> FailureCode {
TypeError::IntrinsicCast => {
Error0308("cannot coerce intrinsics to function pointers")
}
TypeError::ObjectUnsafeCoercion(did) => Error0038(did.clone()),
TypeError::ObjectUnsafeCoercion(did) => Error0038(*did),
_ => Error0308("mismatched types"),
},
}

View File

@ -909,18 +909,18 @@ fn with_loop_condition_scope<T, F>(&mut self, f: F) -> T
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind<'hir> {
let inner = hir::InlineAsmInner {
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
outputs: asm
.outputs
.iter()
.map(|out| hir::InlineAsmOutput {
constraint: out.constraint.clone(),
constraint: out.constraint,
is_rw: out.is_rw,
is_indirect: out.is_indirect,
span: out.expr.span,
})
.collect(),
asm: asm.asm.clone(),
asm: asm.asm,
asm_str_style: asm.asm_str_style,
clobbers: asm.clobbers.clone().into(),
volatile: asm.volatile,

View File

@ -1608,7 +1608,7 @@ fn create_subpatterns(
} else {
ast::BindingMode::ByRef(mutbl)
};
cx.pat(path.span, PatKind::Ident(binding_mode, (*path).clone(), None))
cx.pat(path.span, PatKind::Ident(binding_mode, *path, None))
})
.collect()
}

View File

@ -196,7 +196,7 @@ fn emit_messages_default(
) {
let converter = DiagnosticConverter {
source_map: self.source_map.clone(),
level: level.clone(),
level: *level,
message,
code: code.clone(),
msp: msp.clone(),

View File

@ -236,7 +236,7 @@ fn encode_work_product_index(
let serialized_products: Vec<_> = work_products
.iter()
.map(|(id, work_product)| SerializedWorkProduct {
id: id.clone(),
id: *id,
work_product: work_product.clone(),
})
.collect();

View File

@ -245,7 +245,7 @@ pub fn register_group(
pub fn register_renamed(&mut self, old_name: &str, new_name: &str) {
let target = match self.by_name.get(new_name) {
Some(&Id(lint_id)) => lint_id.clone(),
Some(&Id(lint_id)) => lint_id,
_ => bug!("invalid lint renaming of {} to {}", old_name, new_name),
};
self.by_name.insert(old_name.to_string(), Renamed(new_name.to_string(), target));

View File

@ -840,7 +840,7 @@ fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
match self.is_proc_macro(id) {
true => self.root.proc_macro_stability.clone(),
true => self.root.proc_macro_stability,
false => self.root.per_def.stability.get(self, id).map(|stab| stab.decode(self)),
}
}

View File

@ -504,7 +504,7 @@ fn encode_crate_root(&mut self) -> Lazy<CrateRoot<'tcx>> {
},
proc_macro_data,
proc_macro_stability: if is_proc_macro {
tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| stab.clone())
tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).map(|stab| *stab)
} else {
None
},

View File

@ -200,8 +200,8 @@ fn visit_assign(
region,
reserve_location: location,
activation_location: TwoPhaseActivation::NotTwoPhase,
borrowed_place: borrowed_place.clone(),
assigned_place: assigned_place.clone(),
borrowed_place: *borrowed_place,
assigned_place: *assigned_place,
};
let idx = self.idx_vec.push(borrow);
self.location_map.insert(location, idx);

View File

@ -65,7 +65,7 @@ fn mir_build(tcx: TyCtxt<'_>, def_id: DefId) -> BodyAndCache<'_> {
} else if cx.body_owner_kind.is_fn_or_closure() {
// fetch the fully liberated fn signature (that is, all bound
// types/lifetimes replaced)
let fn_sig = cx.tables().liberated_fn_sigs()[id].clone();
let fn_sig = cx.tables().liberated_fn_sigs()[id];
let fn_def_id = tcx.hir().local_def_id(id);
let ty = tcx.type_of(fn_def_id);

View File

@ -91,7 +91,7 @@ fn annotate<F>(
// deprecated_since and its reason.
if let Some(parent_stab) = self.parent_stab {
if parent_stab.rustc_depr.is_some() && stab.rustc_depr.is_none() {
stab.rustc_depr = parent_stab.rustc_depr.clone()
stab.rustc_depr = parent_stab.rustc_depr
}
}

View File

@ -400,7 +400,7 @@ fn u_canonicalize_goal(
&mut self,
value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>,
) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) {
(value.clone(), UniverseMap)
(*value, UniverseMap)
}
fn invert_goal(

View File

@ -175,7 +175,7 @@ fn deduce_expectations_from_expected_type(
}
ty::Infer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid),
ty::FnPtr(sig) => {
let expected_sig = ExpectedSig { cause_span: None, sig: sig.skip_binder().clone() };
let expected_sig = ExpectedSig { cause_span: None, sig: *sig.skip_binder() };
(Some(expected_sig), Some(ty::ClosureKind::Fn))
}
_ => (None, None),

View File

@ -239,7 +239,7 @@ fn handle_lifetimes<'cx>(
// constraint, and add it to our list. Since we make sure to never re-add
// deleted items, this process will always finish.
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

@ -485,9 +485,7 @@ fn run_test_inner(
}
StaticBenchFn(benchfn) => {
// Benchmarks aren't expected to panic, so we run them all in-process.
crate::bench::benchmark(desc, monitor_ch, opts.nocapture, |harness| {
(benchfn.clone())(harness)
});
crate::bench::benchmark(desc, monitor_ch, opts.nocapture, benchfn);
}
DynTestFn(f) => {
match strategy {