Skip to content

Commit c1904bf

Browse files
committed
Add test that eager expansion does not happen in non-stability attribute
1 parent 7f9cfa5 commit c1904bf

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

tests/ui/stability-attribute/eager-expansion-fail.rs

+10
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ macro_rules! not_a_literal {
88
};
99
}
1010

11+
macro_rules! deprecation_msg {
12+
() => {
13+
"..."
14+
};
15+
}
16+
1117
macro_rules! m {
1218
() => {
1319
#[stable(feature = 1 + 1, since = "?")] //~ expression in the value of this attribute must be a literal or macro call
1420
pub struct Math; //~ struct has missing stability attribute
1521

1622
#[stable(feature = not_a_literal!(), since = "?")] //~ expression in the value of this attribute must be a literal or macro call
1723
pub struct NotLiteral; //~ struct has missing stability attribute
24+
25+
#[unstable(feature = "deprecated", issue = "none")]
26+
#[deprecated(reason = deprecation_msg!())] //~ expected unsuffixed literal or identifier, found `deprecation_msg`
27+
pub struct Deprecated;
1828
};
1929
}
2030

tests/ui/stability-attribute/eager-expansion-fail.stderr

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expression in the value of this attribute must be a literal or macro call
2-
--> $DIR/eager-expansion-fail.rs:13:28
2+
--> $DIR/eager-expansion-fail.rs:19:28
33
|
44
LL | #[stable(feature = 1 + 1, since = "?")]
55
| ^^^^^
@@ -10,7 +10,7 @@ LL | m!();
1010
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

1212
error: expression in the value of this attribute must be a literal or macro call
13-
--> $DIR/eager-expansion-fail.rs:16:28
13+
--> $DIR/eager-expansion-fail.rs:22:28
1414
|
1515
LL | #[stable(feature = not_a_literal!(), since = "?")]
1616
| ^^^^^^^^^^^^^^^^
@@ -20,8 +20,19 @@ LL | m!();
2020
|
2121
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
2222

23+
error: expected unsuffixed literal or identifier, found `deprecation_msg`
24+
--> $DIR/eager-expansion-fail.rs:26:31
25+
|
26+
LL | #[deprecated(reason = deprecation_msg!())]
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+
2334
error: struct has missing stability attribute
24-
--> $DIR/eager-expansion-fail.rs:14:9
35+
--> $DIR/eager-expansion-fail.rs:20:9
2536
|
2637
LL | pub struct Math;
2738
| ^^^^^^^^^^^^^^^^
@@ -32,7 +43,7 @@ LL | m!();
3243
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
3344

3445
error: struct has missing stability attribute
35-
--> $DIR/eager-expansion-fail.rs:17:9
46+
--> $DIR/eager-expansion-fail.rs:23:9
3647
|
3748
LL | pub struct NotLiteral;
3849
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -42,5 +53,5 @@ LL | m!();
4253
|
4354
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
4455

45-
error: aborting due to 4 previous errors
56+
error: aborting due to 5 previous errors
4657

0 commit comments

Comments
 (0)