File tree 1 file changed +10
-6
lines changed
compiler/rustc_mir_transform/src/coverage
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> {
379
379
return ;
380
380
}
381
381
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 ( ) {
385
388
// Something is wrong with the macro name span;
386
389
// return now to avoid emitting malformed mappings.
387
390
// FIXME(#117788): Track down why this happens.
388
391
return ;
389
392
}
393
+
390
394
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
+
394
398
debug ! (
395
399
" and curr starts a new macro expansion, so add a new span just for \
396
400
the macro `{visible_macro}!`, new span={macro_name_cov:?}",
You can’t perform that action at this time.
0 commit comments