@@ -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 ;
0 commit comments