File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
compiler/rustc_mir_transform/src/coverage Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -379,18 +379,22 @@ impl<'a> CoverageSpansGenerator<'a> {
379379 return ;
380380 }
381381
382- let merged_prefix_len = self . curr_original_span . lo ( ) - curr. span . lo ( ) ;
383- let after_macro_bang = merged_prefix_len + BytePos ( visible_macro. as_str ( ) . len ( ) as u32 + 1 ) ;
384- if self . curr ( ) . span . lo ( ) + after_macro_bang > self . curr ( ) . span . hi ( ) {
382+ // The split point is relative to `curr_original_span`,
383+ // because `curr.span` may have been merged with preceding spans.
384+ let split_point_after_macro_bang = self . curr_original_span . lo ( )
385+ + BytePos ( visible_macro. as_str ( ) . len ( ) as u32 )
386+ + BytePos ( 1 ) ; // add 1 for the `!`
387+ if split_point_after_macro_bang > curr. span . hi ( ) {
385388 // Something is wrong with the macro name span;
386389 // return now to avoid emitting malformed mappings.
387390 // FIXME(#117788): Track down why this happens.
388391 return ;
389392 }
393+
390394 let mut macro_name_cov = curr. clone ( ) ;
391- self . curr_mut ( ) . span = curr . span . with_lo ( curr . span . lo ( ) + after_macro_bang ) ;
392- macro_name_cov . span =
393- macro_name_cov . span . with_hi ( macro_name_cov . span . lo ( ) + after_macro_bang ) ;
395+ macro_name_cov . span = macro_name_cov . span . with_hi ( split_point_after_macro_bang ) ;
396+ self . curr_mut ( ) . span = curr . span . with_lo ( split_point_after_macro_bang ) ;
397+
394398 debug ! (
395399 " and curr starts a new macro expansion, so add a new span just for \
396400 the macro `{visible_macro}!`, new span={macro_name_cov:?}",
You can’t perform that action at this time.
0 commit comments