mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Auto merge of #14848 - bm-w:fix/highlight-let-else-return, r=Veykril
Fix `preorder_expr` skipping the `else` block of let-else statements Fixes exit/yield points not getting highlighted in such blocks for `highlight_related` (#14813; and possibly other bugs in features that use `preorder_expr`).
This commit is contained in:
commit
e8ae2d3976
2 changed files with 46 additions and 1 deletions
|
@ -692,6 +692,29 @@ pub async$0 fn foo() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hl_let_else_yield_points() {
|
||||
check(
|
||||
r#"
|
||||
pub async fn foo() {
|
||||
// ^^^^^
|
||||
let x = foo()
|
||||
.await$0
|
||||
// ^^^^^
|
||||
.await;
|
||||
// ^^^^^
|
||||
|| { 0.await };
|
||||
let Some(_) = None else {
|
||||
foo().await
|
||||
// ^^^^^
|
||||
};
|
||||
(async { 0.await }).await
|
||||
// ^^^^^
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hl_yield_nested_fn() {
|
||||
check(
|
||||
|
@ -788,6 +811,26 @@ async fn foo() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hl_let_else_exit_points() {
|
||||
check(
|
||||
r#"
|
||||
fn$0 foo() -> u32 {
|
||||
//^^
|
||||
let Some(bar) = None else {
|
||||
return 0;
|
||||
// ^^^^^^
|
||||
};
|
||||
|
||||
0?;
|
||||
// ^
|
||||
0xDEAD_BEEF
|
||||
// ^^^^^^^^^^^
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hl_prefer_ref_over_tail_exit() {
|
||||
check(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue