Skip to content

Commit 1c75f5a

Browse files
committed
parse: test bad variants wrt. issue 48137.
1 parent fde5939 commit 1c75f5a

2 files changed

+97
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
fn main() {}
2+
3+
macro_rules! expand_to_enum {
4+
() => {
5+
enum BadE {}
6+
//~^ ERROR enum is not supported in `trait`s or `impl`s
7+
//~| ERROR enum is not supported in `trait`s or `impl`s
8+
//~| ERROR enum is not supported in `extern` blocks
9+
};
10+
}
11+
12+
macro_rules! mac_impl {
13+
($($i:item)*) => {
14+
struct S;
15+
impl S { $($i)* }
16+
}
17+
}
18+
19+
mac_impl! {
20+
struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s
21+
expand_to_enum!();
22+
}
23+
24+
macro_rules! mac_trait {
25+
($($i:item)*) => {
26+
trait T { $($i)* }
27+
}
28+
}
29+
30+
mac_trait! {
31+
struct BadS; //~ ERROR struct is not supported in `trait`s or `impl`s
32+
expand_to_enum!();
33+
}
34+
35+
macro_rules! mac_extern {
36+
($($i:item)*) => {
37+
extern "C" { $($i)* }
38+
}
39+
}
40+
41+
mac_extern! {
42+
struct BadS; //~ ERROR struct is not supported in `extern` blocks
43+
expand_to_enum!();
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
error: struct is not supported in `trait`s or `impl`s
2+
--> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:20:5
3+
|
4+
LL | struct BadS;
5+
| ^^^^^^^^^^^^
6+
7+
error: enum is not supported in `trait`s or `impl`s
8+
--> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
9+
|
10+
LL | enum BadE {}
11+
| ^^^^^^^^^
12+
...
13+
LL | expand_to_enum!();
14+
| ------------------ in this macro invocation
15+
|
16+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error: struct is not supported in `trait`s or `impl`s
19+
--> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:31:5
20+
|
21+
LL | struct BadS;
22+
| ^^^^^^^^^^^^
23+
24+
error: enum is not supported in `trait`s or `impl`s
25+
--> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
26+
|
27+
LL | enum BadE {}
28+
| ^^^^^^^^^
29+
...
30+
LL | expand_to_enum!();
31+
| ------------------ in this macro invocation
32+
|
33+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
34+
35+
error: struct is not supported in `extern` blocks
36+
--> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:42:5
37+
|
38+
LL | struct BadS;
39+
| ^^^^^^^^^^^^
40+
41+
error: enum is not supported in `extern` blocks
42+
--> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:5:9
43+
|
44+
LL | enum BadE {}
45+
| ^^^^^^^^^
46+
...
47+
LL | expand_to_enum!();
48+
| ------------------ in this macro invocation
49+
|
50+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
51+
52+
error: aborting due to 6 previous errors
53+

0 commit comments

Comments
 (0)