@@ -90,7 +90,6 @@ use rustc_index::{IndexSlice, IndexVec};
9090use  rustc_middle:: middle:: region; 
9191use  rustc_middle:: mir:: * ; 
9292use  rustc_middle:: thir:: { Expr ,  LintLevel } ; 
93- use  rustc_middle:: ty:: Ty ; 
9493use  rustc_session:: lint:: Level ; 
9594use  rustc_span:: { Span ,  DUMMY_SP } ; 
9695
@@ -660,14 +659,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
660659            ( None ,  Some ( _) )  => { 
661660                panic ! ( "`return`, `become` and `break` with value and must have a destination" ) 
662661            } 
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+                 } 
669670            } 
670-             ( None ,  None )  => { } 
671671        } 
672672
673673        let  region_scope = self . scopes . breakable_scopes [ break_index] . region_scope ; 
@@ -723,14 +723,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
723723        self . cfg . terminate ( block,  source_info,  TerminatorKind :: UnwindResume ) ; 
724724    } 
725725
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- 
734726    fn  leave_top_scope ( & mut  self ,  block :  BasicBlock )  -> BasicBlock  { 
735727        // If we are emitting a `drop` statement, we need to have the cached 
736728        // diverge cleanup pads ready in case that drop panics. 
0 commit comments