@@ -902,7 +902,7 @@ fn classify_name_ref<'db>(
902902 receiver_ty,
903903 kind: DotAccessKind :: Field { receiver_is_ambiguous_float_literal } ,
904904 receiver,
905- ctx: DotAccessExprCtx { in_block_expr: is_in_block( field. syntax( ) ) , in_breakable: is_in_breakable( field. syntax( ) ) }
905+ ctx: DotAccessExprCtx { in_block_expr: is_in_block( field. syntax( ) ) , in_breakable: is_in_breakable( field. syntax( ) ) . 0 }
906906 } ) ;
907907 return Some ( make_res( kind) ) ;
908908 } ,
@@ -917,7 +917,7 @@ fn classify_name_ref<'db>(
917917 receiver_ty: receiver. as_ref( ) . and_then( |it| sema. type_of_expr( it) ) ,
918918 kind: DotAccessKind :: Method { has_parens } ,
919919 receiver,
920- ctx: DotAccessExprCtx { in_block_expr: is_in_block( method. syntax( ) ) , in_breakable: is_in_breakable( method. syntax( ) ) }
920+ ctx: DotAccessExprCtx { in_block_expr: is_in_block( method. syntax( ) ) , in_breakable: is_in_breakable( method. syntax( ) ) . 0 }
921921 } ) ;
922922 return Some ( make_res( kind) ) ;
923923 } ,
@@ -1223,7 +1223,7 @@ fn classify_name_ref<'db>(
12231223 let make_path_kind_expr = |expr : ast:: Expr | {
12241224 let it = expr. syntax ( ) ;
12251225 let in_block_expr = is_in_block ( it) ;
1226- let in_loop_body = is_in_breakable ( it) ;
1226+ let ( in_loop_body, innermost_breakable ) = is_in_breakable ( it) ;
12271227 let after_if_expr = after_if_expr ( it. clone ( ) ) ;
12281228 let ref_expr_parent =
12291229 path. as_single_name_ref ( ) . and_then ( |_| it. parent ( ) ) . and_then ( ast:: RefExpr :: cast) ;
@@ -1277,6 +1277,11 @@ fn classify_name_ref<'db>(
12771277 None => ( None , None ) ,
12781278 }
12791279 } ;
1280+ let innermost_breakable_ty = innermost_breakable
1281+ . and_then ( ast:: Expr :: cast)
1282+ . and_then ( |expr| find_node_in_file_compensated ( sema, original_file, & expr) )
1283+ . and_then ( |expr| sema. type_of_expr ( & expr) )
1284+ . map ( |ty| if ty. original . is_never ( ) { ty. adjusted ( ) } else { ty. original ( ) } ) ;
12801285 let is_func_update = func_update_record ( it) ;
12811286 let in_condition = is_in_condition ( & expr) ;
12821287 let after_incomplete_let = after_incomplete_let ( it. clone ( ) ) . is_some ( ) ;
@@ -1307,6 +1312,7 @@ fn classify_name_ref<'db>(
13071312 after_amp,
13081313 is_func_update,
13091314 innermost_ret_ty,
1315+ innermost_breakable_ty,
13101316 self_param,
13111317 in_value,
13121318 incomplete_let,
@@ -1854,7 +1860,7 @@ fn is_in_token_of_for_loop(path: &ast::Path) -> bool {
18541860 . unwrap_or ( false )
18551861}
18561862
1857- fn is_in_breakable ( node : & SyntaxNode ) -> BreakableKind {
1863+ fn is_in_breakable ( node : & SyntaxNode ) -> ( BreakableKind , Option < SyntaxNode > ) {
18581864 node. ancestors ( )
18591865 . take_while ( |it| it. kind ( ) != SyntaxKind :: FN && it. kind ( ) != SyntaxKind :: CLOSURE_EXPR )
18601866 . find_map ( |it| {
@@ -1863,15 +1869,15 @@ fn is_in_breakable(node: &SyntaxNode) -> BreakableKind {
18631869 ast:: ForExpr ( it) => ( BreakableKind :: For , it. loop_body( ) ) ,
18641870 ast:: WhileExpr ( it) => ( BreakableKind :: While , it. loop_body( ) ) ,
18651871 ast:: LoopExpr ( it) => ( BreakableKind :: Loop , it. loop_body( ) ) ,
1866- ast:: BlockExpr ( it) => return it. label( ) . map( |_| BreakableKind :: Block ) ,
1872+ ast:: BlockExpr ( it) => return it. label( ) . map( |_| ( BreakableKind :: Block , Some ( it . syntax ( ) . clone ( ) ) ) ) ,
18671873 _ => return None ,
18681874 }
18691875 } ;
18701876 loop_body
18711877 . filter ( |it| it. syntax ( ) . text_range ( ) . contains_range ( node. text_range ( ) ) )
1872- . map ( |_| breakable)
1878+ . map ( |_| ( breakable, Some ( it ) ) )
18731879 } )
1874- . unwrap_or ( BreakableKind :: None )
1880+ . unwrap_or ( ( BreakableKind :: None , None ) )
18751881}
18761882
18771883fn is_in_block ( node : & SyntaxNode ) -> bool {
0 commit comments