remove unnecessary to_string and String::new for tool_only_span_suggestion

This commit is contained in:
Takayuki Maeda 2022-06-13 16:01:16 +09:00
parent 77d6176e69
commit fd1290a631
6 changed files with 7 additions and 12 deletions

View file

@ -363,7 +363,7 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
err.tool_only_span_suggestion(
full_span,
"remove this option",
String::new(),
"",
Applicability::MachineApplicable,
);

View file

@ -330,7 +330,7 @@ impl<'a, 'b> Context<'a, 'b> {
err.tool_only_span_suggestion(
sp,
&format!("use the `{}` trait", name),
(*fmt).to_string(),
*fmt,
Applicability::MaybeIncorrect,
);
}

View file

@ -2596,7 +2596,7 @@ impl<'a> Parser<'a> {
err.tool_only_span_suggestion(
label.ident.span.until(self.token.span),
"remove this block label",
String::new(),
"",
Applicability::MachineApplicable,
);
err.emit();

View file

@ -271,7 +271,7 @@ impl<'a> Resolver<'a> {
err.tool_only_span_suggestion(
import.use_span_with_attributes,
"remove unnecessary import",
String::new(),
"",
Applicability::MaybeIncorrect,
);
}
@ -396,12 +396,7 @@ impl<'a> Resolver<'a> {
// previous imports.
if found_closing_brace {
if let Some(span) = extend_span_to_previous_binding(self.session, span) {
err.tool_only_span_suggestion(
span,
message,
String::new(),
Applicability::MaybeIncorrect,
);
err.tool_only_span_suggestion(span, message, "", Applicability::MaybeIncorrect);
} else {
// Remove the entire line if we cannot extend the span back, this indicates an
// `issue_52891::{self}` case.

View file

@ -174,7 +174,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.tool_only_span_suggestion(
semi_span,
"remove this semicolon",
String::new(),
"",
Applicability::MaybeIncorrect,
);
}),

View file

@ -281,7 +281,7 @@ fn check<'tcx>(
diag.tool_only_span_suggestion(
local_stmt.span,
"remove the local",
String::new(),
"",
Applicability::MachineApplicable,
);