Fix break point highlighting not considering outer labels

This commit is contained in:
Lukas Wirth 2021-06-24 21:14:43 +02:00
parent 42efd211bc
commit 67075b228e

View file

@ -371,7 +371,9 @@ fn for_each_break(
depth += 1
}
ast::Expr::EffectExpr(e) if e.label().is_some() => depth += 1,
ast::Expr::BreakExpr(b) if depth == 0 || eq_label(b.lifetime()) => {
ast::Expr::BreakExpr(b)
if (depth == 0 && b.lifetime().is_none()) || eq_label(b.lifetime()) =>
{
cb(b);
}
_ => (),
@ -727,6 +729,33 @@ fn foo() {
);
}
#[test]
fn test_hl_break_loop2() {
check(
r#"
fn foo() {
'outer: loop {
break;
'inner: loop {
// ^^^^^^^^^^^^
break;
// ^^^^^
'innermost: loop {
break 'outer;
break 'inner;
// ^^^^^^^^^^^^
}
break 'outer;
break$0;
// ^^^^^
}
break;
}
}
"#,
);
}
#[test]
fn test_hl_break_for() {
check(