9397: fix: Fix break point highlighting not considering outer labels r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-06-24 19:15:59 +00:00 committed by GitHub
commit 83fc0db7e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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(