Skip to content

Commit d9b91de

Browse files
committed
coverage: Add some more cases to tests/coverage/holes.rs
1 parent f44efbf commit d9b91de

File tree

3 files changed

+88
-17
lines changed

3 files changed

+88
-17
lines changed

tests/coverage/holes.cov-map

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,57 @@
11
Function name: <holes::main::MyStruct>::_method (unused)
2-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 25, 09, 00, 1d]
2+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 2b, 09, 00, 1d]
33
Number of files: 1
44
- file 0 => global file 1
55
Number of expressions: 0
66
Number of file 0 mappings: 1
7-
- Code(Zero) at (prev + 37, 9) to (start + 0, 29)
7+
- Code(Zero) at (prev + 43, 9) to (start + 0, 29)
88
Highest counter ID seen: (none)
99

1010
Function name: holes::main
11-
Raw bytes (44): 0x[01, 01, 00, 08, 01, 08, 01, 06, 11, 01, 0f, 05, 00, 12, 01, 04, 05, 00, 12, 01, 07, 05, 00, 12, 01, 06, 05, 00, 12, 01, 06, 05, 03, 0f, 01, 0a, 05, 03, 0f, 01, 0a, 05, 01, 02]
11+
Raw bytes (69): 0x[01, 01, 00, 0d, 01, 08, 01, 01, 12, 01, 05, 05, 00, 12, 01, 07, 09, 00, 11, 01, 09, 05, 00, 12, 01, 04, 05, 00, 12, 01, 07, 05, 00, 12, 01, 06, 05, 00, 12, 01, 04, 05, 00, 12, 01, 04, 05, 00, 12, 01, 06, 05, 03, 0f, 01, 0a, 05, 03, 0f, 01, 0a, 05, 0c, 0d, 01, 0f, 0e, 05, 02]
1212
Number of files: 1
1313
- file 0 => global file 1
1414
Number of expressions: 0
15-
Number of file 0 mappings: 8
16-
- Code(Counter(0)) at (prev + 8, 1) to (start + 6, 17)
17-
- Code(Counter(0)) at (prev + 15, 5) to (start + 0, 18)
15+
Number of file 0 mappings: 13
16+
- Code(Counter(0)) at (prev + 8, 1) to (start + 1, 18)
17+
- Code(Counter(0)) at (prev + 5, 5) to (start + 0, 18)
18+
- Code(Counter(0)) at (prev + 7, 9) to (start + 0, 17)
19+
- Code(Counter(0)) at (prev + 9, 5) to (start + 0, 18)
1820
- Code(Counter(0)) at (prev + 4, 5) to (start + 0, 18)
1921
- Code(Counter(0)) at (prev + 7, 5) to (start + 0, 18)
2022
- Code(Counter(0)) at (prev + 6, 5) to (start + 0, 18)
23+
- Code(Counter(0)) at (prev + 4, 5) to (start + 0, 18)
24+
- Code(Counter(0)) at (prev + 4, 5) to (start + 0, 18)
2125
- Code(Counter(0)) at (prev + 6, 5) to (start + 3, 15)
2226
- Code(Counter(0)) at (prev + 10, 5) to (start + 3, 15)
23-
- Code(Counter(0)) at (prev + 10, 5) to (start + 1, 2)
27+
- Code(Counter(0)) at (prev + 10, 5) to (start + 12, 13)
28+
- Code(Counter(0)) at (prev + 15, 14) to (start + 5, 2)
2429
Highest counter ID seen: c0
2530

2631
Function name: holes::main::_unused_fn (unused)
27-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 19, 05, 00, 17]
32+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 1f, 05, 00, 17]
2833
Number of files: 1
2934
- file 0 => global file 1
3035
Number of expressions: 0
3136
Number of file 0 mappings: 1
32-
- Code(Zero) at (prev + 25, 5) to (start + 0, 23)
37+
- Code(Zero) at (prev + 31, 5) to (start + 0, 23)
3338
Highest counter ID seen: (none)
3439

3540
Function name: holes::main::{closure#0} (unused)
36-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 12, 09, 02, 0a]
41+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 18, 09, 02, 0a]
3742
Number of files: 1
3843
- file 0 => global file 1
3944
Number of expressions: 0
4045
Number of file 0 mappings: 1
41-
- Code(Zero) at (prev + 18, 9) to (start + 2, 10)
46+
- Code(Zero) at (prev + 24, 9) to (start + 2, 10)
4247
Highest counter ID seen: (none)
4348

4449
Function name: holes::main::{closure#1} (unused)
45-
Raw bytes (9): 0x[01, 01, 00, 01, 00, 3d, 09, 02, 0a]
50+
Raw bytes (9): 0x[01, 01, 00, 01, 00, 4b, 09, 02, 0a]
4651
Number of files: 1
4752
- file 0 => global file 1
4853
Number of expressions: 0
4954
Number of file 0 mappings: 1
50-
- Code(Zero) at (prev + 61, 9) to (start + 2, 10)
55+
- Code(Zero) at (prev + 75, 9) to (start + 2, 10)
5156
Highest counter ID seen: (none)
5257

tests/coverage/holes.coverage

+37-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
LL| |
88
LL| 1|fn main() {
99
LL| 1| black_box(());
10-
LL| 1|
11-
LL| 1| // Splitting this across multiple lines makes it easier to see where the
12-
LL| 1| // coverage mapping regions begin and end.
13-
LL| 1| #[rustfmt::skip]
10+
LL| |
11+
LL| | static MY_STATIC: () = ();
12+
LL| |
13+
LL| 1| black_box(());
14+
LL| |
15+
LL| | const MY_CONST: () = ();
16+
LL| |
17+
LL| | // Splitting this across multiple lines makes it easier to see where the
18+
LL| | // coverage mapping regions begin and end.
19+
LL| | #[rustfmt::skip]
1420
LL| 1| let _closure =
1521
LL| | |
1622
LL| | _arg: (),
@@ -39,6 +45,14 @@
3945
LL| |
4046
LL| 1| black_box(());
4147
LL| |
48+
LL| | trait MyTrait {}
49+
LL| |
50+
LL| 1| black_box(());
51+
LL| |
52+
LL| | impl MyTrait for MyStruct {}
53+
LL| |
54+
LL| 1| black_box(());
55+
LL| |
4256
LL| | macro_rules! _my_macro {
4357
LL| | () => {};
4458
LL| | }
@@ -64,5 +78,24 @@
6478
LL| | ;
6579
LL| |
6680
LL| 1| black_box(());
81+
LL| 1|
82+
LL| 1| // This tests the edge case of a const block nested inside an "anon const",
83+
LL| 1| // such as the length of an array literal. Handling this case requires
84+
LL| 1| // `nested_filter::OnlyBodies` or equivalent.
85+
LL| 1| #[rustfmt::skip]
86+
LL| 1| let _const_block_inside_anon_const =
87+
LL| 1| [
88+
LL| 1| 0
89+
LL| 1| ;
90+
LL| 1| 7
91+
LL| 1| +
92+
LL| 1| const
93+
LL| | {
94+
LL| | 3
95+
LL| 1| }
96+
LL| 1| ]
97+
LL| 1| ;
98+
LL| 1|
99+
LL| 1| black_box(());
67100
LL| 1|}
68101

tests/coverage/holes.rs

+33
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ use core::hint::black_box;
88
fn main() {
99
black_box(());
1010

11+
static MY_STATIC: () = ();
12+
13+
black_box(());
14+
15+
const MY_CONST: () = ();
16+
1117
// Splitting this across multiple lines makes it easier to see where the
1218
// coverage mapping regions begin and end.
1319
#[rustfmt::skip]
@@ -39,6 +45,14 @@ fn main() {
3945

4046
black_box(());
4147

48+
trait MyTrait {}
49+
50+
black_box(());
51+
52+
impl MyTrait for MyStruct {}
53+
54+
black_box(());
55+
4256
macro_rules! _my_macro {
4357
() => {};
4458
}
@@ -64,4 +78,23 @@ fn main() {
6478
;
6579

6680
black_box(());
81+
82+
// This tests the edge case of a const block nested inside an "anon const",
83+
// such as the length of an array literal. Handling this case requires
84+
// `nested_filter::OnlyBodies` or equivalent.
85+
#[rustfmt::skip]
86+
let _const_block_inside_anon_const =
87+
[
88+
0
89+
;
90+
7
91+
+
92+
const
93+
{
94+
3
95+
}
96+
]
97+
;
98+
99+
black_box(());
67100
}

0 commit comments

Comments
 (0)