Open
Description
Examples of inert attributes on macro invocations:
#[inert]
bang_macro!();
#[inert]
#[attr_macro]
struct S;
#[inert]
#[derive(DeriveMacro)]
struct S;
// Doc comments are also attributes (attribute literals if you wish).
/// Doc.
bang_macro!();
/// Doc.
#[attr_macro]
struct S;
/// Doc.
#[derive(DeriveMacro)]
struct S;
How these attributes are treated currently (ad hoc, there's no RFC or anything):
- For bang macros the attributes are thrown away (sometimes with a warning).
- For attribute macros and derive macros the attributes become a part of the macro input, the attribute tokens are prepended to the tokens of the "primary" input.
Effectively,#[inert] #[macro_attr] struct S;
->macro_attr! { #[inert] struct S; }
.
Related issues: #61733 (comment).