Open
Description
macro_rules! typ {
() => { i32 };
}
#[derive(Debug)]
struct MyStruct<T> {
field: typ!(),
}
The compiler gives this error:
error: `derive` cannot be used on items with type macros
--> src/main.rs:7:12
|
7 | field: typ!(),
| ^^^^^^
But if I change MyStruct into non-generic type
macro_rules! typ {
() => { i32 };
}
#[derive(Debug)]
struct MyStruct {
field: typ!(),
}
It works without any error.
Why can't use #[derive] and macro on a generic type at the same time?
Is it a compiler bug?