@@ -403,6 +403,21 @@ enum NeedsTemporary {
403
403
#[ must_use = "if you don't use one of these results, you're leaving a dangling edge" ]
404
404
struct BlockAnd < T > ( BasicBlock , T ) ;
405
405
406
+ impl BlockAnd < ( ) > {
407
+ /// Unpacks `BlockAnd<()>` into a [`BasicBlock`].
408
+ #[ must_use]
409
+ fn unpack_block ( self ) -> BasicBlock {
410
+ let Self ( block, ( ) ) = self ;
411
+ block
412
+ }
413
+
414
+ /// Explicitly discards a [`BlockAnd<()>`] value.
415
+ ///
416
+ /// This is similar to writing `let _ = ...`, except that it is also
417
+ /// (a) postfix, and (b) searchable.
418
+ fn unpack_discard ( self ) { }
419
+ }
420
+
406
421
trait BlockAndExtension {
407
422
fn and < T > ( self , v : T ) -> BlockAnd < T > ;
408
423
fn unit ( self ) -> BlockAnd < ( ) > ;
@@ -426,11 +441,6 @@ macro_rules! unpack {
426
441
$x = b;
427
442
v
428
443
} } ;
429
-
430
- ( $c: expr) => { {
431
- let BlockAnd ( b, ( ) ) = $c;
432
- b
433
- } } ;
434
444
}
435
445
436
446
///////////////////////////////////////////////////////////////////////////
@@ -516,21 +526,24 @@ fn construct_fn<'tcx>(
516
526
region:: Scope { id : body. id ( ) . hir_id . local_id , data : region:: ScopeData :: Arguments } ;
517
527
let source_info = builder. source_info ( span) ;
518
528
let call_site_s = ( call_site_scope, source_info) ;
519
- unpack ! ( builder. in_scope( call_site_s, LintLevel :: Inherited , |builder| {
520
- let arg_scope_s = ( arg_scope, source_info) ;
521
- // Attribute epilogue to function's closing brace
522
- let fn_end = span_with_body. shrink_to_hi( ) ;
523
- let return_block =
524
- unpack!( builder. in_breakable_scope( None , Place :: return_place( ) , fn_end, |builder| {
525
- Some ( builder. in_scope( arg_scope_s, LintLevel :: Inherited , |builder| {
526
- builder. args_and_body( START_BLOCK , arguments, arg_scope, expr)
527
- } ) )
528
- } ) ) ;
529
- let source_info = builder. source_info( fn_end) ;
530
- builder. cfg. terminate( return_block, source_info, TerminatorKind :: Return ) ;
531
- builder. build_drop_trees( ) ;
532
- return_block. unit( )
533
- } ) ) ;
529
+ builder
530
+ . in_scope ( call_site_s, LintLevel :: Inherited , |builder| {
531
+ let arg_scope_s = ( arg_scope, source_info) ;
532
+ // Attribute epilogue to function's closing brace
533
+ let fn_end = span_with_body. shrink_to_hi ( ) ;
534
+ let return_block = builder
535
+ . in_breakable_scope ( None , Place :: return_place ( ) , fn_end, |builder| {
536
+ Some ( builder. in_scope ( arg_scope_s, LintLevel :: Inherited , |builder| {
537
+ builder. args_and_body ( START_BLOCK , arguments, arg_scope, expr)
538
+ } ) )
539
+ } )
540
+ . unpack_block ( ) ;
541
+ let source_info = builder. source_info ( fn_end) ;
542
+ builder. cfg . terminate ( return_block, source_info, TerminatorKind :: Return ) ;
543
+ builder. build_drop_trees ( ) ;
544
+ return_block. unit ( )
545
+ } )
546
+ . unpack_discard ( ) ;
534
547
535
548
let mut body = builder. finish ( ) ;
536
549
0 commit comments