@@ -513,16 +513,23 @@ pub(crate) fn highlight_yield_points(
513
513
match anc {
514
514
ast:: Fn ( fn_) => hl( sema, fn_. async_token( ) , fn_. body( ) . map( ast:: Expr :: BlockExpr ) ) ,
515
515
ast:: BlockExpr ( block_expr) => {
516
- if block_expr. async_token( ) . is_none ( ) {
516
+ let Some ( async_token ) = block_expr. async_token( ) else {
517
517
continue ;
518
- }
518
+ } ;
519
519
520
520
// Async blocks act similar to closures. So we want to
521
- // highlight their exit points too.
522
- let exit_points = hl_exit_points( sema, block_expr. async_token( ) , block_expr. clone( ) . into( ) ) ;
523
- merge_map( & mut res, exit_points) ;
521
+ // highlight their exit points too, but only if we are on
522
+ // the async token.
523
+ if async_token == token {
524
+ let exit_points = hl_exit_points(
525
+ sema,
526
+ Some ( async_token. clone( ) ) ,
527
+ block_expr. clone( ) . into( ) ,
528
+ ) ;
529
+ merge_map( & mut res, exit_points) ;
530
+ }
524
531
525
- hl( sema, block_expr . async_token ( ) , Some ( block_expr. into( ) ) )
532
+ hl( sema, Some ( async_token ) , Some ( block_expr. into( ) ) )
526
533
} ,
527
534
ast:: ClosureExpr ( closure) => hl( sema, closure. async_token( ) , closure. body( ) ) ,
528
535
_ => continue ,
@@ -949,7 +956,6 @@ async fn foo() {
949
956
(async {
950
957
// ^^^^^
951
958
(async { 0.await }).await$0
952
- // ^^^^^^^^^^^^^^^^^^^^^^^^^
953
959
// ^^^^^
954
960
}).await;
955
961
}
0 commit comments