Skip to content

Commit 5e1bf56

Browse files
committed
Add test for incomplete derive macro output parse.
1 parent 1a7591d commit 5e1bf56

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/test/ui/proc-macro/auxiliary/derive-bad.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ use proc_macro::TokenStream;
1111
pub fn derive_a(_input: TokenStream) -> TokenStream {
1212
"struct A { inner }".parse().unwrap()
1313
}
14+
15+
#[proc_macro_derive(B)]
16+
pub fn derive_b(_input: TokenStream) -> TokenStream {
17+
"const _: () = (); { HEY! }".parse().unwrap()
18+
}

src/test/ui/proc-macro/derive-bad.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ extern crate derive_bad;
88
//~| ERROR expected `:`, found `}`
99
struct A; //~ ERROR the name `A` is defined multiple times
1010

11+
#[derive(B)]
12+
//~^ ERROR proc-macro derive produced unparseable tokens
13+
struct B;
14+
1115
fn main() {}

src/test/ui/proc-macro/derive-bad.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ LL | struct A;
2323
|
2424
= note: `A` must be defined only once in the type namespace of this module
2525

26-
error: aborting due to 3 previous errors
26+
error: proc-macro derive produced unparseable tokens
27+
--> $DIR/derive-bad.rs:11:10
28+
|
29+
LL | #[derive(B)]
30+
| ^
31+
32+
error: aborting due to 4 previous errors
2733

2834
For more information about this error, try `rustc --explain E0428`.

0 commit comments

Comments
 (0)