@@ -90,7 +90,6 @@ use rustc_index::{IndexSlice, IndexVec};
90
90
use rustc_middle:: middle:: region;
91
91
use rustc_middle:: mir:: * ;
92
92
use rustc_middle:: thir:: { Expr , LintLevel } ;
93
- use rustc_middle:: ty:: Ty ;
94
93
use rustc_session:: lint:: Level ;
95
94
use rustc_span:: { Span , DUMMY_SP } ;
96
95
@@ -660,14 +659,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
660
659
( None , Some ( _) ) => {
661
660
panic ! ( "`return`, `become` and `break` with value and must have a destination" )
662
661
}
663
- ( None , None ) if self . tcx . sess . instrument_coverage ( ) => {
664
- // Unlike `break` and `return`, which push an `Assign` statement to MIR, from which
665
- // a Coverage code region can be generated, `continue` needs no `Assign`; but
666
- // without one, the `InstrumentCoverage` MIR pass cannot generate a code region for
667
- // `continue`. Coverage will be missing unless we add a dummy `Assign` to MIR.
668
- self . add_dummy_assignment ( span, block, source_info) ;
662
+ ( None , None ) => {
663
+ if self . tcx . sess . instrument_coverage ( ) {
664
+ // Normally we wouldn't build any MIR in this case, but that makes it
665
+ // harder for coverage instrumentation to extract a relevant span for
666
+ // `continue` expressions. So here we inject a dummy statement with the
667
+ // desired span.
668
+ self . cfg . push_coverage_span_marker ( block, source_info) ;
669
+ }
669
670
}
670
- ( None , None ) => { }
671
671
}
672
672
673
673
let region_scope = self . scopes . breakable_scopes [ break_index] . region_scope ;
@@ -723,14 +723,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
723
723
self . cfg . terminate ( block, source_info, TerminatorKind :: UnwindResume ) ;
724
724
}
725
725
726
- // Add a dummy `Assign` statement to the CFG, with the span for the source code's `continue`
727
- // statement.
728
- fn add_dummy_assignment ( & mut self , span : Span , block : BasicBlock , source_info : SourceInfo ) {
729
- let local_decl = LocalDecl :: new ( Ty :: new_unit ( self . tcx ) , span) ;
730
- let temp_place = Place :: from ( self . local_decls . push ( local_decl) ) ;
731
- self . cfg . push_assign_unit ( block, source_info, temp_place, self . tcx ) ;
732
- }
733
-
734
726
fn leave_top_scope ( & mut self , block : BasicBlock ) -> BasicBlock {
735
727
// If we are emitting a `drop` statement, we need to have the cached
736
728
// diverge cleanup pads ready in case that drop panics.
0 commit comments