coverage: Test for handling of nested item spans
This commit is contained in:
parent
7fdefb804e
commit
9b2c58d1fa
42
tests/coverage/holes.cov-map
Normal file
42
tests/coverage/holes.cov-map
Normal file
@ -0,0 +1,42 @@
|
||||
Function name: <holes::main::MyStruct>::_method (unused)
|
||||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 25, 09, 00, 1d]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 1
|
||||
- Code(Zero) at (prev + 37, 9) to (start + 0, 29)
|
||||
|
||||
Function name: holes::main
|
||||
Raw bytes (19): 0x[01, 01, 00, 03, 01, 08, 01, 06, 11, 01, 0f, 05, 24, 0f, 01, 2b, 05, 01, 02]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 3
|
||||
- Code(Counter(0)) at (prev + 8, 1) to (start + 6, 17)
|
||||
- Code(Counter(0)) at (prev + 15, 5) to (start + 36, 15)
|
||||
- Code(Counter(0)) at (prev + 43, 5) to (start + 1, 2)
|
||||
|
||||
Function name: holes::main::_unused_fn (unused)
|
||||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 19, 05, 00, 17]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 1
|
||||
- Code(Zero) at (prev + 25, 5) to (start + 0, 23)
|
||||
|
||||
Function name: holes::main::{closure#0} (unused)
|
||||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 12, 09, 02, 0a]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 1
|
||||
- Code(Zero) at (prev + 18, 9) to (start + 2, 10)
|
||||
|
||||
Function name: holes::main::{closure#1} (unused)
|
||||
Raw bytes (9): 0x[01, 01, 00, 01, 00, 3d, 09, 02, 0a]
|
||||
Number of files: 1
|
||||
- file 0 => global file 1
|
||||
Number of expressions: 0
|
||||
Number of file 0 mappings: 1
|
||||
- Code(Zero) at (prev + 61, 9) to (start + 2, 10)
|
||||
|
70
tests/coverage/holes.coverage
Normal file
70
tests/coverage/holes.coverage
Normal file
@ -0,0 +1,70 @@
|
||||
LL| |//@ edition: 2021
|
||||
LL| |
|
||||
LL| |// Nested items/closures should be treated as "holes", so that their spans are
|
||||
LL| |// not displayed as executable code in the enclosing function.
|
||||
LL| |
|
||||
LL| |use core::hint::black_box;
|
||||
LL| |
|
||||
LL| 1|fn main() {
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| // Splitting this across multiple lines makes it easier to see where the
|
||||
LL| 1| // coverage mapping regions begin and end.
|
||||
LL| 1| #[rustfmt::skip]
|
||||
LL| 1| let _closure =
|
||||
LL| | |
|
||||
LL| | _arg: (),
|
||||
LL| | |
|
||||
LL| 0| {
|
||||
LL| 0| black_box(());
|
||||
LL| 0| }
|
||||
LL| | ;
|
||||
LL| |
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| fn _unused_fn() {}
|
||||
^0
|
||||
LL| 1|
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| struct MyStruct {
|
||||
LL| 1| _x: u32,
|
||||
LL| 1| _y: u32,
|
||||
LL| 1| }
|
||||
LL| 1|
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| impl MyStruct {
|
||||
LL| 1| fn _method(&self) {}
|
||||
^0
|
||||
LL| 1| }
|
||||
LL| 1|
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| macro_rules! _my_macro {
|
||||
LL| 1| () => {};
|
||||
LL| 1| }
|
||||
LL| 1|
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| #[rustfmt::skip]
|
||||
LL| 1| let _const =
|
||||
LL| 1| const
|
||||
LL| 1| {
|
||||
LL| 1| 7 + 4
|
||||
LL| 1| }
|
||||
LL| 1| ;
|
||||
LL| 1|
|
||||
LL| 1| black_box(());
|
||||
LL| 1|
|
||||
LL| 1| #[rustfmt::skip]
|
||||
LL| 1| let _async =
|
||||
LL| | async
|
||||
LL| 0| {
|
||||
LL| 0| 7 + 4
|
||||
LL| 0| }
|
||||
LL| | ;
|
||||
LL| |
|
||||
LL| 1| black_box(());
|
||||
LL| 1|}
|
||||
|
67
tests/coverage/holes.rs
Normal file
67
tests/coverage/holes.rs
Normal file
@ -0,0 +1,67 @@
|
||||
//@ edition: 2021
|
||||
|
||||
// Nested items/closures should be treated as "holes", so that their spans are
|
||||
// not displayed as executable code in the enclosing function.
|
||||
|
||||
use core::hint::black_box;
|
||||
|
||||
fn main() {
|
||||
black_box(());
|
||||
|
||||
// Splitting this across multiple lines makes it easier to see where the
|
||||
// coverage mapping regions begin and end.
|
||||
#[rustfmt::skip]
|
||||
let _closure =
|
||||
|
|
||||
_arg: (),
|
||||
|
|
||||
{
|
||||
black_box(());
|
||||
}
|
||||
;
|
||||
|
||||
black_box(());
|
||||
|
||||
fn _unused_fn() {}
|
||||
|
||||
black_box(());
|
||||
|
||||
struct MyStruct {
|
||||
_x: u32,
|
||||
_y: u32,
|
||||
}
|
||||
|
||||
black_box(());
|
||||
|
||||
impl MyStruct {
|
||||
fn _method(&self) {}
|
||||
}
|
||||
|
||||
black_box(());
|
||||
|
||||
macro_rules! _my_macro {
|
||||
() => {};
|
||||
}
|
||||
|
||||
black_box(());
|
||||
|
||||
#[rustfmt::skip]
|
||||
let _const =
|
||||
const
|
||||
{
|
||||
7 + 4
|
||||
}
|
||||
;
|
||||
|
||||
black_box(());
|
||||
|
||||
#[rustfmt::skip]
|
||||
let _async =
|
||||
async
|
||||
{
|
||||
7 + 4
|
||||
}
|
||||
;
|
||||
|
||||
black_box(());
|
||||
}
|
Loading…
Reference in New Issue
Block a user