Skip to content

Commit 6f98c08

Browse files
ehusstraviscross
authored andcommitted
Unwrap proc_macro_attribute
1 parent 752eab0 commit 6f98c08

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
@@ -232,25 +232,15 @@ r[macro.proc.attribute]
232232
## Attribute macros
233233
234234
r[macro.proc.attribute.intro]
235-
*Attribute macros* define new [outer attributes][attributes] which can be
236-
attached to [items], including items in [`extern` blocks], inherent and trait
237-
[implementations], and [trait definitions].
235+
*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].
238236
239237
r[macro.proc.attribute.def]
240-
Attribute macros are defined by a [public] [function] with the
241-
`proc_macro_attribute` [attribute] that has a signature of `(TokenStream,
242-
TokenStream) -> TokenStream`. The first [`TokenStream`] is the delimited token
243-
tree following the attribute's name, not including the outer delimiters. If
244-
the attribute is written as a bare attribute name, the attribute
245-
[`TokenStream`] is empty. The second [`TokenStream`] is the rest of the [item]
246-
including other [attributes] on the [item]. The returned [`TokenStream`]
247-
replaces the [item] with an arbitrary number of [items].
238+
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].
248239
249240
r[macro.proc.attribute.namespace]
250241
The `proc_macro_attribute` attribute defines the attribute in the [macro namespace] in the root of the crate.
251242
252-
For example, this attribute macro takes the input stream and returns it as is,
253-
effectively being the no-op of attributes.
243+
For example, this attribute macro takes the input stream and returns it as is, effectively being the no-op of attributes.
254244
255245
<!-- ignore: test doesn't support proc-macro -->
256246
```rust,ignore
@@ -264,9 +254,7 @@ pub fn return_as_is(_attr: TokenStream, item: TokenStream) -> TokenStream {
264254
}
265255
```
266256
267-
This following example shows the stringified [`TokenStream`s] that the attribute
268-
macros see. The output will show in the output of the compiler. The output is
269-
shown in the comments after the function prefixed with "out:".
257+
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:".
270258

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

0 commit comments

Comments
 (0)