We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
for_loop_over_fallibles
while let
1 parent b661157 commit 7cf94adCopy full SHA for 7cf94ad
compiler/rustc_lint/src/for_loop_over_fallibles.rs
@@ -84,6 +84,16 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopOverFallibles {
84
"",
85
Applicability::MaybeIncorrect
86
);
87
+ } else {
88
+ warn.multipart_suggestion_verbose(
89
+ format!("to check pattern in a loop use `while let`"),
90
+ vec![
91
+ // NB can't use `until` here because `expr.span` and `pat.span` have different syntax contexts
92
+ (expr.span.with_hi(pat.span.lo()), format!("while let {var}(")),
93
+ (pat.span.between(arg.span), format!(") = ")),
94
+ ],
95
+ Applicability::MaybeIncorrect
96
+ );
97
}
98
99
warn.multipart_suggestion_verbose(
0 commit comments