1
Fork 0

use &str / String literals instead of format!()

This commit is contained in:
Matthias Krüger 2022-12-18 16:17:46 +01:00
parent 35a99eef32
commit 3af7df91fc
19 changed files with 37 additions and 55 deletions

View file

@ -71,11 +71,11 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
);
} else {
lint.multipart_suggestion_verbose(
format!("to check pattern in a loop use `while let`"),
"to check pattern in a loop use `while let`",
vec![
// NB can't use `until` here because `expr.span` and `pat.span` have different syntax contexts
(expr.span.with_hi(pat.span.lo()), format!("while let {var}(")),
(pat.span.between(arg.span), format!(") = ")),
(pat.span.between(arg.span), ") = ".to_string()),
],
Applicability::MaybeIncorrect
);
@ -95,7 +95,7 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles {
vec![
// NB can't use `until` here because `expr.span` and `pat.span` have different syntax contexts
(expr.span.with_hi(pat.span.lo()), format!("if let {var}(")),
(pat.span.between(arg.span), format!(") = ")),
(pat.span.between(arg.span), ") = ".to_string()),
],
Applicability::MaybeIncorrect,
)