-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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?
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.