@@ -644,24 +644,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
644644 }
645645 } ;
646646
647- if let Some ( destination) = destination {
648- if let Some ( value) = value {
647+ match ( destination, value ) {
648+ ( Some ( destination ) , Some ( value) ) => {
649649 debug ! ( "stmt_expr Break val block_context.push(SubExpr)" ) ;
650650 self . block_context . push ( BlockFrame :: SubExpr ) ;
651651 unpack ! ( block = self . expr_into_dest( destination, block, value) ) ;
652652 self . block_context . pop ( ) ;
653- } else {
653+ }
654+ ( Some ( destination) , None ) => {
654655 self . cfg . push_assign_unit ( block, source_info, destination, self . tcx )
655656 }
656- } else {
657- assert ! ( value. is_none( ) , "`return` and `break` should have a destination" ) ;
658- if self . tcx . sess . instrument_coverage ( ) {
657+ ( None , Some ( _) ) => {
658+ panic ! ( "`return`, `become` and `break` with value and must have a destination" )
659+ }
660+ ( None , None ) if self . tcx . sess . instrument_coverage ( ) => {
659661 // Unlike `break` and `return`, which push an `Assign` statement to MIR, from which
660662 // a Coverage code region can be generated, `continue` needs no `Assign`; but
661663 // without one, the `InstrumentCoverage` MIR pass cannot generate a code region for
662664 // `continue`. Coverage will be missing unless we add a dummy `Assign` to MIR.
663665 self . add_dummy_assignment ( span, block, source_info) ;
664666 }
667+ ( None , None ) => { }
665668 }
666669
667670 let region_scope = self . scopes . breakable_scopes [ break_index] . region_scope ;
@@ -671,12 +674,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
671674 } else {
672675 self . scopes . breakable_scopes [ break_index] . continue_drops . as_mut ( ) . unwrap ( )
673676 } ;
674- let mut drop_idx = ROOT_NODE ;
675- for scope in & self . scopes . scopes [ scope_index + 1 ..] {
676- for drop in & scope . drops {
677- drop_idx = drops . add_drop ( * drop , drop_idx ) ;
678- }
679- }
677+
678+ let drop_idx = self . scopes . scopes [ scope_index + 1 ..]
679+ . iter ( )
680+ . flat_map ( |scope| & scope . drops )
681+ . fold ( ROOT_NODE , |drop_idx , & drop| drops . add_drop ( drop , drop_idx ) ) ;
682+
680683 drops. add_entry ( block, drop_idx) ;
681684
682685 // `build_drop_trees` doesn't have access to our source_info, so we
0 commit comments