mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
coverage: Clean up maybe_push_macro_name_span
This commit is contained in:
parent
9358642e3b
commit
ff3af59f2b
@ -379,18 +379,22 @@ impl<'a> CoverageSpansGenerator<'a> {
|
||||
return;
|
||||
}
|
||||
|
||||
let merged_prefix_len = self.curr_original_span.lo() - curr.span.lo();
|
||||
let after_macro_bang = merged_prefix_len + BytePos(visible_macro.as_str().len() as u32 + 1);
|
||||
if self.curr().span.lo() + after_macro_bang > self.curr().span.hi() {
|
||||
// The split point is relative to `curr_original_span`,
|
||||
// because `curr.span` may have been merged with preceding spans.
|
||||
let split_point_after_macro_bang = self.curr_original_span.lo()
|
||||
+ BytePos(visible_macro.as_str().len() as u32)
|
||||
+ BytePos(1); // add 1 for the `!`
|
||||
if split_point_after_macro_bang > curr.span.hi() {
|
||||
// Something is wrong with the macro name span;
|
||||
// return now to avoid emitting malformed mappings.
|
||||
// FIXME(#117788): Track down why this happens.
|
||||
return;
|
||||
}
|
||||
|
||||
let mut macro_name_cov = curr.clone();
|
||||
self.curr_mut().span = curr.span.with_lo(curr.span.lo() + after_macro_bang);
|
||||
macro_name_cov.span =
|
||||
macro_name_cov.span.with_hi(macro_name_cov.span.lo() + after_macro_bang);
|
||||
macro_name_cov.span = macro_name_cov.span.with_hi(split_point_after_macro_bang);
|
||||
self.curr_mut().span = curr.span.with_lo(split_point_after_macro_bang);
|
||||
|
||||
debug!(
|
||||
" and curr starts a new macro expansion, so add a new span just for \
|
||||
the macro `{visible_macro}!`, new span={macro_name_cov:?}",
|
||||
|
Loading…
Reference in New Issue
Block a user