@@ -403,6 +403,21 @@ enum NeedsTemporary {
403403#[ must_use = "if you don't use one of these results, you're leaving a dangling edge" ]
404404struct BlockAnd < T > ( BasicBlock , T ) ;
405405
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+
406421trait BlockAndExtension {
407422 fn and < T > ( self , v : T ) -> BlockAnd < T > ;
408423 fn unit ( self ) -> BlockAnd < ( ) > ;
@@ -426,11 +441,6 @@ macro_rules! unpack {
426441 $x = b;
427442 v
428443 } } ;
429-
430- ( $c: expr) => { {
431- let BlockAnd ( b, ( ) ) = $c;
432- b
433- } } ;
434444}
435445
436446///////////////////////////////////////////////////////////////////////////
@@ -516,21 +526,24 @@ fn construct_fn<'tcx>(
516526 region:: Scope { id : body. id ( ) . hir_id . local_id , data : region:: ScopeData :: Arguments } ;
517527 let source_info = builder. source_info ( span) ;
518528 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 ( ) ;
534547
535548 let mut body = builder. finish ( ) ;
536549
0 commit comments