Use more efficient &&str to String conversion (clippy::inefficient_to_string)

This commit is contained in:
Matthias Krüger 2020-03-05 14:29:58 +01:00
parent a1c3eb6043
commit 8ba92d9ce4
5 changed files with 8 additions and 7 deletions

View File

@ -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,
);
}

View File

@ -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::<Vec<String>>()
.join(",");

View File

@ -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)
}

View File

@ -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)))

View File

@ -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>(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(),