mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
don't clone types that are Copy (clippy::clone_on_copy)
This commit is contained in:
parent
22719efcc5
commit
c1e96085d3
@ -1739,7 +1739,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
category: constraint.category,
|
||||
from_closure: false,
|
||||
span,
|
||||
variance_info: constraint.variance_info.clone(),
|
||||
variance_info: constraint.variance_info,
|
||||
};
|
||||
}
|
||||
Locations::Single(loc) => loc,
|
||||
@ -1752,13 +1752,13 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
category,
|
||||
from_closure: true,
|
||||
span: span,
|
||||
variance_info: constraint.variance_info.clone(),
|
||||
variance_info: constraint.variance_info,
|
||||
})
|
||||
.unwrap_or(BlameConstraint {
|
||||
category: constraint.category,
|
||||
from_closure: false,
|
||||
span: body.source_info(loc).span,
|
||||
variance_info: constraint.variance_info.clone(),
|
||||
variance_info: constraint.variance_info,
|
||||
})
|
||||
}
|
||||
|
||||
@ -2001,7 +2001,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
category: constraint.category,
|
||||
from_closure: false,
|
||||
span: constraint.locations.span(body),
|
||||
variance_info: constraint.variance_info.clone(),
|
||||
variance_info: constraint.variance_info,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -519,7 +519,7 @@ where
|
||||
|
||||
let old_ambient_variance = self.ambient_variance;
|
||||
self.ambient_variance = self.ambient_variance.xform(variance);
|
||||
self.ambient_variance_info = self.ambient_variance_info.clone().xform(info);
|
||||
self.ambient_variance_info = self.ambient_variance_info.xform(info);
|
||||
|
||||
debug!("relate_with_variance: ambient_variance = {:?}", self.ambient_variance);
|
||||
|
||||
@ -597,12 +597,12 @@ where
|
||||
|
||||
if self.ambient_covariance() {
|
||||
// Covariance: a <= b. Hence, `b: a`.
|
||||
self.push_outlives(v_b, v_a, self.ambient_variance_info.clone());
|
||||
self.push_outlives(v_b, v_a, self.ambient_variance_info);
|
||||
}
|
||||
|
||||
if self.ambient_contravariance() {
|
||||
// Contravariant: b <= a. Hence, `a: b`.
|
||||
self.push_outlives(v_a, v_b, self.ambient_variance_info.clone());
|
||||
self.push_outlives(v_a, v_b, self.ambient_variance_info);
|
||||
}
|
||||
|
||||
Ok(a)
|
||||
|
@ -448,7 +448,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
||||
span_idx = Some(syn::Index::from(idx));
|
||||
} else {
|
||||
throw_span_err!(
|
||||
info.span.clone().unwrap(),
|
||||
info.span.unwrap(),
|
||||
"type of field annotated with `#[suggestion(...)]` contains more than one Span"
|
||||
);
|
||||
}
|
||||
@ -460,7 +460,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
||||
applicability_idx = Some(syn::Index::from(idx));
|
||||
} else {
|
||||
throw_span_err!(
|
||||
info.span.clone().unwrap(),
|
||||
info.span.unwrap(),
|
||||
"type of field annotated with `#[suggestion(...)]` contains more than one Applicability"
|
||||
);
|
||||
}
|
||||
@ -479,7 +479,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
||||
return Ok((span, applicability));
|
||||
}
|
||||
throw_span_err!(
|
||||
info.span.clone().unwrap(),
|
||||
info.span.unwrap(),
|
||||
"wrong types for suggestion",
|
||||
|diag| {
|
||||
diag.help("#[suggestion(...)] on a tuple field must be applied to fields of type (Span, Applicability)")
|
||||
@ -487,7 +487,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
|
||||
);
|
||||
}
|
||||
_ => throw_span_err!(
|
||||
info.span.clone().unwrap(),
|
||||
info.span.unwrap(),
|
||||
"wrong field type for suggestion",
|
||||
|diag| {
|
||||
diag.help("#[suggestion(...)] should be applied to fields of type Span or (Span, Applicability)")
|
||||
|
@ -2060,7 +2060,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
source_info.span, ascription.source, ascription.user_ty,
|
||||
);
|
||||
|
||||
let user_ty = ascription.user_ty.clone().user_ty(
|
||||
let user_ty = ascription.user_ty.user_ty(
|
||||
&mut self.canonical_user_type_annotations,
|
||||
ascription.source.ty(&self.local_decls, self.tcx).ty,
|
||||
source_info.span,
|
||||
|
@ -75,13 +75,11 @@ fn lower_slice_len_call<'tcx>(
|
||||
let deref_arg = tcx.mk_place_deref(arg);
|
||||
let r_value = Rvalue::Len(deref_arg);
|
||||
let len_statement_kind = StatementKind::Assign(Box::new((*dest, r_value)));
|
||||
let add_statement = Statement {
|
||||
kind: len_statement_kind,
|
||||
source_info: terminator.source_info.clone(),
|
||||
};
|
||||
let add_statement =
|
||||
Statement { kind: len_statement_kind, source_info: terminator.source_info };
|
||||
|
||||
// modify terminator into simple Goto
|
||||
let new_terminator_kind = TerminatorKind::Goto { target: bb.clone() };
|
||||
let new_terminator_kind = TerminatorKind::Goto { target: *bb };
|
||||
|
||||
let patch = SliceLenPatchInformation { add_statement, new_terminator_kind };
|
||||
|
||||
|
@ -1487,7 +1487,7 @@ impl<'a> Resolver<'a> {
|
||||
.iter()
|
||||
.map(|(ident, entry)| (ident.name, entry.introduced_by_item))
|
||||
.collect(),
|
||||
main_def: self.main_def.clone(),
|
||||
main_def: self.main_def,
|
||||
trait_impls: self.trait_impls.clone(),
|
||||
proc_macros,
|
||||
confused_type_with_std_module: self.confused_type_with_std_module.clone(),
|
||||
|
@ -1357,9 +1357,7 @@ fn for_all_expns_in<E>(
|
||||
mut f: impl FnMut(ExpnId, &ExpnData, ExpnHash) -> Result<(), E>,
|
||||
) -> Result<(), E> {
|
||||
let all_data: Vec<_> = HygieneData::with(|data| {
|
||||
expns
|
||||
.map(|expn| (expn, data.expn_data(expn).clone(), data.expn_hash(expn).clone()))
|
||||
.collect()
|
||||
expns.map(|expn| (expn, data.expn_data(expn).clone(), data.expn_hash(expn))).collect()
|
||||
});
|
||||
for (expn, data, hash) in all_data.into_iter() {
|
||||
f(expn, &data, hash)?;
|
||||
|
@ -249,10 +249,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
if let ObligationCauseCode::WellFormed(Some(wf_loc)) =
|
||||
root_obligation.cause.code.peel_derives()
|
||||
{
|
||||
if let Some(cause) = self.tcx.diagnostic_hir_wf_check((
|
||||
tcx.erase_regions(obligation.predicate),
|
||||
wf_loc.clone(),
|
||||
)) {
|
||||
if let Some(cause) = self
|
||||
.tcx
|
||||
.diagnostic_hir_wf_check((tcx.erase_regions(obligation.predicate), *wf_loc))
|
||||
{
|
||||
obligation.cause = cause;
|
||||
span = obligation.cause.span;
|
||||
}
|
||||
|
@ -595,7 +595,7 @@ impl TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
|
||||
ty::ReLateBound(debruijn, br) if debruijn >= self.current_index => {
|
||||
let universe = self.universe_for(debruijn);
|
||||
let p = ty::PlaceholderRegion { universe, name: br.kind };
|
||||
self.mapped_regions.insert(p.clone(), br);
|
||||
self.mapped_regions.insert(p, br);
|
||||
self.infcx.tcx.mk_region(ty::RePlaceholder(p))
|
||||
}
|
||||
_ => r,
|
||||
@ -613,7 +613,7 @@ impl TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
|
||||
ty::Bound(debruijn, bound_ty) if debruijn >= self.current_index => {
|
||||
let universe = self.universe_for(debruijn);
|
||||
let p = ty::PlaceholderType { universe, name: bound_ty.var };
|
||||
self.mapped_types.insert(p.clone(), bound_ty);
|
||||
self.mapped_types.insert(p, bound_ty);
|
||||
self.infcx.tcx.mk_ty(ty::Placeholder(p))
|
||||
}
|
||||
_ if t.has_vars_bound_at_or_above(self.current_index) => t.super_fold_with(self),
|
||||
@ -637,7 +637,7 @@ impl TypeFolder<'tcx> for BoundVarReplacer<'_, 'tcx> {
|
||||
universe,
|
||||
name: ty::BoundConst { var: bound_const, ty },
|
||||
};
|
||||
self.mapped_consts.insert(p.clone(), bound_const);
|
||||
self.mapped_consts.insert(p, bound_const);
|
||||
self.infcx.tcx.mk_const(ty::Const { val: ty::ConstKind::Placeholder(p), ty })
|
||||
}
|
||||
_ if ct.has_vars_bound_at_or_above(self.current_index) => ct.super_fold_with(self),
|
||||
|
@ -2445,7 +2445,7 @@ impl<'tcx> ProvisionalEvaluationCache<'tcx> {
|
||||
"get_provisional = {:#?}",
|
||||
self.map.borrow().get(&fresh_trait_ref),
|
||||
);
|
||||
Some(self.map.borrow().get(&fresh_trait_ref)?.clone())
|
||||
Some(*self.map.borrow().get(&fresh_trait_ref)?)
|
||||
}
|
||||
|
||||
/// Insert a provisional result into the cache. The result came
|
||||
|
@ -186,7 +186,7 @@ pub enum AutorefOrPtrAdjustment<'tcx> {
|
||||
impl<'tcx> AutorefOrPtrAdjustment<'tcx> {
|
||||
fn get_unsize(&self) -> Option<Ty<'tcx>> {
|
||||
match self {
|
||||
AutorefOrPtrAdjustment::Autoref { mutbl: _, unsize } => unsize.clone(),
|
||||
AutorefOrPtrAdjustment::Autoref { mutbl: _, unsize } => *unsize,
|
||||
AutorefOrPtrAdjustment::ToConstPtr => None,
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
|
||||
// Because the testsuit node holds some of the information as attributes, we can't write it
|
||||
// until all of the tests has ran. Instead of writting every result as they come in, we add
|
||||
// them to a Vec and write them all at once when run is complete.
|
||||
let duration = exec_time.map(|t| t.0.clone()).unwrap_or_default();
|
||||
let duration = exec_time.map(|t| t.0).unwrap_or_default();
|
||||
self.results.push((desc.clone(), result.clone(), duration));
|
||||
Ok(())
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ impl Item {
|
||||
.filter_map(|ItemLink { link: s, link_text, did, ref fragment }| {
|
||||
match did {
|
||||
Some(did) => {
|
||||
if let Ok((mut href, ..)) = href(did.clone(), cx) {
|
||||
if let Ok((mut href, ..)) = href(*did, cx) {
|
||||
if let Some(ref fragment) = *fragment {
|
||||
href.push('#');
|
||||
href.push_str(fragment);
|
||||
|
@ -73,7 +73,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
|
||||
search_paths: options.libs.clone(),
|
||||
crate_types,
|
||||
lint_opts: if !options.display_warnings { lint_opts } else { vec![] },
|
||||
lint_cap: Some(options.lint_cap.clone().unwrap_or_else(|| lint::Forbid)),
|
||||
lint_cap: Some(options.lint_cap.unwrap_or_else(|| lint::Forbid)),
|
||||
cg: options.codegen_options.clone(),
|
||||
externs: options.externs.clone(),
|
||||
unstable_features: options.render_options.unstable_features,
|
||||
|
@ -1323,7 +1323,7 @@ impl LinkCollector<'_, '_> {
|
||||
if let Some(ref cached) = self.visited_links.get(&key) {
|
||||
match cached {
|
||||
Some(cached) => {
|
||||
self.kind_side_channel.set(cached.side_channel.clone());
|
||||
self.kind_side_channel.set(cached.side_channel);
|
||||
return Some(cached.res.clone());
|
||||
}
|
||||
None if cache_resolution_failure => return None,
|
||||
|
Loading…
Reference in New Issue
Block a user