Skip to content

Commit 090dad0

Browse files
Changes in uitests for cfg_attr
Signed-off-by: Jonathan Brouwer <[email protected]>
1 parent 7113d58 commit 090dad0

18 files changed

+384
-86
lines changed

tests/ui/attributes/malformed-attrs.stderr

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ LL | #[cfg]
99
|
1010
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
1111

12-
error: malformed `cfg_attr` attribute input
12+
error[E0539]: malformed `cfg_attr` attribute input
1313
--> $DIR/malformed-attrs.rs:103:1
1414
|
1515
LL | #[cfg_attr]
1616
| ^^^^^^^^^^^
17+
| |
18+
| expected this to be a list
19+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
1720
|
1821
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
19-
help: missing condition and attribute
20-
|
21-
LL | #[cfg_attr(condition, attribute, other_attribute, ...)]
22-
| ++++++++++++++++++++++++++++++++++++++++++++
2322

2423
error[E0463]: can't find crate for `wloop`
2524
--> $DIR/malformed-attrs.rs:209:1

tests/ui/cfg/cfg-path-error.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@
33
#![allow(unexpected_cfgs)] // invalid cfgs
44

55
#[cfg(any(foo, foo::bar))]
6-
//~^ERROR `cfg` predicate key must be an identifier
6+
//~^ ERROR malformed `cfg` attribute input
7+
//~| NOTE expected a valid identifier here
8+
//~| NOTE for more information, visit
79
fn foo1() {}
810

911
#[cfg(any(foo::bar, foo))]
10-
//~^ERROR `cfg` predicate key must be an identifier
12+
//~^ ERROR malformed `cfg` attribute input
13+
//~| NOTE expected a valid identifier here
14+
//~| NOTE for more information, visit
1115
fn foo2() {}
1216

1317
#[cfg(all(foo, foo::bar))]
14-
//~^ERROR `cfg` predicate key must be an identifier
18+
//~^ ERROR malformed `cfg` attribute input
19+
//~| NOTE expected a valid identifier here
20+
//~| NOTE for more information, visit
1521
fn foo3() {}
1622

1723
#[cfg(all(foo::bar, foo))]
18-
//~^ERROR `cfg` predicate key must be an identifier
24+
//~^ ERROR malformed `cfg` attribute input
25+
//~| NOTE expected a valid identifier here
26+
//~| NOTE for more information, visit
1927
fn foo4() {}
2028

2129
fn main() {}

tests/ui/cfg/cfg-path-error.stderr

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,47 @@
1-
error: `cfg` predicate key must be an identifier
2-
--> $DIR/cfg-path-error.rs:5:16
1+
error[E0539]: malformed `cfg` attribute input
2+
--> $DIR/cfg-path-error.rs:5:1
33
|
44
LL | #[cfg(any(foo, foo::bar))]
5-
| ^^^^^^^^
5+
| ^^^^^^^^^^^^^^^--------^^^
6+
| | |
7+
| | expected a valid identifier here
8+
| help: must be of the form: `#[cfg(predicate)]`
9+
|
10+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
611

7-
error: `cfg` predicate key must be an identifier
8-
--> $DIR/cfg-path-error.rs:9:11
12+
error[E0539]: malformed `cfg` attribute input
13+
--> $DIR/cfg-path-error.rs:11:1
914
|
1015
LL | #[cfg(any(foo::bar, foo))]
11-
| ^^^^^^^^
16+
| ^^^^^^^^^^--------^^^^^^^^
17+
| | |
18+
| | expected a valid identifier here
19+
| help: must be of the form: `#[cfg(predicate)]`
20+
|
21+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
1222

13-
error: `cfg` predicate key must be an identifier
14-
--> $DIR/cfg-path-error.rs:13:16
23+
error[E0539]: malformed `cfg` attribute input
24+
--> $DIR/cfg-path-error.rs:17:1
1525
|
1626
LL | #[cfg(all(foo, foo::bar))]
17-
| ^^^^^^^^
27+
| ^^^^^^^^^^^^^^^--------^^^
28+
| | |
29+
| | expected a valid identifier here
30+
| help: must be of the form: `#[cfg(predicate)]`
31+
|
32+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
1833

19-
error: `cfg` predicate key must be an identifier
20-
--> $DIR/cfg-path-error.rs:17:11
34+
error[E0539]: malformed `cfg` attribute input
35+
--> $DIR/cfg-path-error.rs:23:1
2136
|
2237
LL | #[cfg(all(foo::bar, foo))]
23-
| ^^^^^^^^
38+
| ^^^^^^^^^^--------^^^^^^^^
39+
| | |
40+
| | expected a valid identifier here
41+
| help: must be of the form: `#[cfg(predicate)]`
42+
|
43+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
2444

2545
error: aborting due to 4 previous errors
2646

47+
For more information about this error, try `rustc --explain E0539`.

tests/ui/cfg/cfg-target-compact-errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn three() {}
1919
fn four() {}
2020

2121
#[cfg(target(clippy::os = "linux"))]
22-
//~^ ERROR `cfg` predicate key must be an identifier
22+
//~^ ERROR malformed `cfg` attribute input
2323
fn five() {}
2424

2525
fn main() {}

tests/ui/cfg/cfg-target-compact-errors.stderr

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,16 @@ LL | #[cfg(target(true))]
4242
|
4343
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
4444

45-
error: `cfg` predicate key must be an identifier
46-
--> $DIR/cfg-target-compact-errors.rs:21:14
45+
error[E0539]: malformed `cfg` attribute input
46+
--> $DIR/cfg-target-compact-errors.rs:21:1
4747
|
4848
LL | #[cfg(target(clippy::os = "linux"))]
49-
| ^^^^^^^^^^
49+
| ^^^^^^^^^^^^^----------^^^^^^^^^^^^^
50+
| | |
51+
| | expected a valid identifier here
52+
| help: must be of the form: `#[cfg(predicate)]`
53+
|
54+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
5055

5156
error: aborting due to 5 previous errors
5257

tests/ui/conditional-compilation/cfg-attr-parse.stderr

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
1-
error: malformed `cfg_attr` attribute input
1+
error[E0539]: malformed `cfg_attr` attribute input
22
--> $DIR/cfg-attr-parse.rs:4:1
33
|
44
LL | #[cfg_attr()]
5-
| ^^^^^^^^^^^^^
5+
| ^^^^^^^^^^--^
6+
| | |
7+
| | expected at least 1 argument here
8+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
69
|
710
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
8-
help: missing condition and attribute
9-
|
10-
LL | #[cfg_attr(condition, attribute, other_attribute, ...)]
11-
| ++++++++++++++++++++++++++++++++++++++++++
1211

1312
error: expected `,`, found end of `cfg_attr` input
1413
--> $DIR/cfg-attr-parse.rs:8:17
1514
|
1615
LL | #[cfg_attr(all())]
17-
| ^ expected `,`
16+
| ----------------^-
17+
| | |
18+
| | expected `,`
19+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
1820
|
19-
= help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]`
2021
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
2122

2223
error: expected identifier, found `,`
2324
--> $DIR/cfg-attr-parse.rs:16:18
2425
|
2526
LL | #[cfg_attr(all(),,)]
26-
| ^ expected identifier
27+
| -----------------^--
28+
| | |
29+
| | expected identifier
30+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
2731
|
28-
= help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]`
2932
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
3033

3134
error: expected identifier, found `,`
3235
--> $DIR/cfg-attr-parse.rs:28:28
3336
|
3437
LL | #[cfg_attr(all(), must_use,,)]
35-
| ^ expected identifier
38+
| ---------------------------^--
39+
| | |
40+
| | expected identifier
41+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
3642
|
37-
= help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]`
3843
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
3944

4045
error: expected identifier, found `,`
4146
--> $DIR/cfg-attr-parse.rs:40:40
4247
|
4348
LL | #[cfg_attr(all(), must_use, deprecated,,)]
44-
| ^ expected identifier
49+
| ---------------------------------------^--
50+
| | |
51+
| | expected identifier
52+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
4553
|
46-
= help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]`
4754
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
4855

4956
error: wrong `cfg_attr` delimiters
@@ -62,9 +69,11 @@ error: expected identifier, found `,`
6269
--> $DIR/cfg-attr-parse.rs:44:18
6370
|
6471
LL | #[cfg_attr[all(),,]]
65-
| ^ expected identifier
72+
| -----------------^--
73+
| | |
74+
| | expected identifier
75+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
6676
|
67-
= help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]`
6877
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
6978

7079
error: wrong `cfg_attr` delimiters
@@ -83,10 +92,13 @@ error: expected identifier, found `,`
8392
--> $DIR/cfg-attr-parse.rs:50:18
8493
|
8594
LL | #[cfg_attr{all(),,}]
86-
| ^ expected identifier
95+
| -----------------^--
96+
| | |
97+
| | expected identifier
98+
| help: must be of the form: `#[cfg_attr(predicate, attr1, attr2, ...)]`
8799
|
88-
= help: the valid syntax is `#[cfg_attr(condition, attribute, other_attribute, ...)]`
89100
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute>
90101

91102
error: aborting due to 9 previous errors
92103

104+
For more information about this error, try `rustc --explain E0539`.

tests/ui/conditional-compilation/cfg-attr-syntax-validation.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ struct S3;
2222
//~| NOTE for more information, visit
2323
struct S4;
2424

25-
#[cfg("str")] //~ ERROR `cfg` predicate key must be an identifier
25+
#[cfg("str")]
26+
//~^ ERROR malformed `cfg` attribute input
27+
//~| NOTE expected a valid identifier here
28+
//~| NOTE for more information, visit
2629
struct S5;
2730

28-
#[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier
31+
#[cfg(a::b)]
32+
//~^ ERROR malformed `cfg` attribute input
33+
//~| NOTE expected a valid identifier here
34+
//~| NOTE for more information, visit
2935
struct S6;
3036

3137
#[cfg(a())] //~ ERROR invalid predicate `a`

tests/ui/conditional-compilation/cfg-attr-syntax-validation.stderr

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,36 @@ LL | #[cfg(a, b)]
4242
|
4343
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
4444

45-
error: `cfg` predicate key must be an identifier
46-
--> $DIR/cfg-attr-syntax-validation.rs:25:7
45+
error[E0539]: malformed `cfg` attribute input
46+
--> $DIR/cfg-attr-syntax-validation.rs:25:1
4747
|
4848
LL | #[cfg("str")]
49-
| ^^^^^
49+
| ^^^^^^-----^^
50+
| | |
51+
| | expected a valid identifier here
52+
| help: must be of the form: `#[cfg(predicate)]`
53+
|
54+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
5055

51-
error: `cfg` predicate key must be an identifier
52-
--> $DIR/cfg-attr-syntax-validation.rs:28:7
56+
error[E0539]: malformed `cfg` attribute input
57+
--> $DIR/cfg-attr-syntax-validation.rs:31:1
5358
|
5459
LL | #[cfg(a::b)]
55-
| ^^^^
60+
| ^^^^^^----^^
61+
| | |
62+
| | expected a valid identifier here
63+
| help: must be of the form: `#[cfg(predicate)]`
64+
|
65+
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
5666

5767
error[E0537]: invalid predicate `a`
58-
--> $DIR/cfg-attr-syntax-validation.rs:31:7
68+
--> $DIR/cfg-attr-syntax-validation.rs:37:7
5969
|
6070
LL | #[cfg(a())]
6171
| ^^^
6272

6373
error[E0539]: malformed `cfg` attribute input
64-
--> $DIR/cfg-attr-syntax-validation.rs:34:1
74+
--> $DIR/cfg-attr-syntax-validation.rs:40:1
6575
|
6676
LL | #[cfg(a = 10)]
6777
| ^^^^^^^^^^--^^
@@ -72,7 +82,7 @@ LL | #[cfg(a = 10)]
7282
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
7383

7484
error[E0539]: malformed `cfg` attribute input
75-
--> $DIR/cfg-attr-syntax-validation.rs:39:1
85+
--> $DIR/cfg-attr-syntax-validation.rs:45:1
7686
|
7787
LL | #[cfg(a = b"hi")]
7888
| ^^^^^^^^^^-^^^^^^
@@ -82,7 +92,7 @@ LL | #[cfg(a = b"hi")]
8292
= note: expected a normal string literal, not a byte string literal
8393

8494
error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable
85-
--> $DIR/cfg-attr-syntax-validation.rs:45:25
95+
--> $DIR/cfg-attr-syntax-validation.rs:51:25
8696
|
8797
LL | #[cfg(feature = $expr)]
8898
| ^^^^^
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#[cfg_attr]
2+
//~^ ERROR malformed `cfg_attr` attribute
3+
struct S1;
4+
5+
#[cfg_attr = 10]
6+
//~^ ERROR malformed `cfg_attr` attribute
7+
struct S2;
8+
9+
#[cfg_attr()]
10+
//~^ ERROR malformed `cfg_attr` attribute
11+
struct S3;
12+
13+
#[cfg_attr("str")] //~ ERROR malformed `cfg_attr` attribute input
14+
struct S5;
15+
16+
#[cfg_attr(a::b)] //~ ERROR malformed `cfg_attr` attribute input
17+
struct S6;
18+
19+
#[cfg_attr(a())] //~ ERROR invalid predicate `a`
20+
struct S7;
21+
22+
#[cfg_attr(a = 10)] //~ ERROR malformed `cfg_attr` attribute input
23+
struct S8;
24+
25+
#[cfg_attr(a = b"hi")] //~ ERROR malformed `cfg_attr` attribute input
26+
struct S9;
27+
28+
macro_rules! generate_s10 {
29+
($expr: expr) => {
30+
#[cfg_attr(feature = $expr)]
31+
//~^ ERROR expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found `expr` metavariable
32+
struct S10;
33+
}
34+
}
35+
36+
generate_s10!(concat!("nonexistent"));
37+
38+
#[cfg_attr(true)] //~ ERROR expected `,`, found end of `cfg_attr` input
39+
struct S11;
40+
41+
#[cfg_attr(true, unknown_attribute)] //~ ERROR cannot find attribute `unknown_attribute` in this scope
42+
struct S12;
43+
44+
#[cfg_attr(true, link_section)] //~ ERROR malformed `link_section` attribute input
45+
struct S13;
46+
47+
#[cfg_attr(true, inline())] //~ ERROR malformed `inline` attribute input
48+
fn f1() {}
49+
50+
fn main() {}

0 commit comments

Comments
 (0)