@@ -926,7 +926,7 @@ fn classify_name_ref<'db>(
926926 receiver_ty,
927927 kind: DotAccessKind :: Field { receiver_is_ambiguous_float_literal } ,
928928 receiver,
929- ctx: DotAccessExprCtx { in_block_expr: is_in_block( field. syntax( ) ) , in_breakable: is_in_breakable( field. syntax( ) ) }
929+ ctx: DotAccessExprCtx { in_block_expr: is_in_block( field. syntax( ) ) , in_breakable: is_in_breakable( field. syntax( ) ) . unzip ( ) . 0 }
930930 } ) ;
931931 return Some ( make_res( kind) ) ;
932932 } ,
@@ -941,7 +941,7 @@ fn classify_name_ref<'db>(
941941 receiver_ty: receiver. as_ref( ) . and_then( |it| sema. type_of_expr( it) ) ,
942942 kind: DotAccessKind :: Method { has_parens } ,
943943 receiver,
944- ctx: DotAccessExprCtx { in_block_expr: is_in_block( method. syntax( ) ) , in_breakable: is_in_breakable( method. syntax( ) ) }
944+ ctx: DotAccessExprCtx { in_block_expr: is_in_block( method. syntax( ) ) , in_breakable: is_in_breakable( method. syntax( ) ) . unzip ( ) . 0 }
945945 } ) ;
946946 return Some ( make_res( kind) ) ;
947947 } ,
@@ -1229,7 +1229,7 @@ fn classify_name_ref<'db>(
12291229 let make_path_kind_expr = |expr : ast:: Expr | {
12301230 let it = expr. syntax ( ) ;
12311231 let in_block_expr = is_in_block ( it) ;
1232- let in_loop_body = is_in_breakable ( it) ;
1232+ let ( in_loop_body, innermost_breakable ) = is_in_breakable ( it) . unzip ( ) ;
12331233 let after_if_expr = after_if_expr ( it. clone ( ) ) ;
12341234 let ref_expr_parent =
12351235 path. as_single_name_ref ( ) . and_then ( |_| it. parent ( ) ) . and_then ( ast:: RefExpr :: cast) ;
@@ -1283,6 +1283,11 @@ fn classify_name_ref<'db>(
12831283 None => ( None , None ) ,
12841284 }
12851285 } ;
1286+ let innermost_breakable_ty = innermost_breakable
1287+ . and_then ( ast:: Expr :: cast)
1288+ . and_then ( |expr| find_node_in_file_compensated ( sema, original_file, & expr) )
1289+ . and_then ( |expr| sema. type_of_expr ( & expr) )
1290+ . map ( |ty| if ty. original . is_never ( ) { ty. adjusted ( ) } else { ty. original ( ) } ) ;
12861291 let is_func_update = func_update_record ( it) ;
12871292 let in_condition = is_in_condition ( & expr) ;
12881293 let after_incomplete_let = after_incomplete_let ( it. clone ( ) ) . is_some ( ) ;
@@ -1316,6 +1321,7 @@ fn classify_name_ref<'db>(
13161321 after_amp,
13171322 is_func_update,
13181323 innermost_ret_ty,
1324+ innermost_breakable_ty,
13191325 self_param,
13201326 in_value,
13211327 incomplete_let,
@@ -1865,24 +1871,22 @@ fn is_in_token_of_for_loop(path: &ast::Path) -> bool {
18651871 . unwrap_or ( false )
18661872}
18671873
1868- fn is_in_breakable ( node : & SyntaxNode ) -> BreakableKind {
1874+ fn is_in_breakable ( node : & SyntaxNode ) -> Option < ( BreakableKind , SyntaxNode ) > {
18691875 node. ancestors ( )
18701876 . take_while ( |it| it. kind ( ) != SyntaxKind :: FN && it. kind ( ) != SyntaxKind :: CLOSURE_EXPR )
18711877 . find_map ( |it| {
18721878 let ( breakable, loop_body) = match_ast ! {
18731879 match it {
1874- ast:: ForExpr ( it) => ( BreakableKind :: For , it. loop_body( ) ) ,
1875- ast:: WhileExpr ( it) => ( BreakableKind :: While , it. loop_body( ) ) ,
1876- ast:: LoopExpr ( it) => ( BreakableKind :: Loop , it. loop_body( ) ) ,
1877- ast:: BlockExpr ( it) => return it. label( ) . map( |_| BreakableKind :: Block ) ,
1880+ ast:: ForExpr ( it) => ( BreakableKind :: For , it. loop_body( ) ? ) ,
1881+ ast:: WhileExpr ( it) => ( BreakableKind :: While , it. loop_body( ) ? ) ,
1882+ ast:: LoopExpr ( it) => ( BreakableKind :: Loop , it. loop_body( ) ? ) ,
1883+ ast:: BlockExpr ( it) => return it. label( ) . map( |_| ( BreakableKind :: Block , it . syntax ( ) . clone ( ) ) ) ,
18781884 _ => return None ,
18791885 }
18801886 } ;
1881- loop_body
1882- . filter ( |it| it. syntax ( ) . text_range ( ) . contains_range ( node. text_range ( ) ) )
1883- . map ( |_| breakable)
1887+ loop_body. syntax ( ) . text_range ( ) . contains_range ( node. text_range ( ) )
1888+ . then_some ( ( breakable, it) )
18841889 } )
1885- . unwrap_or ( BreakableKind :: None )
18861890}
18871891
18881892fn is_in_block ( node : & SyntaxNode ) -> bool {
0 commit comments