@@ -644,24 +644,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
644
644
}
645
645
} ;
646
646
647
- if let Some ( destination) = destination {
648
- if let Some ( value) = value {
647
+ match ( destination, value ) {
648
+ ( Some ( destination ) , Some ( value) ) => {
649
649
debug ! ( "stmt_expr Break val block_context.push(SubExpr)" ) ;
650
650
self . block_context . push ( BlockFrame :: SubExpr ) ;
651
651
unpack ! ( block = self . expr_into_dest( destination, block, value) ) ;
652
652
self . block_context . pop ( ) ;
653
- } else {
653
+ }
654
+ ( Some ( destination) , None ) => {
654
655
self . cfg . push_assign_unit ( block, source_info, destination, self . tcx )
655
656
}
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 ( ) => {
659
661
// Unlike `break` and `return`, which push an `Assign` statement to MIR, from which
660
662
// a Coverage code region can be generated, `continue` needs no `Assign`; but
661
663
// without one, the `InstrumentCoverage` MIR pass cannot generate a code region for
662
664
// `continue`. Coverage will be missing unless we add a dummy `Assign` to MIR.
663
665
self . add_dummy_assignment ( span, block, source_info) ;
664
666
}
667
+ ( None , None ) => { }
665
668
}
666
669
667
670
let region_scope = self . scopes . breakable_scopes [ break_index] . region_scope ;
@@ -671,12 +674,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
671
674
} else {
672
675
self . scopes . breakable_scopes [ break_index] . continue_drops . as_mut ( ) . unwrap ( )
673
676
} ;
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
+
680
683
drops. add_entry ( block, drop_idx) ;
681
684
682
685
// `build_drop_trees` doesn't have access to our source_info, so we
0 commit comments