You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `proc_macro` attribute uses the [MetaWord] syntax.
121
121
122
122
r[macro.proc.proc_macro.allowed-positions]
123
-
The `proc_macro` attribute may only be applied to a function with the signature of `pub fn(TokenStream) -> TokenStream` where [`TokenStream`] comes from the [`proc_macro` crate]. It must have the ["Rust" ABI][items.fn.extern]. No other function qualifiers are allowed.
123
+
The `proc_macro` attribute may only be applied to a `pub` function of type `fn(TokenStream) -> TokenStream` where [`TokenStream`] comes from the [`proc_macro` crate]. It must have the ["Rust" ABI][items.fn.extern]. No other function qualifiers are allowed. It must be located in the root of the crate.
124
124
125
125
r[macro.proc.proc_macro.duplicates]
126
126
The `proc_macro` attribute may only be specified once on a function.
The `proc_macro` attribute publicly defines the macro in the [macro namespace] in the root of the crate with the same name as the function.
130
130
131
131
r[macro.proc.proc_macro.behavior]
132
-
A function-like macro invocation of a function-like procedural macro will pass what is inside the delimiters of the macro invocation as the input [`TokenStream`] argument, and replace the entire macro invocation with the output [`TokenStream`] of the function.
132
+
A function-like macro invocation of a function-like procedural macro will pass what is inside the delimiters of the macro invocation as the input [`TokenStream`] argument and replace the entire macro invocation with the output [`TokenStream`] of the function.
133
133
134
134
r[macro.proc.proc_macro.invocation]
135
135
Function-like procedural macros may be invoked in any macro invocation position, which includes:
136
136
137
-
- [statements]
138
-
- [expressions]
139
-
- [patterns]
140
-
- [type expressions]
141
-
- [item] positions, including items in [`extern` blocks]
142
-
- inherent and trait [implementations]
143
-
- [trait definitions]
137
+
- [Statements]
138
+
- [Expressions]
139
+
- [Patterns]
140
+
- [Type expressions]
141
+
- [Item] positions, including items in [`extern` blocks]
0 commit comments