Skip to content

Commit 221e71e

Browse files
authored
Rollup merge of #105869 - matthiaskrgr:clone_on_copy, r=compiler-errors
don't clone Copy types
2 parents e96166e + fec9e9e commit 221e71e

File tree

11 files changed

+16
-16
lines changed

11 files changed

+16
-16
lines changed

compiler/rustc_borrowck/src/constraints/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl<'s, 'tcx, D: ConstraintGraphDirecton> Iterator for Edges<'s, 'tcx, D> {
148148
if let Some(p) = self.pointer {
149149
self.pointer = self.graph.next_constraints[p];
150150

151-
Some(self.constraints[p].clone())
151+
Some(self.constraints[p])
152152
} else if let Some(next_static_idx) = self.next_static_idx {
153153
self.next_static_idx = if next_static_idx == (self.graph.first_constraints.len() - 1) {
154154
None

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
612612

613613
let locations = location.to_locations();
614614
for constraint in constraints.outlives().iter() {
615-
let mut constraint = constraint.clone();
615+
let mut constraint = *constraint;
616616
constraint.locations = locations;
617617
if let ConstraintCategory::Return(_)
618618
| ConstraintCategory::UseAsConst

compiler/rustc_hir_typeck/src/coercion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15481548
cause,
15491549
expected,
15501550
found,
1551-
coercion_error.clone(),
1551+
coercion_error,
15521552
fcx,
15531553
parent_id,
15541554
expression,
@@ -1567,7 +1567,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15671567
cause,
15681568
expected,
15691569
found,
1570-
coercion_error.clone(),
1570+
coercion_error,
15711571
fcx,
15721572
id,
15731573
expression,
@@ -1583,7 +1583,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
15831583
cause,
15841584
expected,
15851585
found,
1586-
coercion_error.clone(),
1586+
coercion_error,
15871587
);
15881588
}
15891589
}

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
163163
let expr = expr.peel_drop_temps();
164164
let cause = self.misc(expr.span);
165165
let expr_ty = self.resolve_vars_with_obligations(checked_ty);
166-
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e.clone());
166+
let mut err = self.err_ctxt().report_mismatched_types(&cause, expected, expr_ty, e);
167167

168168
let is_insufficiently_polymorphic =
169169
matches!(e, TypeError::RegionsInsufficientlyPolymorphic(..));

compiler/rustc_interface/src/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'tcx> Queries<'tcx> {
127127

128128
pub fn register_plugins(&self) -> Result<&Query<(ast::Crate, Lrc<LintStore>)>> {
129129
self.register_plugins.compute(|| {
130-
let crate_name = self.crate_name()?.peek().clone();
130+
let crate_name = *self.crate_name()?.peek();
131131
let krate = self.parse()?.take();
132132

133133
let empty: &(dyn Fn(&Session, &mut LintStore) + Sync + Send) = &|_, _| {};

compiler/rustc_lint/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
270270
|lint| {
271271
let suggested_ident =
272272
format!("{}{}", binding_annot.prefix_str(), ident);
273-
lint.set_arg("ident", ident.clone()).span_suggestion(
273+
lint.set_arg("ident", ident).span_suggestion(
274274
fieldpat.span,
275275
fluent::suggestion,
276276
suggested_ident,
@@ -2052,7 +2052,7 @@ impl KeywordIdents {
20522052
ident.span,
20532053
fluent::lint_builtin_keyword_idents,
20542054
|lint| {
2055-
lint.set_arg("kw", ident.clone()).set_arg("next", next_edition).span_suggestion(
2055+
lint.set_arg("kw", ident).set_arg("next", next_edition).span_suggestion(
20562056
ident.span,
20572057
fluent::suggestion,
20582058
format!("r#{}", ident),

compiler/rustc_metadata/src/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for Symbol {
332332
s.emit_str(self.as_str());
333333
}
334334
Entry::Occupied(o) => {
335-
let x = o.get().clone();
335+
let x = *o.get();
336336
s.emit_u8(SYMBOL_OFFSET);
337337
s.emit_usize(x);
338338
}

compiler/rustc_query_impl/src/on_disk_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ impl<'a, 'tcx> Encodable<CacheEncoder<'a, 'tcx>> for Symbol {
965965
s.emit_str(self.as_str());
966966
}
967967
Entry::Occupied(o) => {
968-
let x = o.get().clone();
968+
let x = *o.get();
969969
s.emit_u8(SYMBOL_OFFSET);
970970
s.emit_usize(x);
971971
}

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ impl<'a> Resolver<'a> {
14911491
label_res_map: self.label_res_map.clone(),
14921492
lifetimes_res_map: self.lifetimes_res_map.clone(),
14931493
extra_lifetime_params_map: self.extra_lifetime_params_map.clone(),
1494-
next_node_id: self.next_node_id.clone(),
1494+
next_node_id: self.next_node_id,
14951495
node_id_to_def_id: self.node_id_to_def_id.clone(),
14961496
def_id_to_node_id: self.def_id_to_node_id.clone(),
14971497
trait_map: self.trait_map.clone(),

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
15741574
&error.obligation.cause,
15751575
expected_found.expected,
15761576
expected_found.found,
1577-
err.clone(),
1577+
*err,
15781578
)
15791579
.emit();
15801580
}
@@ -1583,7 +1583,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
15831583
&error.obligation.cause,
15841584
expected_found.expected,
15851585
expected_found.found,
1586-
err.clone(),
1586+
*err,
15871587
);
15881588
let code = error.obligation.cause.code().peel_derives().peel_match_impls();
15891589
if let ObligationCauseCode::BindingObligation(..)

compiler/rustc_transmute/src/layout/nfa.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ where
123123
let fix_state = |state| if state == other.start { self.accepting } else { state };
124124
let entry = transitions.entry(fix_state(source)).or_default();
125125
for (edge, destinations) in transition {
126-
let entry = entry.entry(edge.clone()).or_default();
126+
let entry = entry.entry(edge).or_default();
127127
for destination in destinations {
128128
entry.insert(fix_state(destination));
129129
}
@@ -147,7 +147,7 @@ where
147147
}
148148
let entry = transitions.entry(source).or_default();
149149
for (edge, destinations) in transition {
150-
let entry = entry.entry(edge.clone()).or_default();
150+
let entry = entry.entry(*edge).or_default();
151151
for &(mut destination) in destinations {
152152
// if dest is accepting state of `other`, replace with accepting state of `self`
153153
if destination == other.accepting {

0 commit comments

Comments
 (0)