Skip to content

Commit 84b75b3

Browse files
committed
Add test of eager expansion failure in a stability attribute
1 parent c010fbb commit 84b75b3

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![crate_type = "lib"]
2+
#![feature(staged_api)]
3+
#![stable(feature = "stable_test_feature", since = "3.3.3")]
4+
5+
macro_rules! not_a_literal {
6+
() => {
7+
boohoo
8+
};
9+
}
10+
11+
macro_rules! m {
12+
() => {
13+
#[stable(feature = 1 + 1, since = "?")]
14+
//~^ expression in the value of this attribute must be a literal or macro call
15+
//~^^ incorrect meta item
16+
//~^^^ incorrect meta item
17+
pub struct Math; //~ struct has missing stability attribute
18+
19+
#[stable(feature = not_a_literal!(), since = "?")]
20+
//~^ expression in the value of this attribute must be a literal or macro call
21+
//~^^ incorrect meta item
22+
//~^^^ incorrect meta item
23+
pub struct NotLiteral; //~ struct has missing stability attribute
24+
};
25+
}
26+
27+
m!();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
error: expression in the value of this attribute must be a literal or macro call
2+
--> $DIR/eager-expansion-fail.rs:13:28
3+
|
4+
LL | #[stable(feature = 1 + 1, since = "?")]
5+
| ^^^^^
6+
...
7+
LL | m!();
8+
| ---- in this macro invocation
9+
|
10+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
11+
12+
error: expression in the value of this attribute must be a literal or macro call
13+
--> $DIR/eager-expansion-fail.rs:19:28
14+
|
15+
LL | #[stable(feature = not_a_literal!(), since = "?")]
16+
| ^^^^^^^^^^^^^^^^
17+
...
18+
LL | m!();
19+
| ---- in this macro invocation
20+
|
21+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
error[E0539]: incorrect meta item
24+
--> $DIR/eager-expansion-fail.rs:13:18
25+
|
26+
LL | #[stable(feature = 1 + 1, since = "?")]
27+
| ^^^^^^^^^^^^^^^
28+
...
29+
LL | m!();
30+
| ---- in this macro invocation
31+
|
32+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
33+
34+
error[E0539]: incorrect meta item
35+
--> $DIR/eager-expansion-fail.rs:13:18
36+
|
37+
LL | #[stable(feature = 1 + 1, since = "?")]
38+
| ^^^^^^^^^^^^^^^
39+
...
40+
LL | m!();
41+
| ---- in this macro invocation
42+
|
43+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
44+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
45+
46+
error[E0539]: incorrect meta item
47+
--> $DIR/eager-expansion-fail.rs:19:18
48+
|
49+
LL | #[stable(feature = not_a_literal!(), since = "?")]
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
51+
...
52+
LL | m!();
53+
| ---- in this macro invocation
54+
|
55+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
56+
57+
error[E0539]: incorrect meta item
58+
--> $DIR/eager-expansion-fail.rs:19:18
59+
|
60+
LL | #[stable(feature = not_a_literal!(), since = "?")]
61+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
...
63+
LL | m!();
64+
| ---- in this macro invocation
65+
|
66+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
67+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
68+
69+
error: struct has missing stability attribute
70+
--> $DIR/eager-expansion-fail.rs:17:9
71+
|
72+
LL | pub struct Math;
73+
| ^^^^^^^^^^^^^^^^
74+
...
75+
LL | m!();
76+
| ---- in this macro invocation
77+
|
78+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
79+
80+
error: struct has missing stability attribute
81+
--> $DIR/eager-expansion-fail.rs:23:9
82+
|
83+
LL | pub struct NotLiteral;
84+
| ^^^^^^^^^^^^^^^^^^^^^^
85+
...
86+
LL | m!();
87+
| ---- in this macro invocation
88+
|
89+
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
90+
91+
error: aborting due to 8 previous errors
92+
93+
For more information about this error, try `rustc --explain E0539`.

0 commit comments

Comments
 (0)