Fix a bug in never_loop when anonymous blocks are nested in named blocks
The following code ``` loop { 'a: { { } break 'a; } } ``` was detected as a never-looping loop.
This commit is contained in:
parent
1fec2927c5
commit
e9dffa3910
@ -163,7 +163,9 @@ fn never_loop_expr(expr: &Expr<'_>, ignore_ids: &mut Vec<HirId>, main_loop_id: H
|
||||
ignore_ids.push(b.hir_id);
|
||||
}
|
||||
let ret = never_loop_block(b, ignore_ids, main_loop_id);
|
||||
ignore_ids.pop();
|
||||
if l.is_some() {
|
||||
ignore_ids.pop();
|
||||
}
|
||||
ret
|
||||
},
|
||||
ExprKind::Continue(d) => {
|
||||
|
@ -250,6 +250,15 @@ pub fn test20() {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn test21() {
|
||||
loop {
|
||||
'a: {
|
||||
{ }
|
||||
break 'a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test1();
|
||||
test2();
|
||||
|
Loading…
x
Reference in New Issue
Block a user