Skip to content

Commit 8ba92d9

Browse files
committed
Use more efficient &&str to String conversion (clippy::inefficient_to_string)
1 parent a1c3eb6 commit 8ba92d9

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/librustc_builtin_macros/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ impl<'a, 'b> Context<'a, 'b> {
284284
err.tool_only_span_suggestion(
285285
sp,
286286
&format!("use the `{}` trait", name),
287-
fmt.to_string(),
287+
(*fmt).to_string(),
288288
Applicability::MaybeIncorrect,
289289
);
290290
}

src/librustc_codegen_llvm/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
6060
.chain(ia.inputs.iter().map(|s| s.to_string()))
6161
.chain(ext_constraints)
6262
.chain(clobbers)
63-
.chain(arch_clobbers.iter().map(|s| s.to_string()))
63+
.chain(arch_clobbers.iter().map(|s| (*s).to_string()))
6464
.collect::<Vec<String>>()
6565
.join(",");
6666

src/librustc_incremental/persist/dirty_clean.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ impl DirtyCleanVisitor<'tcx> {
343343
&format!("clean/dirty auto-assertions not yet defined for {:?}", node),
344344
),
345345
};
346-
let labels = Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| l.to_string())));
346+
let labels =
347+
Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| (*l).to_string())));
347348
(name, labels)
348349
}
349350

src/librustc_lint/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ impl LintStore {
369369
return if *silent {
370370
CheckLintNameResult::Ok(&lint_ids)
371371
} else {
372-
CheckLintNameResult::Tool(Err((Some(&lint_ids), name.to_string())))
372+
CheckLintNameResult::Tool(Err((Some(&lint_ids), (*name).to_string())))
373373
};
374374
}
375375
CheckLintNameResult::Ok(&lint_ids)
@@ -404,7 +404,7 @@ impl LintStore {
404404
return if *silent {
405405
CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name)))
406406
} else {
407-
CheckLintNameResult::Tool(Err((Some(&lint_ids), name.to_string())))
407+
CheckLintNameResult::Tool(Err((Some(&lint_ids), (*name).to_string())))
408408
};
409409
}
410410
CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name)))

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ crate fn placeholder_type_error(
151151
.unwrap_or(&"ParamName");
152152

153153
let mut sugg: Vec<_> =
154-
placeholder_types.iter().map(|sp| (*sp, type_name.to_string())).collect();
154+
placeholder_types.iter().map(|sp| (*sp, (*type_name).to_string())).collect();
155155
if generics.is_empty() {
156156
sugg.push((span, format!("<{}>", type_name)));
157157
} else if let Some(arg) = generics.iter().find(|arg| match arg.name {
@@ -160,7 +160,7 @@ crate fn placeholder_type_error(
160160
}) {
161161
// Account for `_` already present in cases like `struct S<_>(_);` and suggest
162162
// `struct S<T>(T);` instead of `struct S<_, T>(T);`.
163-
sugg.push((arg.span, type_name.to_string()));
163+
sugg.push((arg.span, (*type_name).to_string()));
164164
} else {
165165
sugg.push((
166166
generics.iter().last().unwrap().span.shrink_to_hi(),

0 commit comments

Comments
 (0)