From fec9e9ecf1a34aa87bcae28c158a590f75e16a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 18 Dec 2022 14:25:55 +0100 Subject: [PATCH] don't clone Copy types --- compiler/rustc_borrowck/src/constraints/graph.rs | 2 +- compiler/rustc_borrowck/src/type_check/mod.rs | 2 +- compiler/rustc_hir_typeck/src/coercion.rs | 6 +++--- compiler/rustc_hir_typeck/src/demand.rs | 2 +- compiler/rustc_interface/src/queries.rs | 2 +- compiler/rustc_lint/src/builtin.rs | 4 ++-- compiler/rustc_metadata/src/rmeta/encoder.rs | 2 +- compiler/rustc_query_impl/src/on_disk_cache.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 2 +- .../rustc_trait_selection/src/traits/error_reporting/mod.rs | 4 ++-- compiler/rustc_transmute/src/layout/nfa.rs | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_borrowck/src/constraints/graph.rs b/compiler/rustc_borrowck/src/constraints/graph.rs index 385f153174c..c780d047992 100644 --- a/compiler/rustc_borrowck/src/constraints/graph.rs +++ b/compiler/rustc_borrowck/src/constraints/graph.rs @@ -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 diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 814bc275019..8d4a720f8ce 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -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 diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 36cf4791492..8cdd12e4e34 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -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, ); } } diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 6763e06c0cf..4ac24aca25a 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -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(..)); diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 39e1f2204b0..1d0c7f5b7a3 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -127,7 +127,7 @@ impl<'tcx> Queries<'tcx> { pub fn register_plugins(&self) -> Result<&Query<(ast::Crate, Lrc)>> { 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) = &|_, _| {}; diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 43862570e80..cd19e65b6fc 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -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), diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 856f5bc4645..219753dbd16 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -332,7 +332,7 @@ impl<'a, 'tcx> Encodable> 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); } diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs index ac9653b9007..c4e605c1852 100644 --- a/compiler/rustc_query_impl/src/on_disk_cache.rs +++ b/compiler/rustc_query_impl/src/on_disk_cache.rs @@ -965,7 +965,7 @@ impl<'a, 'tcx> Encodable> 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); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 24e4b5bdd3f..4861ee746aa 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -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(), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 2dd2c568bab..929d813bfc3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -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(..) diff --git a/compiler/rustc_transmute/src/layout/nfa.rs b/compiler/rustc_transmute/src/layout/nfa.rs index c2bc47bc043..78fcceb5f2c 100644 --- a/compiler/rustc_transmute/src/layout/nfa.rs +++ b/compiler/rustc_transmute/src/layout/nfa.rs @@ -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 {