@@ -72,28 +72,21 @@ pub(crate) fn highlight_related(
7272 T ! [ break ] | T ! [ loop ] | T ! [ while ] | T ! [ continue ] if config. break_points => {
7373 highlight_break_points ( token)
7474 }
75- T ! [ |] if config. closure_captures => highlight_closure_captures (
76- sema,
77- token. parent_ancestors ( ) . nth ( 1 ) . and_then ( ast:: ClosureExpr :: cast) ?,
78- file_id,
79- ) ,
80- T ! [ move] if config. closure_captures => highlight_closure_captures (
81- sema,
82- token. parent ( ) . and_then ( ast:: ClosureExpr :: cast) ?,
83- file_id,
84- ) ,
75+ T ! [ |] if config. closure_captures => highlight_closure_captures ( sema, token, file_id) ,
76+ T ! [ move] if config. closure_captures => highlight_closure_captures ( sema, token, file_id) ,
8577 _ if config. references => highlight_references ( sema, & syntax, token, file_id) ,
8678 _ => None ,
8779 }
8880}
8981
9082fn highlight_closure_captures (
9183 sema : & Semantics < ' _ , RootDatabase > ,
92- node : ast :: ClosureExpr ,
84+ token : SyntaxToken ,
9385 file_id : FileId ,
9486) -> Option < Vec < HighlightedRange > > {
95- let search_range = node. body ( ) ?. syntax ( ) . text_range ( ) ;
96- let ty = & sema. type_of_expr ( & node. into ( ) ) ?. original ;
87+ let closure = token. parent_ancestors ( ) . take ( 2 ) . find_map ( ast:: ClosureExpr :: cast) ?;
88+ let search_range = closure. body ( ) ?. syntax ( ) . text_range ( ) ;
89+ let ty = & sema. type_of_expr ( & closure. into ( ) ) ?. original ;
9790 let c = ty. as_closure ( ) ?;
9891 Some (
9992 c. captured_items ( sema. db )
0 commit comments