Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't clone types that are copy #68292

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ impl<'tcx> ObligationCause<'tcx> {
TypeError::IntrinsicCast => {
Error0308("cannot coerce intrinsics to function pointers")
}
TypeError::ObjectUnsafeCoercion(did) => Error0038(did.clone()),
TypeError::ObjectUnsafeCoercion(did) => Error0038(*did),
_ => Error0308("mismatched types"),
},
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,18 +909,18 @@ impl<'hir> LoweringContext<'_, 'hir> {

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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ impl<'a> TraitDef<'a> {
} 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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl AnnotateSnippetEmitterWriter {
) {
let converter = DiagnosticConverter {
source_map: self.source_map.clone(),
level: level.clone(),
level: *level,
message,
code: code.clone(),
msp: msp.clone(),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/persist/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl LintStore {

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));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ impl<'a, 'tcx> CrateMetadata {

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)),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ impl<'tcx> EncodeContext<'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
},
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/borrow_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
// 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
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_traits/chalk_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl context::UnificationOps<ChalkArenas<'tcx>, ChalkArenas<'tcx>>
&mut self,
value: &Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>,
) -> (Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>, UniverseMap) {
(value.clone(), UniverseMap)
(*value, UniverseMap)
}

fn invert_goal(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
// 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() {
Expand Down
4 changes: 1 addition & 3 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,7 @@ pub fn run_test(
}
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 {
Expand Down