@@ -225,31 +225,7 @@ impl LoweringContext<'_> {
225
225
hir:: LoopSource :: Loop ,
226
226
)
227
227
} ) ,
228
- ExprKind :: TryBlock ( ref body) => {
229
- self . with_catch_scope ( body. id , |this| {
230
- let unstable_span = this. mark_span_with_reason (
231
- DesugaringKind :: TryBlock ,
232
- body. span ,
233
- this. allow_try_trait . clone ( ) ,
234
- ) ;
235
- let mut block = this. lower_block ( body, true ) . into_inner ( ) ;
236
- let tail = block. expr . take ( ) . map_or_else (
237
- || {
238
- let span = this. sess . source_map ( ) . end_point ( unstable_span) ;
239
- hir:: Expr {
240
- span,
241
- node : hir:: ExprKind :: Tup ( hir_vec ! [ ] ) ,
242
- attrs : ThinVec :: new ( ) ,
243
- hir_id : this. next_id ( ) ,
244
- }
245
- } ,
246
- |x : P < hir:: Expr > | x. into_inner ( ) ,
247
- ) ;
248
- block. expr = Some ( this. wrap_in_try_constructor (
249
- sym:: from_ok, tail, unstable_span) ) ;
250
- hir:: ExprKind :: Block ( P ( block) , None )
251
- } )
252
- }
228
+ ExprKind :: TryBlock ( ref body) => self . lower_expr_try_block ( body) ,
253
229
ExprKind :: Match ( ref expr, ref arms) => hir:: ExprKind :: Match (
254
230
P ( self . lower_expr ( expr) ) ,
255
231
arms. iter ( ) . map ( |x| self . lower_arm ( x) ) . collect ( ) ,
@@ -375,6 +351,23 @@ impl LoweringContext<'_> {
375
351
}
376
352
}
377
353
354
+ fn lower_expr_try_block ( & mut self , body : & Block ) -> hir:: ExprKind {
355
+ self . with_catch_scope ( body. id , |this| {
356
+ let unstable_span = this. mark_span_with_reason (
357
+ DesugaringKind :: TryBlock ,
358
+ body. span ,
359
+ this. allow_try_trait . clone ( ) ,
360
+ ) ;
361
+ let mut block = this. lower_block ( body, true ) . into_inner ( ) ;
362
+ let tail = block. expr . take ( ) . map_or_else (
363
+ || this. expr_unit ( this. sess . source_map ( ) . end_point ( unstable_span) ) ,
364
+ |x : P < hir:: Expr > | x. into_inner ( ) ,
365
+ ) ;
366
+ block. expr = Some ( this. wrap_in_try_constructor ( sym:: from_ok, tail, unstable_span) ) ;
367
+ hir:: ExprKind :: Block ( P ( block) , None )
368
+ } )
369
+ }
370
+
378
371
/// Desugar `<expr>.await` into:
379
372
/// ```rust
380
373
/// {
0 commit comments