for_loop_over_fallibles
: suggest while let
loop
This commit is contained in:
parent
21ec99b6fa
commit
5dcfdbf31e
1 changed files with 10 additions and 0 deletions
|
@ -84,6 +84,16 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopOverFallibles {
|
||||||
"",
|
"",
|
||||||
Applicability::MaybeIncorrect
|
Applicability::MaybeIncorrect
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
warn.multipart_suggestion_verbose(
|
||||||
|
format!("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!(") = ")),
|
||||||
|
],
|
||||||
|
Applicability::MaybeIncorrect
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
warn.multipart_suggestion_verbose(
|
warn.multipart_suggestion_verbose(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue