Skip to content

Commit 01954ad

Browse files
committed
coverage: Bless coverage attribute tests
1 parent b79a99d commit 01954ad

File tree

8 files changed

+419
-299
lines changed

8 files changed

+419
-299
lines changed

tests/ui/coverage-attr/bad-syntax.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ fn multiple_inconsistent() {}
1818
#[coverage] //~ ERROR expected `coverage(off)` or `coverage(on)`
1919
fn bare_word() {}
2020

21-
// FIXME(#126658): This shows as multiple different errors, one of which suggests
22-
// writing bare `#[coverage]`, which is not allowed.
23-
#[coverage = true]
24-
//~^ ERROR expected `coverage(off)` or `coverage(on)`
25-
//~| ERROR malformed `coverage` attribute input
26-
//~| HELP the following are the possible correct uses
27-
//~| SUGGESTION #[coverage(on|off)]
21+
#[coverage = true] //~ ERROR expected `coverage(off)` or `coverage(on)`
2822
fn key_value() {}
2923

3024
#[coverage()] //~ ERROR expected `coverage(off)` or `coverage(on)`

tests/ui/coverage-attr/bad-syntax.stderr

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
error: malformed `coverage` attribute input
2-
--> $DIR/bad-syntax.rs:23:1
3-
|
4-
LL | #[coverage = true]
5-
| ^^^^^^^^^^^^^^^^^^
6-
|
7-
help: the following are the possible correct uses
8-
|
9-
LL | #[coverage(on|off)]
10-
|
11-
LL | #[coverage]
12-
|
13-
141
error: expected identifier, found `,`
15-
--> $DIR/bad-syntax.rs:52:12
2+
--> $DIR/bad-syntax.rs:46:12
163
|
174
LL | #[coverage(,off)]
185
| ^
@@ -51,52 +38,52 @@ LL | #[coverage]
5138
| ^^^^^^^^^^^
5239

5340
error: expected `coverage(off)` or `coverage(on)`
54-
--> $DIR/bad-syntax.rs:23:1
41+
--> $DIR/bad-syntax.rs:21:1
5542
|
5643
LL | #[coverage = true]
5744
| ^^^^^^^^^^^^^^^^^^
5845

5946
error: expected `coverage(off)` or `coverage(on)`
60-
--> $DIR/bad-syntax.rs:30:1
47+
--> $DIR/bad-syntax.rs:24:1
6148
|
6249
LL | #[coverage()]
6350
| ^^^^^^^^^^^^^
6451

6552
error: expected `coverage(off)` or `coverage(on)`
66-
--> $DIR/bad-syntax.rs:33:1
53+
--> $DIR/bad-syntax.rs:27:1
6754
|
6855
LL | #[coverage(off, off)]
6956
| ^^^^^^^^^^^^^^^^^^^^^
7057

7158
error: expected `coverage(off)` or `coverage(on)`
72-
--> $DIR/bad-syntax.rs:36:1
59+
--> $DIR/bad-syntax.rs:30:1
7360
|
7461
LL | #[coverage(off, on)]
7562
| ^^^^^^^^^^^^^^^^^^^^
7663

7764
error: expected `coverage(off)` or `coverage(on)`
78-
--> $DIR/bad-syntax.rs:39:1
65+
--> $DIR/bad-syntax.rs:33:1
7966
|
8067
LL | #[coverage(bogus)]
8168
| ^^^^^^^^^^^^^^^^^^
8269

8370
error: expected `coverage(off)` or `coverage(on)`
84-
--> $DIR/bad-syntax.rs:42:1
71+
--> $DIR/bad-syntax.rs:36:1
8572
|
8673
LL | #[coverage(bogus, off)]
8774
| ^^^^^^^^^^^^^^^^^^^^^^^
8875

8976
error: expected `coverage(off)` or `coverage(on)`
90-
--> $DIR/bad-syntax.rs:45:1
77+
--> $DIR/bad-syntax.rs:39:1
9178
|
9279
LL | #[coverage(off, bogus)]
9380
| ^^^^^^^^^^^^^^^^^^^^^^^
9481

9582
error: expected `coverage(off)` or `coverage(on)`
96-
--> $DIR/bad-syntax.rs:52:1
83+
--> $DIR/bad-syntax.rs:46:1
9784
|
9885
LL | #[coverage(,off)]
9986
| ^^^^^^^^^^^^^^^^^
10087

101-
error: aborting due to 13 previous errors
88+
error: aborting due to 12 previous errors
10289

tests/ui/coverage-attr/name-value.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,62 @@
88
// and in places that cannot have a coverage attribute, to demonstrate the
99
// interaction between multiple errors.
1010

11-
// FIXME(#126658): The error messages for using this syntax are inconsistent
12-
// with the error message in other cases. They also sometimes appear together
13-
// with other errors, and they suggest using the incorrect `#[coverage]` syntax.
14-
15-
#[coverage = "off"] //~ ERROR malformed `coverage` attribute input
11+
#[coverage = "off"]
12+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
13+
//~| ERROR attribute should be applied to a function definition or closure
1614
mod my_mod {}
1715

1816
mod my_mod_inner {
19-
#![coverage = "off"] //~ ERROR malformed `coverage` attribute input
17+
#![coverage = "off"]
18+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
19+
//~| ERROR attribute should be applied to a function definition or closure
2020
}
2121

2222
#[coverage = "off"]
23-
//~^ ERROR `#[coverage]` must be applied to coverable code
24-
//~| ERROR malformed `coverage` attribute input
23+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
24+
//~| ERROR attribute should be applied to a function definition or closure
2525
struct MyStruct;
2626

27-
#[coverage = "off"] //~ ERROR malformed `coverage` attribute input
27+
#[coverage = "off"]
28+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
29+
//~| ERROR attribute should be applied to a function definition or closure
2830
impl MyStruct {
2931
#[coverage = "off"]
30-
//~^ ERROR `#[coverage]` must be applied to coverable code
31-
//~| ERROR malformed `coverage` attribute input
32+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
33+
//~| ERROR attribute should be applied to a function definition or closure
3234
const X: u32 = 7;
3335
}
3436

35-
#[coverage = "off"] //~ ERROR malformed `coverage` attribute input
37+
#[coverage = "off"]
38+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
39+
//~| ERROR attribute should be applied to a function definition or closure
3640
trait MyTrait {
3741
#[coverage = "off"]
38-
//~^ ERROR `#[coverage]` must be applied to coverable code
39-
//~| ERROR malformed `coverage` attribute input
42+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
43+
//~| ERROR attribute should be applied to a function definition or closure
4044
const X: u32;
4145

4246
#[coverage = "off"]
43-
//~^ ERROR `#[coverage]` must be applied to coverable code
44-
//~| ERROR malformed `coverage` attribute input
47+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
48+
//~| ERROR attribute should be applied to a function definition or closure
4549
type T;
4650
}
4751

48-
#[coverage = "off"] //~ ERROR malformed `coverage` attribute input
52+
#[coverage = "off"]
53+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
54+
//~| ERROR attribute should be applied to a function definition or closure
4955
impl MyTrait for MyStruct {
5056
#[coverage = "off"]
51-
//~^ ERROR `#[coverage]` must be applied to coverable code
52-
//~| ERROR malformed `coverage` attribute input
57+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
58+
//~| ERROR attribute should be applied to a function definition or closure
5359
const X: u32 = 8;
5460

5561
#[coverage = "off"]
56-
//~^ ERROR `#[coverage]` must be applied to coverable code
57-
//~| ERROR malformed `coverage` attribute input
62+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
63+
//~| ERROR attribute should be applied to a function definition or closure
5864
type T = ();
5965
}
6066

6167
#[coverage = "off"]
6268
//~^ ERROR expected `coverage(off)` or `coverage(on)`
63-
//~| ERROR malformed `coverage` attribute input
6469
fn main() {}

0 commit comments

Comments
 (0)