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:
Samuel Tardieu 2023-02-14 09:12:51 +01:00
parent 1fec2927c5
commit e9dffa3910
2 changed files with 12 additions and 1 deletions

View File

@ -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) => {

View File

@ -250,6 +250,15 @@ pub fn test20() {
}
}
pub fn test21() {
loop {
'a: {
{ }
break 'a;
}
}
}
fn main() {
test1();
test2();