File tree Expand file tree Collapse file tree
compiler/rustc_hir_typeck/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1895,11 +1895,11 @@ impl<'tcx> CoerceMany<'tcx> {
18951895
18961896 err. note ( format ! ( "{loop_type} evaluate to unit type `()`" ) ) ;
18971897 if loop_src == hir:: LoopSource :: While
1898- && let Some ( pat) = irrefutable_while_let_pattern ( block)
1898+ && let Some ( pat) = irrefutable_if_let_expr ( block)
18991899 {
19001900 err. span_note (
19011901 pat. span ,
1902- "this pattern always matches, so the loop condition never fails " ,
1902+ "this pattern always matches, consider using ` loop` instead " ,
19031903 ) ;
19041904 }
19051905 }
@@ -2134,7 +2134,7 @@ impl<'tcx> CoerceMany<'tcx> {
21342134 }
21352135}
21362136
2137- fn irrefutable_while_let_pattern < ' hir > ( block : & hir:: Block < ' hir > ) -> Option < & ' hir hir:: Pat < ' hir > > {
2137+ fn irrefutable_if_let_expr < ' hir > ( block : & hir:: Block < ' hir > ) -> Option < & ' hir hir:: Pat < ' hir > > {
21382138 let hir:: ExprKind :: If ( cond, _, _) = block. expr ?. kind else {
21392139 return None ;
21402140 } ;
Original file line number Diff line number Diff line change @@ -182,7 +182,7 @@ LL | | }
182182 | |_____^ expected `bool`, found `()`
183183 |
184184 = note: `while` loops evaluate to unit type `()`
185- note: this pattern always matches, so the loop condition never fails
185+ note: this pattern always matches, consider using ` loop` instead
186186 --> $DIR/coerce-loop-issue-122561.rs:73:15
187187 |
188188LL | while let x = false {
@@ -207,7 +207,7 @@ LL | | }
207207 | |_____^ expected `bool`, found `()`
208208 |
209209 = note: `while` loops evaluate to unit type `()`
210- note: this pattern always matches, so the loop condition never fails
210+ note: this pattern always matches, consider using ` loop` instead
211211 --> $DIR/coerce-loop-issue-122561.rs:82:15
212212 |
213213LL | while let (x, _) = (false, true) {
You can’t perform that action at this time.
0 commit comments