Skip to content

Commit 192d0bf

Browse files
committed
Revise proc_macro_attribute text
1 parent 6d8ab85 commit 192d0bf

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/procedural-macros.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,15 @@ A helper attribute for a derive macro is declared by adding its identifier to th
228228
> }
229229
> ```
230230
231+
<!-- template:attributes -->
231232
r[macro.proc.attribute]
232233
## The `proc_macro_attribute` attribute
233234
234235
r[macro.proc.attribute.intro]
235236
The *`proc_macro_attribute` [attribute][attributes]* defines an *attribute macro* which can be used as an [outer attribute][attributes].
236237
237238
> [!EXAMPLE]
238-
> The following attribute macro takes the input stream and returns it as is, effectively being the no-op of attributes.
239+
> This attribute macro takes the input stream and emits it as-is, effectively being a no-op attribute.
239240
>
240241
> <!-- ignore: test doesn't support proc-macro -->
241242
> ```rust,ignore
@@ -250,7 +251,7 @@ The *`proc_macro_attribute` [attribute][attributes]* defines an *attribute macro
250251
> ```
251252
252253
> [!EXAMPLE]
253-
> This following example shows the stringified [`TokenStream`s] that the attribute macros see. The output will show in the output of the compiler. The output is shown in the comments after the function prefixed with "out:".
254+
> This shows, in the output of the compiler, the stringified [`TokenStream`s] that attribute macros see.
254255
>
255256
> <!-- ignore: test doesn't support proc-macro -->
256257
> ```rust,ignore
@@ -273,36 +274,36 @@ The *`proc_macro_attribute` [attribute][attributes]* defines an *attribute macro
273274
>
274275
> use my_macro::show_streams;
275276
>
276-
> // Example: Basic function
277+
> // Example: Basic function.
277278
> #[show_streams]
278279
> fn invoke1() {}
279280
> // out: attr: ""
280281
> // out: item: "fn invoke1() {}"
281282
>
282-
> // Example: Attribute with input
283+
> // Example: Attribute with input.
283284
> #[show_streams(bar)]
284285
> fn invoke2() {}
285286
> // out: attr: "bar"
286287
> // out: item: "fn invoke2() {}"
287288
>
288-
> // Example: Multiple tokens in the input
289+
> // Example: Multiple tokens in the input.
289290
> #[show_streams(multiple => tokens)]
290291
> fn invoke3() {}
291292
> // out: attr: "multiple => tokens"
292293
> // out: item: "fn invoke3() {}"
293294
>
294-
> // Example:
295+
> // Example: Delimiters in the input.
295296
> #[show_streams { delimiters }]
296297
> fn invoke4() {}
297298
> // out: attr: "delimiters"
298299
> // out: item: "fn invoke4() {}"
299300
> ```
300301
301302
r[macro.proc.attribute.syntax]
302-
The `proc_macro_attribute` attribute uses the [MetaWord] syntax and thus does not take any inputs.
303+
The `proc_macro_attribute` attribute uses the [MetaWord] syntax.
303304
304305
r[macro.proc.attribute.allowed-positions]
305-
The `proc_macro_attribute` attribute may only be applied to a function with the signature of `pub fn(TokenStream, 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.
306+
The `proc_macro_attribute` attribute may only be applied to a `pub` function of type `fn(TokenStream, 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.
306307
307308
r[macro.proc.attribute.duplicates]
308309
The `proc_macro_attribute` attribute may only be specified once on a function.

0 commit comments

Comments
 (0)