File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,6 +232,22 @@ fn highlight_references(
232232 }
233233 }
234234
235+ if matches ! ( def, Definition :: Label ( _) ) {
236+ let label = token. parent_ancestors ( ) . find_map ( ast:: Label :: cast) ;
237+ if let Some ( block) =
238+ label. and_then ( |label| label. syntax ( ) . parent ( ) ) . and_then ( ast:: BlockExpr :: cast)
239+ {
240+ for_each_tail_expr ( & block. into ( ) , & mut |tail| {
241+ if !matches ! ( tail, ast:: Expr :: BreakExpr ( _) ) {
242+ res. insert ( HighlightedRange {
243+ range : tail. syntax ( ) . text_range ( ) ,
244+ category : ReferenceCategory :: empty ( ) ,
245+ } ) ;
246+ }
247+ } ) ;
248+ }
249+ }
250+
235251 // highlight the defs themselves
236252 match def {
237253 Definition :: Local ( local) => {
@@ -2098,6 +2114,26 @@ fn foo() {
20982114 // ^
20992115 }
21002116}
2117+ "# ,
2118+ ) ;
2119+ }
2120+
2121+ #[ test]
2122+ fn labeled_block_tail_expr_2 ( ) {
2123+ check (
2124+ r#"
2125+ fn foo() {
2126+ let _ = 'b$0lk: {
2127+ // ^^^^
2128+ let x = 1;
2129+ if true { break 'blk 42; }
2130+ // ^^^^
2131+ if false { break 'blk 24; }
2132+ // ^^^^
2133+ 100
2134+ // ^^^
2135+ };
2136+ }
21012137"# ,
21022138 ) ;
21032139 }
You can’t perform that action at this time.
0 commit comments