Skip to content

Commit c85d7a7

Browse files
committed
coverage: Bless coverage attribute tests
1 parent 54cee0a commit c85d7a7

8 files changed

+419
-299
lines changed

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

+1-7
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

+10-23
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

+27-22
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,62 @@
44
// Demonstrates the diagnostics produced when using the syntax
55
// `#![coverage = "off"]`, which should not be allowed.
66

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

1412
mod my_mod_inner {
15-
#![coverage = "off"] //~ ERROR malformed `coverage` attribute input
13+
#![coverage = "off"]
14+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
15+
//~| ERROR attribute should be applied to a function definition or closure
1616
}
1717

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

23-
#[coverage = "off"] //~ ERROR malformed `coverage` attribute input
23+
#[coverage = "off"]
24+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
25+
//~| ERROR attribute should be applied to a function definition or closure
2426
impl MyStruct {
2527
#[coverage = "off"]
26-
//~^ ERROR `#[coverage]` must be applied to coverable code
27-
//~| ERROR malformed `coverage` attribute input
28+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
29+
//~| ERROR attribute should be applied to a function definition or closure
2830
const X: u32 = 7;
2931
}
3032

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

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

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

5157
#[coverage = "off"]
52-
//~^ ERROR `#[coverage]` must be applied to coverable code
53-
//~| ERROR malformed `coverage` attribute input
58+
//~^ ERROR expected `coverage(off)` or `coverage(on)`
59+
//~| ERROR attribute should be applied to a function definition or closure
5460
type T = ();
5561
}
5662

5763
#[coverage = "off"]
5864
//~^ ERROR expected `coverage(off)` or `coverage(on)`
59-
//~| ERROR malformed `coverage` attribute input
6065
fn main() {}

0 commit comments

Comments
 (0)