Skip to content

Commit 785465e

Browse files
committed
Add test for coverage on a body-less trait function
1 parent 9056e9f commit 785465e

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

tests/ui/coverage-attr/no-coverage.rs

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ trait Trait {
1212
type T;
1313

1414
type U;
15+
16+
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
17+
fn f(&self);
18+
19+
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
20+
fn g();
1521
}
1622

1723
#[coverage(off)]
@@ -23,6 +29,9 @@ impl Trait for () {
2329

2430
#[coverage(off)] //~ ERROR attribute should be applied to a function definition or closure
2531
type U = impl Trait; //~ ERROR unconstrained opaque type
32+
33+
fn f(&self) {}
34+
fn g() {}
2635
}
2736

2837
extern "C" {

tests/ui/coverage-attr/no-coverage.stderr

+26-10
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ LL | / trait Trait {
77
LL | | #[coverage(off)]
88
LL | | const X: u32;
99
... |
10-
LL | | type U;
10+
LL | | fn g();
1111
LL | | }
1212
| |_- not a function or closure
1313

1414
error[E0788]: attribute should be applied to a function definition or closure
15-
--> $DIR/no-coverage.rs:38:5
15+
--> $DIR/no-coverage.rs:47:5
1616
|
1717
LL | #[coverage(off)]
1818
| ^^^^^^^^^^^^^^^^
1919
LL | let _ = ();
2020
| ----------- not a function or closure
2121

2222
error[E0788]: attribute should be applied to a function definition or closure
23-
--> $DIR/no-coverage.rs:42:9
23+
--> $DIR/no-coverage.rs:51:9
2424
|
2525
LL | #[coverage(off)]
2626
| ^^^^^^^^^^^^^^^^
2727
LL | () => (),
2828
| -------- not a function or closure
2929

3030
error[E0788]: attribute should be applied to a function definition or closure
31-
--> $DIR/no-coverage.rs:46:5
31+
--> $DIR/no-coverage.rs:55:5
3232
|
3333
LL | #[coverage(off)]
3434
| ^^^^^^^^^^^^^^^^
@@ -52,45 +52,61 @@ LL | type T;
5252
| ------- not a function or closure
5353

5454
error[E0788]: attribute should be applied to a function definition or closure
55-
--> $DIR/no-coverage.rs:21:5
55+
--> $DIR/no-coverage.rs:16:5
56+
|
57+
LL | #[coverage(off)]
58+
| ^^^^^^^^^^^^^^^^
59+
LL | fn f(&self);
60+
| ------------ not a function or closure
61+
62+
error[E0788]: attribute should be applied to a function definition or closure
63+
--> $DIR/no-coverage.rs:19:5
64+
|
65+
LL | #[coverage(off)]
66+
| ^^^^^^^^^^^^^^^^
67+
LL | fn g();
68+
| ------- not a function or closure
69+
70+
error[E0788]: attribute should be applied to a function definition or closure
71+
--> $DIR/no-coverage.rs:27:5
5672
|
5773
LL | #[coverage(off)]
5874
| ^^^^^^^^^^^^^^^^
5975
LL | type T = Self;
6076
| -------------- not a function or closure
6177

6278
error[E0788]: attribute should be applied to a function definition or closure
63-
--> $DIR/no-coverage.rs:24:5
79+
--> $DIR/no-coverage.rs:30:5
6480
|
6581
LL | #[coverage(off)]
6682
| ^^^^^^^^^^^^^^^^
6783
LL | type U = impl Trait;
6884
| -------------------- not a function or closure
6985

7086
error[E0788]: attribute should be applied to a function definition or closure
71-
--> $DIR/no-coverage.rs:29:5
87+
--> $DIR/no-coverage.rs:38:5
7288
|
7389
LL | #[coverage(off)]
7490
| ^^^^^^^^^^^^^^^^
7591
LL | static X: u32;
7692
| -------------- not a function or closure
7793

7894
error[E0788]: attribute should be applied to a function definition or closure
79-
--> $DIR/no-coverage.rs:32:5
95+
--> $DIR/no-coverage.rs:41:5
8096
|
8197
LL | #[coverage(off)]
8298
| ^^^^^^^^^^^^^^^^
8399
LL | type T;
84100
| ------- not a function or closure
85101

86102
error: unconstrained opaque type
87-
--> $DIR/no-coverage.rs:25:14
103+
--> $DIR/no-coverage.rs:31:14
88104
|
89105
LL | type U = impl Trait;
90106
| ^^^^^^^^^^
91107
|
92108
= note: `U` must be used in combination with a concrete type within the same impl
93109

94-
error: aborting due to 11 previous errors
110+
error: aborting due to 13 previous errors
95111

96112
For more information about this error, try `rustc --explain E0788`.

0 commit comments

Comments
 (0)