From ee40a67cd9283a9e8b0de87926581456252c6c9f Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Tue, 13 Dec 2022 02:06:24 +0900 Subject: [PATCH] remove unnecessary uses of `clone` --- compiler/rustc_ast/src/token.rs | 2 +- compiler/rustc_ast_passes/src/feature_gate.rs | 2 +- compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs | 2 +- compiler/rustc_builtin_macros/src/alloc_error_handler.rs | 2 +- compiler/rustc_builtin_macros/src/concat_bytes.rs | 2 +- compiler/rustc_codegen_llvm/src/back/lto.rs | 2 +- .../error_reporting/nice_region_error/static_impl_trait.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index c0cc4e79a3d53..7b8c0d79a17e8 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -114,7 +114,7 @@ impl Lit { if let NtExpr(expr) | NtLiteral(expr) = &**nt && let ast::ExprKind::Lit(token_lit) = expr.kind => { - Some(token_lit.clone()) + Some(token_lit) } _ => None, } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 32f45f8b59e90..039338f543cc5 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -630,7 +630,7 @@ fn check_incompatible_features(sess: &Session) { { let spans = vec![f1_span, f2_span]; sess.struct_span_err( - spans.clone(), + spans, &format!( "features `{}` and `{}` are incompatible, using them at the same time \ is not allowed", diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 5e3745f17353a..5fb4dcf09f5df 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -745,7 +745,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { err.span_suggestion_verbose( span.shrink_to_hi(), "consider cloning the value if the performance cost is acceptable", - ".clone()".to_string(), + ".clone()", Applicability::MachineApplicable, ); } diff --git a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs index 95e38e4b053f4..dcf500ddbd3c8 100644 --- a/compiler/rustc_builtin_macros/src/alloc_error_handler.rs +++ b/compiler/rustc_builtin_macros/src/alloc_error_handler.rs @@ -32,7 +32,7 @@ pub fn expand( (item, true, ecx.with_def_site_ctxt(fn_kind.sig.span)) } else { ecx.sess.parse_sess.span_diagnostic.span_err(item.span(), "alloc_error_handler must be a function"); - return vec![orig_item.clone()]; + return vec![orig_item]; }; // Generate a bunch of new items using the AllocFnFactory diff --git a/compiler/rustc_builtin_macros/src/concat_bytes.rs b/compiler/rustc_builtin_macros/src/concat_bytes.rs index 70ce5a6c41929..392bd93ff8414 100644 --- a/compiler/rustc_builtin_macros/src/concat_bytes.rs +++ b/compiler/rustc_builtin_macros/src/concat_bytes.rs @@ -196,7 +196,7 @@ pub fn expand_concat_bytes( } } if !missing_literals.is_empty() { - let mut err = cx.struct_span_err(missing_literals.clone(), "expected a byte literal"); + let mut err = cx.struct_span_err(missing_literals, "expected a byte literal"); err.note("only byte literals (like `b\"foo\"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()`"); err.emit(); return base::MacEager::expr(DummyResult::raw_expr(sp, true)); diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 3fa21355b7f4c..b5e0736774f79 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -206,7 +206,7 @@ pub(crate) fn run_thin( } pub(crate) fn prepare_thin(module: ModuleCodegen) -> (String, ThinBuffer) { - let name = module.name.clone(); + let name = module.name; let buffer = ThinBuffer::new(module.module_llvm.llmod(), true); (name, buffer) } diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 09f9aa3c84220..9bd2202d2601e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -330,7 +330,7 @@ pub fn suggest_new_region_bound( Applicability::MaybeIncorrect, ); } - if let Some((param_span, param_ty)) = param.clone() { + if let Some((param_span, ref param_ty)) = param { err.span_suggestion_verbose( param_span, add_static_bound,