@@ -7,7 +7,7 @@ use hir::{HirDisplay, Semantics};
77use ide_db:: { FileRange , RootDatabase } ;
88use span:: EditionedFileId ;
99use syntax:: {
10- ast:: { self , AstNode , HasName } ,
10+ ast:: { self , AstNode , HasLoopBody , HasName } ,
1111 match_ast, SyntaxKind , SyntaxNode , T ,
1212} ;
1313
@@ -57,9 +57,24 @@ pub(super) fn hints(
5757 // the actual number of lines in this case should be the line count of the parent BlockExpr,
5858 // which the `min_lines` config cares about
5959 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+
6276 let lifetime = label. lifetime ( ) . map_or_else ( String :: new, |it| it. to_string ( ) ) ;
77+
6378 ( lifetime, Some ( label. syntax ( ) . text_range ( ) ) )
6479 } else if let Some ( block) = ast:: BlockExpr :: cast ( node. clone ( ) ) {
6580 closing_token = block. stmt_list ( ) ?. r_curly_token ( ) ?;
@@ -219,6 +234,19 @@ fn test() {
219234 //^ 'do_a
220235 }
221236 //^ '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+
222250 }
223251//^ fn test
224252"# ,
0 commit comments