Rollup merge of #99508 - TaKO8Ki:avoid-symbol-to-string-conversion-in-BuiltinLintDiagnostics, r=compiler-errors
Avoid `Symbol` to `String` conversions follow-up to #99342
This commit is contained in:
commit
4b21ad26df
@ -1004,9 +1004,7 @@ fn lint_named_arguments_used_positionally(
|
|||||||
node_id: ast::CRATE_NODE_ID,
|
node_id: ast::CRATE_NODE_ID,
|
||||||
lint_id: LintId::of(&NAMED_ARGUMENTS_USED_POSITIONALLY),
|
lint_id: LintId::of(&NAMED_ARGUMENTS_USED_POSITIONALLY),
|
||||||
diagnostic: BuiltinLintDiagnostics::NamedArgumentUsedPositionally(
|
diagnostic: BuiltinLintDiagnostics::NamedArgumentUsedPositionally(
|
||||||
arg_span,
|
arg_span, span, symbol,
|
||||||
span,
|
|
||||||
symbol.to_string(),
|
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -390,18 +390,17 @@ impl Diagnostic {
|
|||||||
expected: DiagnosticStyledString,
|
expected: DiagnosticStyledString,
|
||||||
found: DiagnosticStyledString,
|
found: DiagnosticStyledString,
|
||||||
) -> &mut Self {
|
) -> &mut Self {
|
||||||
let mut msg: Vec<_> =
|
let mut msg: Vec<_> = vec![("required when trying to coerce from type `", Style::NoStyle)];
|
||||||
vec![("required when trying to coerce from type `".to_string(), Style::NoStyle)];
|
|
||||||
msg.extend(expected.0.iter().map(|x| match *x {
|
msg.extend(expected.0.iter().map(|x| match *x {
|
||||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle),
|
||||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
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 {
|
msg.extend(found.0.iter().map(|x| match *x {
|
||||||
StringPart::Normal(ref s) => (s.to_owned(), Style::NoStyle),
|
StringPart::Normal(ref s) => (s.as_str(), Style::NoStyle),
|
||||||
StringPart::Highlighted(ref s) => (s.to_owned(), Style::Highlight),
|
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
|
// For now, just attach these as notes
|
||||||
self.highlighted_note(msg);
|
self.highlighted_note(msg);
|
||||||
|
@ -467,7 +467,7 @@ pub enum BuiltinLintDiagnostics {
|
|||||||
/// If true, the lifetime will be fully elided.
|
/// If true, the lifetime will be fully elided.
|
||||||
use_span: Option<(Span, bool)>,
|
use_span: Option<(Span, bool)>,
|
||||||
},
|
},
|
||||||
NamedArgumentUsedPositionally(Option<Span>, Span, String),
|
NamedArgumentUsedPositionally(Option<Span>, Span, Symbol),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lints that are buffered up early on in the `Session` before the
|
/// Lints that are buffered up early on in the `Session` before the
|
||||||
|
@ -2603,9 +2603,9 @@ fn show_candidates(
|
|||||||
.skip(1)
|
.skip(1)
|
||||||
.all(|(_, descr, _, _)| descr == descr_first)
|
.all(|(_, descr, _, _)| descr == descr_first)
|
||||||
{
|
{
|
||||||
descr_first.to_string()
|
descr_first
|
||||||
} else {
|
} else {
|
||||||
"item".to_string()
|
"item"
|
||||||
};
|
};
|
||||||
let plural_descr =
|
let plural_descr =
|
||||||
if descr.ends_with("s") { format!("{}es", descr) } else { format!("{}s", descr) };
|
if descr.ends_with("s") { format!("{}es", descr) } else { format!("{}s", descr) };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user