diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-07-20 18:58:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-20 18:58:20 +0200 |
| commit | 4b21ad26df669705831d14a66cd37f2fa0655470 (patch) | |
| tree | 34d0d686351dff3209831e8f1bf21236672df357 /compiler/rustc_errors/src | |
| parent | 73ef81dcea5e7e204cac798ff787551f29a7257b (diff) | |
| parent | 56e7777755945041da1f898d1bd1887e554adce1 (diff) | |
| download | rust-4b21ad26df669705831d14a66cd37f2fa0655470.tar.gz rust-4b21ad26df669705831d14a66cd37f2fa0655470.zip | |
Rollup merge of #99508 - TaKO8Ki:avoid-symbol-to-string-conversion-in-BuiltinLintDiagnostics, r=compiler-errors
Avoid `Symbol` to `String` conversions follow-up to #99342
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 7d7f3e18335..ba888d77b15 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -390,18 +390,17 @@ impl Diagnostic { expected: DiagnosticStyledString, found: DiagnosticStyledString, ) -> &mut Self { - let mut msg: Vec<_> = - vec![("required when trying to coerce from type `".to_string(), Style::NoStyle)]; + let mut msg: Vec<_> = vec![("required when trying to coerce from type `", Style::NoStyle)]; msg.extend(expected.0.iter().map(|x| match *x { - StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle), - StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight), + StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle), + StringPart::Highlighted(ref s) => (s.as_str(), Style::Highlight), })); - msg.push(("` to type '".to_string(), Style::NoStyle)); + msg.push(("` to type '", Style::NoStyle)); msg.extend(found.0.iter().map(|x| match *x { - StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle), - StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight), + StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle), + StringPart::Highlighted(ref s) => (s.as_str(), Style::Highlight), })); - msg.push(("`".to_string(), Style::NoStyle)); + msg.push(("`", Style::NoStyle)); // For now, just attach these as notes self.highlighted_note(msg); |
