mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
feat: highlight tail expression in labeled block
This commit is contained in:
parent
c5882732e6
commit
78503f2d1f
1 changed files with 29 additions and 0 deletions
|
|
@ -446,6 +446,18 @@ pub(crate) fn highlight_break_points(
|
||||||
push_to_highlights(file_id, text_range);
|
push_to_highlights(file_id, text_range);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if matches!(expr, ast::Expr::BlockExpr(_)) {
|
||||||
|
for_each_tail_expr(&expr, &mut |tail| {
|
||||||
|
if matches!(tail, ast::Expr::BreakExpr(_)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let file_id = sema.hir_file_for(tail.syntax());
|
||||||
|
let range = tail.syntax().text_range();
|
||||||
|
push_to_highlights(file_id, Some(range));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Some(highlights)
|
Some(highlights)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2072,4 +2084,21 @@ pub unsafe fn bootstrap() -> ! {
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn labeled_block_tail_expr() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
fn foo() {
|
||||||
|
'a: {
|
||||||
|
// ^^^
|
||||||
|
if true { break$0 'a 0; }
|
||||||
|
// ^^^^^^^^
|
||||||
|
5
|
||||||
|
// ^
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue