Skip to content

Commit 56e7777

Browse files
committed
avoid &str to String conversions
1 parent 57a155b commit 56e7777

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

compiler/rustc_errors/src/diagnostic.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -390,18 +390,17 @@ impl Diagnostic {
390390
expected: DiagnosticStyledString,
391391
found: DiagnosticStyledString,
392392
) -> &mut Self {
393-
let mut msg: Vec<_> =
394-
vec![("required when trying to coerce from type `".to_string(), Style::NoStyle)];
393+
let mut msg: Vec<_> = vec![("required when trying to coerce from type `", Style::NoStyle)];
395394
msg.extend(expected.0.iter().map(|x| match *x {
396-
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
397-
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
395+
StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle),
396+
StringPart::Highlighted(ref s) => (s.as_str(), Style::Highlight),
398397
}));
399-
msg.push(("` to type '".to_string(), Style::NoStyle));
398+
msg.push(("` to type '", Style::NoStyle));
400399
msg.extend(found.0.iter().map(|x| match *x {
401-
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
402-
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
400+
StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle),
401+
StringPart::Highlighted(ref s) => (s.as_str(), Style::Highlight),
403402
}));
404-
msg.push(("`".to_string(), Style::NoStyle));
403+
msg.push(("`", Style::NoStyle));
405404

406405
// For now, just attach these as notes
407406
self.highlighted_note(msg);

compiler/rustc_resolve/src/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2603,9 +2603,9 @@ fn show_candidates(
26032603
.skip(1)
26042604
.all(|(_, descr, _, _)| descr == descr_first)
26052605
{
2606-
descr_first.to_string()
2606+
descr_first
26072607
} else {
2608-
"item".to_string()
2608+
"item"
26092609
};
26102610
let plural_descr =
26112611
if descr.ends_with("s") { format!("{}es", descr) } else { format!("{}s", descr) };

0 commit comments

Comments
 (0)