File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,7 @@ impl ExprCollector<'_> {
505505 . map ( |it| Interned :: new ( TypeRef :: from_ast ( & this. ctx ( ) , it) ) ) ;
506506
507507 let prev_is_lowering_generator = mem:: take ( & mut this. is_lowering_generator ) ;
508+ let prev_try_block_label = this. current_try_block_label . take ( ) ;
508509
509510 let body = this. collect_expr_opt ( e. body ( ) ) ;
510511
@@ -520,11 +521,11 @@ impl ExprCollector<'_> {
520521 } else {
521522 ClosureKind :: Closure
522523 } ;
523- this. is_lowering_generator = prev_is_lowering_generator;
524524 let capture_by =
525525 if e. move_token ( ) . is_some ( ) { CaptureBy :: Value } else { CaptureBy :: Ref } ;
526526 this. is_lowering_generator = prev_is_lowering_generator;
527527 this. current_binding_owner = prev_binding_owner;
528+ this. current_try_block_label = prev_try_block_label;
528529 this. body . exprs [ result_expr_id] = Expr :: Closure {
529530 args : args. into ( ) ,
530531 arg_types : arg_types. into ( ) ,
Original file line number Diff line number Diff line change @@ -132,6 +132,24 @@ fn test() {
132132 // ^^^^^^^ error: can't break with a value in this position
133133 }
134134}
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+ }
135153"# ,
136154 ) ;
137155 }
You can’t perform that action at this time.
0 commit comments