don't clone Copy types

This commit is contained in:
Matthias Krüger 2022-12-18 14:25:55 +01:00
parent 35a99eef32
commit fec9e9ecf1
11 changed files with 16 additions and 16 deletions

View File

@ -148,7 +148,7 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Edges<'s, 'tcx, D> {
if let Some(p) = self.pointer {
self.pointer = self.graph.next_constraints[p];
Some(self.constraints[p].clone())
Some(self.constraints[p])
} else if let Some(next_static_idx) = self.next_static_idx {
self.next_static_idx = if next_static_idx == (self.graph.first_constraints.len() - 1) {
None

View File

@ -612,7 +612,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
let locations = location.to_locations();
for constraint in constraints.outlives().iter() {
let mut constraint = constraint.clone();
let mut constraint = *constraint;
constraint.locations = locations;
if let ConstraintCategory::Return(_)
| ConstraintCategory::UseAsConst

View File

@ -1548,7 +1548,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
cause,
expected,
found,
coercion_error.clone(),
coercion_error,
fcx,
parent_id,
expression,
@ -1567,7 +1567,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
cause,
expected,
found,
coercion_error.clone(),
coercion_error,
fcx,
id,
expression,
@ -1583,7 +1583,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
cause,
expected,
found,
coercion_error.clone(),
coercion_error,
);
}
}

View File

@ -163,7 +163,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let expr = expr.peel_drop_temps();
let cause = self.misc(expr.span);
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e.clone());
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
let is_insufficiently_polymorphic =
matches!(e, TypeError::RegionsInsufficientlyPolymorphic(..));

View File

@ -127,7 +127,7 @@ impl<'tcx> Queries<'tcx> {
pub fn register_plugins(&self) -> Result<&Query<(ast::Crate, Lrc<LintStore>)>> {
self.register_plugins.compute(|| {
let crate_name = self.crate_name()?.peek().clone();
let crate_name = *self.crate_name()?.peek();
let krate = self.parse()?.take();
let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {};

View File

@ -270,7 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
|lint| {
let suggested_ident =
format!("{}{}", binding_annot.prefix_str(), ident);
lint.set_arg("ident", ident.clone()).span_suggestion(
lint.set_arg("ident", ident).span_suggestion(
fieldpat.span,
fluent::suggestion,
suggested_ident,
@ -2052,7 +2052,7 @@ impl KeywordIdents {
ident.span,
fluent::lint_builtin_keyword_idents,
|lint| {
lint.set_arg("kw", ident.clone()).set_arg("next", next_edition).span_suggestion(
lint.set_arg("kw", ident).set_arg("next", next_edition).span_suggestion(
ident.span,
fluent::suggestion,
format!("r#{}", ident),

View File

@ -332,7 +332,7 @@ impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for Symbol {
s.emit_str(self.as_str());
}
Entry::Occupied(o) => {
let x = o.get().clone();
let x = *o.get();
s.emit_u8(SYMBOL_OFFSET);
s.emit_usize(x);
}

View File

@ -965,7 +965,7 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for Symbol {
s.emit_str(self.as_str());
}
Entry::Occupied(o) => {
let x = o.get().clone();
let x = *o.get();
s.emit_u8(SYMBOL_OFFSET);
s.emit_usize(x);
}

View File

@ -1491,7 +1491,7 @@ impl<'a> Resolver<'a> {
label_res_map: self.label_res_map.clone(),
lifetimes_res_map: self.lifetimes_res_map.clone(),
extra_lifetime_params_map: self.extra_lifetime_params_map.clone(),
next_node_id: self.next_node_id.clone(),
next_node_id: self.next_node_id,
node_id_to_def_id: self.node_id_to_def_id.clone(),
def_id_to_node_id: self.def_id_to_node_id.clone(),
trait_map: self.trait_map.clone(),

View File

@ -1574,7 +1574,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
&error.obligation.cause,
expected_found.expected,
expected_found.found,
err.clone(),
*err,
)
.emit();
}
@ -1583,7 +1583,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
&error.obligation.cause,
expected_found.expected,
expected_found.found,
err.clone(),
*err,
);
let code = error.obligation.cause.code().peel_derives().peel_match_impls();
if let ObligationCauseCode::BindingObligation(..)

View File

@ -123,7 +123,7 @@ where
let fix_state = |state| if state == other.start { self.accepting } else { state };
let entry = transitions.entry(fix_state(source)).or_default();
for (edge, destinations) in transition {
let entry = entry.entry(edge.clone()).or_default();
let entry = entry.entry(edge).or_default();
for destination in destinations {
entry.insert(fix_state(destination));
}
@ -147,7 +147,7 @@ where
}
let entry = transitions.entry(source).or_default();
for (edge, destinations) in transition {
let entry = entry.entry(edge.clone()).or_default();
let entry = entry.entry(*edge).or_default();
for &(mut destination) in destinations {
// if dest is accepting state of `other`, replace with accepting state of `self`
if destination == other.accepting {