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( err.tool_only_span_suggestion(
full_span, full_span,
"remove this option", "remove this option",
String::new(), "",
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );

View file

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

View file

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

View file

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

View file

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

View file

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