File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,23 @@ fn highlight_references(
232
232
}
233
233
}
234
234
235
+ // highlight the tail expr of the labelled block
236
+ if matches ! ( def, Definition :: Label ( _) ) {
237
+ let label = token. parent_ancestors ( ) . nth ( 1 ) . and_then ( ast:: Label :: cast) ;
238
+ if let Some ( block) =
239
+ label. and_then ( |label| label. syntax ( ) . parent ( ) ) . and_then ( ast:: BlockExpr :: cast)
240
+ {
241
+ for_each_tail_expr ( & block. into ( ) , & mut |tail| {
242
+ if !matches ! ( tail, ast:: Expr :: BreakExpr ( _) ) {
243
+ res. insert ( HighlightedRange {
244
+ range : tail. syntax ( ) . text_range ( ) ,
245
+ category : ReferenceCategory :: empty ( ) ,
246
+ } ) ;
247
+ }
248
+ } ) ;
249
+ }
250
+ }
251
+
235
252
// highlight the defs themselves
236
253
match def {
237
254
Definition :: Local ( local) => {
@@ -2098,6 +2115,26 @@ fn foo() {
2098
2115
// ^
2099
2116
}
2100
2117
}
2118
+ "# ,
2119
+ ) ;
2120
+ }
2121
+
2122
+ #[ test]
2123
+ fn labeled_block_tail_expr_2 ( ) {
2124
+ check (
2125
+ r#"
2126
+ fn foo() {
2127
+ let _ = 'b$0lk: {
2128
+ // ^^^^
2129
+ let x = 1;
2130
+ if true { break 'blk 42; }
2131
+ // ^^^^
2132
+ if false { break 'blk 24; }
2133
+ // ^^^^
2134
+ 100
2135
+ // ^^^
2136
+ };
2137
+ }
2101
2138
"# ,
2102
2139
) ;
2103
2140
}
You can’t perform that action at this time.
0 commit comments