@@ -75,9 +75,7 @@ the macro invocation operator (`!`).
7575These macros are defined by a [public] [function] with the `proc_macro`
7676[attribute ] and a signature of `(TokenStream) -> TokenStream`. The input
7777[`TokenStream` ] is what is inside the delimiters of the macro invocation and the
78- output [`TokenStream`] replaces the entire macro invocation. It may contain an
79- arbitrary number of [items]. These macros cannot expand to syntax that defines
80- new `macro_rules` style macros.
78+ output [`TokenStream`] replaces the entire macro invocation.
8179
8280For example, the following macro definition ignores its input and outputs a
8381function `answer` into its scope.
@@ -105,11 +103,12 @@ fn main() {
105103}
106104```
107105
108- These macros are only invokable in [ modules] . They cannot even be invoked to
109- create [ item declaration statements] . Furthermore, they must either be invoked
110- with curly braces and no semicolon or a different delimiter followed by a
111- semicolon. For example, ` make_answer ` from the previous example can be invoked
112- as ` make_answer!{} ` , ` make_answer!(); ` or ` make_answer![]; ` .
106+ Function-like procedural macros may expand to a [ type] or any number of
107+ [ items] . They may be invoked in a [ type expression] , [ item] position (except
108+ as a [ statement] ), including items in [ ` extern ` blocks] , inherent and trait
109+ [ implementations] , and [ trait definitions] . They cannot be used in a
110+ [ statement] , [ expression] , or [ pattern] . These macros cannot expand to syntax
111+ that defines new [ ` macro_rules ` ] style macros.
113112
114113### Derive macros
115114
@@ -192,7 +191,9 @@ struct Struct {
192191
193192### Attribute macros
194193
195- * Attribute macros* define new [ attributes] which can be attached to [ items] .
194+ * Attribute macros* define new [ outer attributes] [ attributes ] which can be
195+ attached to [ items] , including items in [ ` extern ` blocks] , inherent and trait
196+ [ implementations] , and [ trait definitions] .
196197
197198Attribute macros are defined by a [ public]   ; [ function] with the
198199` proc_macro_attribute ` [ attribute] that has a signature of `(TokenStream,
@@ -202,7 +203,7 @@ the attribute is written as a bare attribute name, the attribute
202203[ ` TokenStream ` ] is empty. The second [ ` TokenStream ` ] is the rest of the [ item]
203204including other [ attributes] on the [ item] . The returned [ ` TokenStream ` ]
204205replaces the [ item] with an arbitrary number of [ items] . These macros cannot
205- expand to syntax that defines new ` macro_rules ` style macros.
206+ expand to syntax that defines new [ ` macro_rules ` ] style macros.
206207
207208For example, this attribute macro takes the input stream and returns it as is,
208209effectively being the no-op of attributes.
@@ -266,28 +267,35 @@ fn invoke4() {}
266267// out: item: "fn invoke4() {}"
267268```
268269
270+ [ Attribute macros ] : #attribute-macros
271+ [ Cargo's build scripts ] : ../cargo/reference/build-scripts.html
272+ [ Derive macros ] : #derive-macros
273+ [ Function-like macros ] : #function-like-procedural-macros
269274[ `TokenStream` ] : ../proc_macro/struct.TokenStream.html
270275[ `TokenStream`s ] : ../proc_macro/struct.TokenStream.html
271276[ `compile_error` ] : ../std/macro.compile_error.html
272277[ `derive` attribute ] : attributes/derive.md
278+ [ `extern` blocks ] : items/external-blocks.md
279+ [ `macro_rules` ] : macros-by-example.md
273280[ `proc_macro` crate ] : ../proc_macro/index.html
274- [ Cargo's build scripts ] : ../cargo/reference/build-scripts.html
275- [ Derive macros ] : #derive-macros
276- [ Attribute macros ] : #attribute-macros
277- [ Function-like macros ] : #function-like-procedural-macros
278281[ attribute ] : attributes.md
279282[ attributes ] : attributes.md
280283[ block ] : expressions/block-expr.md
281284[ crate type ] : linkage.md
282285[ derive macro helper attributes ] : #derive-macro-helper-attributes
283286[ enum ] : items/enumerations.md
287+ [ expression ] : expressions.md
288+ [ function ] : items/functions.md
289+ [ implementations ] : items/implementations.md
284290[ inert ] : attributes.md#active-and-inert-attributes
285291[ item ] : items.md
286- [ item declaration statements ] : statements.md#item-declarations
287292[ items ] : items.md
288- [ function ] : items/functions.md
289293[ module ] : items/modules.md
290- [ modules ] : items/modules .md
294+ [ pattern ] : patterns .md
291295[ public ] : visibility-and-privacy.md
296+ [ statement ] : statements.md
292297[ struct ] : items/structs.md
298+ [ trait definitions ] : items/traits.md
299+ [ type expression ] : types.md#type-expressions
300+ [ type ] : types.md
293301[ union ] : items/unions.md
0 commit comments