@@ -7,7 +7,7 @@ use hir::{HirDisplay, Semantics};
7
7
use ide_db:: { FileRange , RootDatabase } ;
8
8
use span:: EditionedFileId ;
9
9
use syntax:: {
10
- ast:: { self , AstNode , HasName } ,
10
+ ast:: { self , AstNode , HasLoopBody , HasName } ,
11
11
match_ast, SyntaxKind , SyntaxNode , T ,
12
12
} ;
13
13
@@ -57,9 +57,24 @@ pub(super) fn hints(
57
57
// the actual number of lines in this case should be the line count of the parent BlockExpr,
58
58
// which the `min_lines` config cares about
59
59
node = node. parent ( ) ?;
60
- let block = label. syntax ( ) . parent ( ) . and_then ( ast:: BlockExpr :: cast) ?;
61
- closing_token = block. stmt_list ( ) ?. r_curly_token ( ) ?;
60
+
61
+ let parent = label. syntax ( ) . parent ( ) ?;
62
+ let block;
63
+ match_ast ! {
64
+ match parent {
65
+ ast:: BlockExpr ( block_expr) => {
66
+ block = block_expr. stmt_list( ) ?;
67
+ } ,
68
+ ast:: AnyHasLoopBody ( loop_expr) => {
69
+ block = loop_expr. loop_body( ) ?. stmt_list( ) ?;
70
+ } ,
71
+ _ => return None ,
72
+ }
73
+ }
74
+ closing_token = block. r_curly_token ( ) ?;
75
+
62
76
let lifetime = label. lifetime ( ) . map_or_else ( String :: new, |it| it. to_string ( ) ) ;
77
+
63
78
( lifetime, Some ( label. syntax ( ) . text_range ( ) ) )
64
79
} else if let Some ( block) = ast:: BlockExpr :: cast ( node. clone ( ) ) {
65
80
closing_token = block. stmt_list ( ) ?. r_curly_token ( ) ?;
@@ -219,6 +234,19 @@ fn test() {
219
234
//^ 'do_a
220
235
}
221
236
//^ 'end
237
+
238
+ 'a: loop {
239
+ 'b: for i in 0..5 {
240
+ 'c: while true {
241
+
242
+
243
+ }
244
+ //^ 'c
245
+ }
246
+ //^ 'b
247
+ }
248
+ //^ 'a
249
+
222
250
}
223
251
//^ fn test
224
252
"# ,
0 commit comments