coverage: Add a test case for a previously-unknown span mismatch
This commit is contained in:
parent
46c86aef65
commit
0418f9aa42
4 changed files with 91 additions and 5 deletions
|
|
@ -55,12 +55,10 @@ pub(super) fn extract_refined_covspans<'tcx>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Each pushed covspan should have the same context as the body span.
|
// Each pushed covspan should have the same context as the body span.
|
||||||
// If it somehow doesn't, discard the covspan, or panic in debug builds.
|
// If it somehow doesn't, discard the covspan.
|
||||||
if !body_span.eq_ctxt(covspan_span) {
|
if !body_span.eq_ctxt(covspan_span) {
|
||||||
debug_assert!(
|
// FIXME(Zalathar): Investigate how and why this is triggered
|
||||||
false,
|
// by `tests/coverage/macros/context-mismatch-issue-147339.rs`.
|
||||||
"span context mismatch: body_span={body_span:?}, covspan.span={covspan_span:?}"
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
40
tests/coverage/macros/context-mismatch-issue-147339.cov-map
Normal file
40
tests/coverage/macros/context-mismatch-issue-147339.cov-map
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
Function name: context_mismatch_issue_147339::a (unused)
|
||||||
|
Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => $DIR/context-mismatch-issue-147339.rs
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 2
|
||||||
|
- Code(Zero) at (prev + 12, 39) to (start + 0, 53)
|
||||||
|
- Code(Zero) at (prev + 0, 59) to (start + 0, 60)
|
||||||
|
Highest counter ID seen: (none)
|
||||||
|
|
||||||
|
Function name: context_mismatch_issue_147339::b (unused)
|
||||||
|
Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => $DIR/context-mismatch-issue-147339.rs
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 2
|
||||||
|
- Code(Zero) at (prev + 12, 39) to (start + 0, 53)
|
||||||
|
- Code(Zero) at (prev + 0, 59) to (start + 0, 60)
|
||||||
|
Highest counter ID seen: (none)
|
||||||
|
|
||||||
|
Function name: context_mismatch_issue_147339::c (unused)
|
||||||
|
Raw bytes (14): 0x[01, 01, 00, 02, 00, 0c, 27, 00, 35, 00, 00, 3b, 00, 3c]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => $DIR/context-mismatch-issue-147339.rs
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 2
|
||||||
|
- Code(Zero) at (prev + 12, 39) to (start + 0, 53)
|
||||||
|
- Code(Zero) at (prev + 0, 59) to (start + 0, 60)
|
||||||
|
Highest counter ID seen: (none)
|
||||||
|
|
||||||
|
Function name: context_mismatch_issue_147339::main
|
||||||
|
Raw bytes (14): 0x[01, 01, 00, 02, 01, 14, 01, 00, 0a, 01, 00, 0c, 00, 0d]
|
||||||
|
Number of files: 1
|
||||||
|
- file 0 => $DIR/context-mismatch-issue-147339.rs
|
||||||
|
Number of expressions: 0
|
||||||
|
Number of file 0 mappings: 2
|
||||||
|
- Code(Counter(0)) at (prev + 20, 1) to (start + 0, 10)
|
||||||
|
- Code(Counter(0)) at (prev + 0, 12) to (start + 0, 13)
|
||||||
|
Highest counter ID seen: c0
|
||||||
|
|
||||||
28
tests/coverage/macros/context-mismatch-issue-147339.coverage
Normal file
28
tests/coverage/macros/context-mismatch-issue-147339.coverage
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
LL| |//@ edition: 2024
|
||||||
|
LL| |
|
||||||
|
LL| |// These nested macro expansions were found to cause span refinement to produce
|
||||||
|
LL| |// spans with a context that doesn't match the function body span, triggering
|
||||||
|
LL| |// a defensive check that discards the span.
|
||||||
|
LL| |//
|
||||||
|
LL| |// Reported in <https://github.com/rust-lang/rust/issues/147339>.
|
||||||
|
LL| |
|
||||||
|
LL| |macro_rules! foo {
|
||||||
|
LL| | ($($m:ident $($f:ident $v:tt)+),*) => {
|
||||||
|
LL| | $($(macro_rules! $f { () => { $v } })+)*
|
||||||
|
LL| 0| $(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })*
|
||||||
|
------------------
|
||||||
|
| Unexecuted instantiation: context_mismatch_issue_147339::a
|
||||||
|
------------------
|
||||||
|
| Unexecuted instantiation: context_mismatch_issue_147339::b
|
||||||
|
------------------
|
||||||
|
| Unexecuted instantiation: context_mismatch_issue_147339::c
|
||||||
|
------------------
|
||||||
|
LL| | }
|
||||||
|
LL| |}
|
||||||
|
LL| |
|
||||||
|
LL| |foo!(m a 1 b 2, n c 3);
|
||||||
|
LL| |m!();
|
||||||
|
LL| |n!();
|
||||||
|
LL| |
|
||||||
|
LL| 1|fn main() {}
|
||||||
|
|
||||||
20
tests/coverage/macros/context-mismatch-issue-147339.rs
Normal file
20
tests/coverage/macros/context-mismatch-issue-147339.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
//@ edition: 2024
|
||||||
|
|
||||||
|
// These nested macro expansions were found to cause span refinement to produce
|
||||||
|
// spans with a context that doesn't match the function body span, triggering
|
||||||
|
// a defensive check that discards the span.
|
||||||
|
//
|
||||||
|
// Reported in <https://github.com/rust-lang/rust/issues/147339>.
|
||||||
|
|
||||||
|
macro_rules! foo {
|
||||||
|
($($m:ident $($f:ident $v:tt)+),*) => {
|
||||||
|
$($(macro_rules! $f { () => { $v } })+)*
|
||||||
|
$(macro_rules! $m { () => { $(fn $f() -> i32 { $v })+ } })*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foo!(m a 1 b 2, n c 3);
|
||||||
|
m!();
|
||||||
|
n!();
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue