remove unnecessary to_string
and String::new
This commit is contained in:
parent
c570ab5a0b
commit
77d6176e69
88 changed files with 292 additions and 340 deletions
|
@ -136,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
|
|||
diag.span_suggestion(
|
||||
receiver_arg.span.shrink_to_hi().to(expr.span.shrink_to_hi()),
|
||||
"or remove `.into_iter()` to iterate by value",
|
||||
String::new(),
|
||||
"",
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
} else if receiver_ty.is_array() {
|
||||
|
|
|
@ -993,7 +993,7 @@ fn lint_deprecated_attr(
|
|||
.span_suggestion_short(
|
||||
attr.span,
|
||||
suggestion.unwrap_or("remove this attribute"),
|
||||
String::new(),
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
|
@ -1182,7 +1182,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
.span_suggestion_short(
|
||||
no_mangle_attr.span,
|
||||
"remove this attribute",
|
||||
String::new(),
|
||||
"",
|
||||
// Use of `#[no_mangle]` suggests FFI intent; correct
|
||||
// fix may be to monomorphize source by hand
|
||||
Applicability::MaybeIncorrect,
|
||||
|
@ -1221,7 +1221,7 @@ impl<'tcx> LateLintPass<'tcx> for InvalidNoMangleItems {
|
|||
err.span_suggestion(
|
||||
const_span,
|
||||
"try a static value",
|
||||
"pub static".to_owned(),
|
||||
"pub static",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
|
@ -1405,7 +1405,7 @@ impl UnreachablePub {
|
|||
err.span_suggestion(
|
||||
vis_span,
|
||||
"consider restricting its visibility",
|
||||
"pub(crate)".to_owned(),
|
||||
"pub(crate)",
|
||||
applicability,
|
||||
);
|
||||
if exportable {
|
||||
|
@ -1566,7 +1566,7 @@ impl<'tcx> LateLintPass<'tcx> for TypeAliasBounds {
|
|||
err.span_suggestion(
|
||||
type_alias_generics.where_clause_span,
|
||||
"the clause will not be checked when the type alias is used, and should be removed",
|
||||
String::new(),
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
if !suggested_changing_assoc_types {
|
||||
|
@ -1830,7 +1830,7 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
let replace = "..=".to_owned();
|
||||
let replace = "..=";
|
||||
if join.edition() >= Edition::Edition2021 {
|
||||
let mut err =
|
||||
rustc_errors::struct_span_err!(cx.sess(), pat.span, E0783, "{}", msg,);
|
||||
|
|
|
@ -718,7 +718,7 @@ pub trait LintContext: Sized {
|
|||
the macro must produce the documentation as part of its expansion");
|
||||
}
|
||||
BuiltinLintDiagnostics::PatternsInFnsWithoutBody(span, ident) => {
|
||||
db.span_suggestion(span, "remove `mut` from the parameter", ident.to_string(), Applicability::MachineApplicable);
|
||||
db.span_suggestion(span, "remove `mut` from the parameter", ident, Applicability::MachineApplicable);
|
||||
}
|
||||
BuiltinLintDiagnostics::MissingAbi(span, default_abi) => {
|
||||
db.span_label(span, "ABI should be specified here");
|
||||
|
@ -778,7 +778,7 @@ pub trait LintContext: Sized {
|
|||
|
||||
// Suggest the most probable if we found one
|
||||
if let Some(best_match) = find_best_match_for_name(&possibilities, name, None) {
|
||||
db.span_suggestion(name_span, "did you mean", format!("{best_match}"), Applicability::MaybeIncorrect);
|
||||
db.span_suggestion(name_span, "did you mean", best_match, Applicability::MaybeIncorrect);
|
||||
}
|
||||
},
|
||||
BuiltinLintDiagnostics::UnexpectedCfg((name, name_span), Some((value, value_span))) => {
|
||||
|
@ -805,7 +805,7 @@ pub trait LintContext: Sized {
|
|||
} else {
|
||||
db.note(&format!("no expected value for `{name}`"));
|
||||
if name != sym::feature {
|
||||
db.span_suggestion(name_span.shrink_to_hi().to(value_span), "remove the value", String::new(), Applicability::MaybeIncorrect);
|
||||
db.span_suggestion(name_span.shrink_to_hi().to(value_span), "remove the value", "", Applicability::MaybeIncorrect);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -852,7 +852,7 @@ pub trait LintContext: Sized {
|
|||
db.span_suggestion(
|
||||
deletion_span,
|
||||
"elide the unused lifetime",
|
||||
String::new(),
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||
.span_suggestion(
|
||||
span,
|
||||
"try using `ty::<kind>` directly",
|
||||
"ty".to_string(),
|
||||
"ty",
|
||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||
)
|
||||
.emit();
|
||||
|
@ -170,7 +170,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||
.span_suggestion(
|
||||
path.span,
|
||||
"try using `ty::<kind>` directly",
|
||||
"ty".to_string(),
|
||||
"ty",
|
||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||
)
|
||||
.emit();
|
||||
|
@ -188,7 +188,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||
.span_suggestion(
|
||||
path.span,
|
||||
"try using `ty::<kind>` directly",
|
||||
"ty".to_string(),
|
||||
"ty",
|
||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||
)
|
||||
.emit();
|
||||
|
@ -208,7 +208,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
|
|||
.span_suggestion(
|
||||
path.span,
|
||||
"try using `ty::<kind>` directly",
|
||||
"ty".to_string(),
|
||||
"ty",
|
||||
Applicability::MaybeIncorrect, // ty maybe needs an import
|
||||
)
|
||||
.emit();
|
||||
|
|
|
@ -443,7 +443,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
.span_suggestion(
|
||||
sp,
|
||||
"change it to",
|
||||
new_lint_name.to_string(),
|
||||
new_lint_name,
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
|
@ -516,7 +516,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
err.span_suggestion(
|
||||
sp,
|
||||
"use the new name",
|
||||
new_name.to_string(),
|
||||
new_name,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
@ -543,7 +543,7 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
db.span_suggestion(
|
||||
sp,
|
||||
"did you mean",
|
||||
suggestion.to_string(),
|
||||
suggestion,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -54,9 +54,7 @@ fn maybe_lint_redundant_semis(cx: &EarlyContext<'_>, seq: &mut Option<(Span, boo
|
|||
} else {
|
||||
("unnecessary trailing semicolon", "remove this semicolon")
|
||||
};
|
||||
lint.build(msg)
|
||||
.span_suggestion(span, rem, String::new(), Applicability::MaybeIncorrect)
|
||||
.emit();
|
||||
lint.build(msg).span_suggestion(span, rem, "", Applicability::MaybeIncorrect).emit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
|
|||
lint.span_suggestion_verbose(
|
||||
expr.span.shrink_to_lo(),
|
||||
"use `let _ = ...` to ignore the resulting value",
|
||||
"let _ = ".to_string(),
|
||||
"let _ = ",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
lint.emit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue