From 8ba92d9ce4ec834e925a514d280c2d822334ca00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 5 Mar 2020 14:29:58 +0100 Subject: [PATCH] Use more efficient &&str to String conversion (clippy::inefficient_to_string) --- src/librustc_builtin_macros/format.rs | 2 +- src/librustc_codegen_llvm/asm.rs | 2 +- src/librustc_incremental/persist/dirty_clean.rs | 3 ++- src/librustc_lint/context.rs | 4 ++-- src/librustc_typeck/collect.rs | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index 81c97bcea050..d6b8b8cafb79 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -284,7 +284,7 @@ impl<'a, 'b> Context<'a, 'b> { err.tool_only_span_suggestion( sp, &format!("use the `{}` trait", name), - fmt.to_string(), + (*fmt).to_string(), Applicability::MaybeIncorrect, ); } diff --git a/src/librustc_codegen_llvm/asm.rs b/src/librustc_codegen_llvm/asm.rs index 8066136c2fe4..c8f0fe8c7239 100644 --- a/src/librustc_codegen_llvm/asm.rs +++ b/src/librustc_codegen_llvm/asm.rs @@ -60,7 +60,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { .chain(ia.inputs.iter().map(|s| s.to_string())) .chain(ext_constraints) .chain(clobbers) - .chain(arch_clobbers.iter().map(|s| s.to_string())) + .chain(arch_clobbers.iter().map(|s| (*s).to_string())) .collect::>() .join(","); diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index f304292d922e..e212dc81070a 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -343,7 +343,8 @@ impl DirtyCleanVisitor<'tcx> { &format!("clean/dirty auto-assertions not yet defined for {:?}", node), ), }; - let labels = Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| l.to_string()))); + let labels = + Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| (*l).to_string()))); (name, labels) } diff --git a/src/librustc_lint/context.rs b/src/librustc_lint/context.rs index 29a6b8c693ff..75d493e0f5e7 100644 --- a/src/librustc_lint/context.rs +++ b/src/librustc_lint/context.rs @@ -369,7 +369,7 @@ impl LintStore { return if *silent { CheckLintNameResult::Ok(&lint_ids) } else { - CheckLintNameResult::Tool(Err((Some(&lint_ids), name.to_string()))) + CheckLintNameResult::Tool(Err((Some(&lint_ids), (*name).to_string()))) }; } CheckLintNameResult::Ok(&lint_ids) @@ -404,7 +404,7 @@ impl LintStore { return if *silent { CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name))) } else { - CheckLintNameResult::Tool(Err((Some(&lint_ids), name.to_string()))) + CheckLintNameResult::Tool(Err((Some(&lint_ids), (*name).to_string()))) }; } CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name))) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2dad3d1d6d70..26462e61e5d5 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -151,7 +151,7 @@ crate fn placeholder_type_error( .unwrap_or(&"ParamName"); let mut sugg: Vec<_> = - placeholder_types.iter().map(|sp| (*sp, type_name.to_string())).collect(); + placeholder_types.iter().map(|sp| (*sp, (*type_name).to_string())).collect(); if generics.is_empty() { sugg.push((span, format!("<{}>", type_name))); } else if let Some(arg) = generics.iter().find(|arg| match arg.name { @@ -160,7 +160,7 @@ crate fn placeholder_type_error( }) { // Account for `_` already present in cases like `struct S<_>(_);` and suggest // `struct S(T);` instead of `struct S<_, T>(T);`. - sugg.push((arg.span, type_name.to_string())); + sugg.push((arg.span, (*type_name).to_string())); } else { sugg.push(( generics.iter().last().unwrap().span.shrink_to_hi(),