@@ -902,7 +902,7 @@ fn classify_name_ref<'db>(
902
902
receiver_ty,
903
903
kind: DotAccessKind :: Field { receiver_is_ambiguous_float_literal } ,
904
904
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 }
906
906
} ) ;
907
907
return Some ( make_res( kind) ) ;
908
908
} ,
@@ -917,7 +917,7 @@ fn classify_name_ref<'db>(
917
917
receiver_ty: receiver. as_ref( ) . and_then( |it| sema. type_of_expr( it) ) ,
918
918
kind: DotAccessKind :: Method { has_parens } ,
919
919
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 }
921
921
} ) ;
922
922
return Some ( make_res( kind) ) ;
923
923
} ,
@@ -1223,7 +1223,7 @@ fn classify_name_ref<'db>(
1223
1223
let make_path_kind_expr = |expr : ast:: Expr | {
1224
1224
let it = expr. syntax ( ) ;
1225
1225
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) ;
1227
1227
let after_if_expr = after_if_expr ( it. clone ( ) ) ;
1228
1228
let ref_expr_parent =
1229
1229
path. as_single_name_ref ( ) . and_then ( |_| it. parent ( ) ) . and_then ( ast:: RefExpr :: cast) ;
@@ -1277,6 +1277,11 @@ fn classify_name_ref<'db>(
1277
1277
None => ( None , None ) ,
1278
1278
}
1279
1279
} ;
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 ( ) } ) ;
1280
1285
let is_func_update = func_update_record ( it) ;
1281
1286
let in_condition = is_in_condition ( & expr) ;
1282
1287
let after_incomplete_let = after_incomplete_let ( it. clone ( ) ) . is_some ( ) ;
@@ -1307,6 +1312,7 @@ fn classify_name_ref<'db>(
1307
1312
after_amp,
1308
1313
is_func_update,
1309
1314
innermost_ret_ty,
1315
+ innermost_breakable_ty,
1310
1316
self_param,
1311
1317
in_value,
1312
1318
incomplete_let,
@@ -1854,7 +1860,7 @@ fn is_in_token_of_for_loop(path: &ast::Path) -> bool {
1854
1860
. unwrap_or ( false )
1855
1861
}
1856
1862
1857
- fn is_in_breakable ( node : & SyntaxNode ) -> BreakableKind {
1863
+ fn is_in_breakable ( node : & SyntaxNode ) -> ( BreakableKind , Option < SyntaxNode > ) {
1858
1864
node. ancestors ( )
1859
1865
. take_while ( |it| it. kind ( ) != SyntaxKind :: FN && it. kind ( ) != SyntaxKind :: CLOSURE_EXPR )
1860
1866
. find_map ( |it| {
@@ -1863,15 +1869,15 @@ fn is_in_breakable(node: &SyntaxNode) -> BreakableKind {
1863
1869
ast:: ForExpr ( it) => ( BreakableKind :: For , it. loop_body( ) ) ,
1864
1870
ast:: WhileExpr ( it) => ( BreakableKind :: While , it. loop_body( ) ) ,
1865
1871
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 ( ) ) ) ) ,
1867
1873
_ => return None ,
1868
1874
}
1869
1875
} ;
1870
1876
loop_body
1871
1877
. filter ( |it| it. syntax ( ) . text_range ( ) . contains_range ( node. text_range ( ) ) )
1872
- . map ( |_| breakable)
1878
+ . map ( |_| ( breakable, Some ( it ) ) )
1873
1879
} )
1874
- . unwrap_or ( BreakableKind :: None )
1880
+ . unwrap_or ( ( BreakableKind :: None , None ) )
1875
1881
}
1876
1882
1877
1883
fn is_in_block ( node : & SyntaxNode ) -> bool {
0 commit comments