Skip to content

Commit 649862e

Browse files
committed
Unwrap proc_macro_attribute
1 parent 9571d4d commit 649862e

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/procedural-macros.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,15 @@ r[macro.proc.attribute]
224224
## Attribute macros
225225

226226
r[macro.proc.attribute.intro]
227-
*Attribute macros* define new [outer attributes][attributes] which can be
228-
attached to [items], including items in [`extern` blocks], inherent and trait
229-
[implementations], and [trait definitions].
227+
*Attribute macros* define new [outer attributes][attributes] which can be attached to [items], including items in [`extern` blocks], inherent and trait [implementations], and [trait definitions].
230228

231229
r[macro.proc.attribute.def]
232-
Attribute macros are defined by a [public] [function] with the
233-
`proc_macro_attribute` [attribute] that has a signature of `(TokenStream,
234-
TokenStream) -> TokenStream`. The first [`TokenStream`] is the delimited token
235-
tree following the attribute's name, not including the outer delimiters. If
236-
the attribute is written as a bare attribute name, the attribute
237-
[`TokenStream`] is empty. The second [`TokenStream`] is the rest of the [item]
238-
including other [attributes] on the [item]. The returned [`TokenStream`]
239-
replaces the [item] with an arbitrary number of [items].
230+
Attribute macros are defined by a [public] [function] with the `proc_macro_attribute` [attribute] that has a signature of `(TokenStream, TokenStream) -> TokenStream`. The first [`TokenStream`] is the delimited token tree following the attribute's name, not including the outer delimiters. If the attribute is written as a bare attribute name, the attribute [`TokenStream`] is empty. The second [`TokenStream`] is the rest of the [item] including other [attributes] on the [item]. The returned [`TokenStream`] replaces the [item] with an arbitrary number of [items].
240231

241232
r[macro.proc.attribute.namespace]
242233
The `proc_macro_attribute` attribute defines the attribute in the [macro namespace] in the root of the crate.
243234

244-
For example, this attribute macro takes the input stream and returns it as is,
245-
effectively being the no-op of attributes.
235+
For example, this attribute macro takes the input stream and returns it as is, effectively being the no-op of attributes.
246236

247237
<!-- ignore: test doesn't support proc-macro -->
248238
```rust,ignore
@@ -256,9 +246,7 @@ pub fn return_as_is(_attr: TokenStream, item: TokenStream) -> TokenStream {
256246
}
257247
```
258248

259-
This following example shows the stringified [`TokenStream`s] that the attribute
260-
macros see. The output will show in the output of the compiler. The output is
261-
shown in the comments after the function prefixed with "out:".
249+
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:".
262250

263251
<!-- ignore: test doesn't support proc-macro -->
264252
```rust,ignore

0 commit comments

Comments
 (0)