1
Fork 0

remove unnecessary to_string and String::new

This commit is contained in:
Takayuki Maeda 2022-06-13 15:48:40 +09:00
parent c570ab5a0b
commit 77d6176e69
88 changed files with 292 additions and 340 deletions

View file

@ -431,7 +431,7 @@ impl<'a> Parser<'a> {
err.span_suggestion_verbose(
ident.span.shrink_to_lo(),
&format!("escape `{}` to use it as an identifier", ident.name),
"r#".to_owned(),
"r#",
Applicability::MaybeIncorrect,
);
}
@ -445,7 +445,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
self.token.span,
"remove this comma",
String::new(),
"",
Applicability::MachineApplicable,
);
}
@ -518,7 +518,7 @@ impl<'a> Parser<'a> {
self.bump();
let sp = self.prev_token.span;
self.struct_span_err(sp, &msg)
.span_suggestion_short(sp, "change this to `;`", ";".to_string(), appl)
.span_suggestion_short(sp, "change this to `;`", ";", appl)
.emit();
return Ok(true);
} else if self.look_ahead(0, |t| {
@ -537,7 +537,7 @@ impl<'a> Parser<'a> {
let sp = self.prev_token.span.shrink_to_hi();
self.struct_span_err(sp, &msg)
.span_label(self.token.span, "unexpected token")
.span_suggestion_short(sp, "add `;` here", ";".to_string(), appl)
.span_suggestion_short(sp, "add `;` here", ";", appl)
.emit();
return Ok(true);
}
@ -664,7 +664,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
span,
&format!("remove the extra `#`{}", pluralize!(count)),
String::new(),
"",
Applicability::MachineApplicable,
);
err.span_label(
@ -761,7 +761,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
sp,
"maybe write a path separator here",
"::".to_string(),
"::",
if allow_unstable {
Applicability::MaybeIncorrect
} else {
@ -773,7 +773,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
sp,
"try using a semicolon",
";".to_string(),
";",
Applicability::MaybeIncorrect,
);
} else if allow_unstable {
@ -917,7 +917,7 @@ impl<'a> Parser<'a> {
.span_suggestion(
span,
&format!("remove extra angle bracket{}", pluralize!(total_num_of_gt)),
String::new(),
"",
Applicability::MachineApplicable,
)
.emit();
@ -999,7 +999,7 @@ impl<'a> Parser<'a> {
e.span_suggestion_verbose(
binop.span.shrink_to_lo(),
TURBOFISH_SUGGESTION_STR,
"::".to_string(),
"::",
Applicability::MaybeIncorrect,
)
.emit();
@ -1158,7 +1158,7 @@ impl<'a> Parser<'a> {
err.span_suggestion_verbose(
op.span.shrink_to_lo(),
TURBOFISH_SUGGESTION_STR,
"::".to_string(),
"::",
Applicability::MaybeIncorrect,
);
};
@ -1701,7 +1701,7 @@ impl<'a> Parser<'a> {
Applicability::MachineApplicable,
);
}
err.span_suggestion(lo.shrink_to_lo(), &format!("{prefix}you can still access the deprecated `try!()` macro using the \"raw identifier\" syntax"), "r#".to_string(), Applicability::MachineApplicable);
err.span_suggestion(lo.shrink_to_lo(), &format!("{prefix}you can still access the deprecated `try!()` macro using the \"raw identifier\" syntax"), "r#", Applicability::MachineApplicable);
err.emit();
Ok(self.mk_expr_err(lo.to(hi)))
} else {
@ -1997,7 +1997,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
span,
"declare the type after the parameter binding",
String::from("<identifier>: <type>"),
"<identifier>: <type>",
Applicability::HasPlaceholders,
);
return Some(ident);
@ -2102,7 +2102,7 @@ impl<'a> Parser<'a> {
.span_suggestion_short(
pat.span,
"give this argument a name or use an underscore to ignore it",
"_".to_owned(),
"_",
Applicability::MachineApplicable,
)
.emit();
@ -2336,7 +2336,7 @@ impl<'a> Parser<'a> {
err.span_suggestion_verbose(
start.until(self.token.span),
"the `const` keyword is only needed in the definition of the type",
String::new(),
"",
Applicability::MaybeIncorrect,
);
err.emit();
@ -2394,7 +2394,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
snapshot.token.span,
"if you meant to use an associated type binding, replace `==` with `=`",
"=".to_string(),
"=",
Applicability::MaybeIncorrect,
);
let value = self.mk_expr_err(start.to(expr.span));
@ -2408,7 +2408,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
snapshot.token.span,
"write a path separator here",
"::".to_string(),
"::",
Applicability::MaybeIncorrect,
);
err.emit();
@ -2461,7 +2461,7 @@ impl<'a> Parser<'a> {
err.span_suggestion_verbose(
move_async_span,
"try switching the order",
"async move".to_owned(),
"async move",
Applicability::MaybeIncorrect,
);
err
@ -2566,7 +2566,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
span,
"maybe write a path separator here",
"::".to_string(),
"::",
Applicability::MaybeIncorrect,
);
} else {
@ -2669,7 +2669,7 @@ impl<'a> Parser<'a> {
err.span_suggestion(
between_span,
"use single colon",
": ".to_owned(),
": ",
Applicability::MachineApplicable,
);
return Err(err);