forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
coverage: Regression test for rust-lang#117788
This test isn't able to reproduce the malformed mappings that cause `llvm-cov` to fail, but does reproduce the underlying problem in a way that results in obviously incorrect mappings if the workaround is not present.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Function name: macro_name_span::affected_function | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 0e, 1b, 00, 20] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 14, 27) to (start + 0, 32) | ||
|
||
Function name: macro_name_span::main | ||
Raw bytes (9): 0x[01, 01, 00, 01, 01, 08, 01, 02, 02] | ||
Number of files: 1 | ||
- file 0 => global file 1 | ||
Number of expressions: 0 | ||
Number of file 0 mappings: 1 | ||
- Code(Counter(0)) at (prev + 8, 1) to (start + 2, 2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
LL| |// edition: 2021 | ||
LL| | | ||
LL| |// Regression test for <https://github.com/rust-lang/rust/issues/117788>. | ||
LL| |// Under some circumstances, the heuristics that detect macro name spans can | ||
LL| |// get confused and produce incorrect spans beyond the bounds of the span | ||
LL| |// being processed. | ||
LL| | | ||
LL| 1|fn main() { | ||
LL| 1| affected_function(); | ||
LL| 1|} | ||
LL| | | ||
LL| |macro_rules! macro_that_defines_a_function { | ||
LL| | (fn $name:ident () $body:tt) => { | ||
LL| 1| fn $name () -> () $body | ||
LL| | } | ||
LL| |} | ||
LL| | | ||
LL| |// These comment lines are not executable and should not have counters. | ||
LL| |// If they do have counters, it means that a span from the above $body has | ||
LL| |// been extended beyond its proper bounds. | ||
LL| | | ||
LL| |macro_rules! macro_with_an_unreasonably_and_egregiously_long_name { | ||
LL| | () => { | ||
LL| | println!("hello"); | ||
LL| | }; | ||
LL| |} | ||
LL| | | ||
LL| |macro_that_defines_a_function! { | ||
LL| | fn affected_function() { | ||
LL| | macro_with_an_unreasonably_and_egregiously_long_name!(); | ||
LL| | } | ||
LL| |} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// edition: 2021 | ||
|
||
// Regression test for <https://github.com/rust-lang/rust/issues/117788>. | ||
// Under some circumstances, the heuristics that detect macro name spans can | ||
// get confused and produce incorrect spans beyond the bounds of the span | ||
// being processed. | ||
|
||
fn main() { | ||
affected_function(); | ||
} | ||
|
||
macro_rules! macro_that_defines_a_function { | ||
(fn $name:ident () $body:tt) => { | ||
fn $name () -> () $body | ||
} | ||
} | ||
|
||
// These comment lines are not executable and should not have counters. | ||
// If they do have counters, it means that a span from the above $body has | ||
// been extended beyond its proper bounds. | ||
|
||
macro_rules! macro_with_an_unreasonably_and_egregiously_long_name { | ||
() => { | ||
println!("hello"); | ||
}; | ||
} | ||
|
||
macro_that_defines_a_function! { | ||
fn affected_function() { | ||
macro_with_an_unreasonably_and_egregiously_long_name!(); | ||
} | ||
} |