File tree 2 files changed +20
-1
lines changed
ide-diagnostics/src/handlers 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,7 @@ impl ExprCollector<'_> {
505
505
. map ( |it| Interned :: new ( TypeRef :: from_ast ( & this. ctx ( ) , it) ) ) ;
506
506
507
507
let prev_is_lowering_generator = mem:: take ( & mut this. is_lowering_generator ) ;
508
+ let prev_try_block_label = this. current_try_block_label . take ( ) ;
508
509
509
510
let body = this. collect_expr_opt ( e. body ( ) ) ;
510
511
@@ -520,11 +521,11 @@ impl ExprCollector<'_> {
520
521
} else {
521
522
ClosureKind :: Closure
522
523
} ;
523
- this. is_lowering_generator = prev_is_lowering_generator;
524
524
let capture_by =
525
525
if e. move_token ( ) . is_some ( ) { CaptureBy :: Value } else { CaptureBy :: Ref } ;
526
526
this. is_lowering_generator = prev_is_lowering_generator;
527
527
this. current_binding_owner = prev_binding_owner;
528
+ this. current_try_block_label = prev_try_block_label;
528
529
this. body . exprs [ result_expr_id] = Expr :: Closure {
529
530
args : args. into ( ) ,
530
531
arg_types : arg_types. into ( ) ,
Original file line number Diff line number Diff line change @@ -132,6 +132,24 @@ fn test() {
132
132
// ^^^^^^^ error: can't break with a value in this position
133
133
}
134
134
}
135
+ "# ,
136
+ ) ;
137
+ }
138
+
139
+ #[ test]
140
+ fn try_block_desugaring_inside_closure ( ) {
141
+ // regression test for #14701
142
+ check_diagnostics (
143
+ r#"
144
+ //- minicore: option, try
145
+ fn test() {
146
+ try {
147
+ || {
148
+ let x = Some(2);
149
+ Some(x?)
150
+ };
151
+ };
152
+ }
135
153
"# ,
136
154
) ;
137
155
}
You can’t perform that action at this time.
0 commit comments