Auto merge of #4243 - mikerite:fix-4058, r=flip1995
Fix `never_loop` false positive Closes #4058 changelog: none
This commit is contained in:
commit
47ada9ae07
@ -727,8 +727,7 @@ fn never_loop_expr(expr: &Expr, main_loop_id: HirId) -> NeverLoopResult {
|
||||
NeverLoopResult::AlwaysBreak
|
||||
}
|
||||
},
|
||||
ExprKind::Break(_, _) => NeverLoopResult::AlwaysBreak,
|
||||
ExprKind::Ret(ref e) => {
|
||||
ExprKind::Break(_, ref e) | ExprKind::Ret(ref e) => {
|
||||
if let Some(ref e) = *e {
|
||||
combine_seq(never_loop_expr(e, main_loop_id), NeverLoopResult::AlwaysBreak)
|
||||
} else {
|
||||
|
@ -175,6 +175,17 @@ pub fn test15() {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #4058: `continue` in `break` expression
|
||||
pub fn test16() {
|
||||
let mut n = 1;
|
||||
loop {
|
||||
break if n != 5 {
|
||||
n += 1;
|
||||
continue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test1();
|
||||
test2();
|
||||
|
Loading…
Reference in New Issue
Block a user