Skip to content

Commit 5bf7161

Browse files
ehusstraviscross
authored andcommitted
Unwrap proc_macro_attribute
1 parent 80bd085 commit 5bf7161

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
@@ -244,25 +244,15 @@ r[macro.proc.attribute]
244244
## Attribute macros
245245
246246
r[macro.proc.attribute.intro]
247-
*Attribute macros* define new [outer attributes][attributes] which can be
248-
attached to [items], including items in [`extern` blocks], inherent and trait
249-
[implementations], and [trait definitions].
247+
*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].
250248
251249
r[macro.proc.attribute.def]
252-
Attribute macros are defined by a [public] [function] with the
253-
`proc_macro_attribute` [attribute] that has a signature of `(TokenStream,
254-
TokenStream) -> TokenStream`. The first [`TokenStream`] is the delimited token
255-
tree following the attribute's name, not including the outer delimiters. If
256-
the attribute is written as a bare attribute name, the attribute
257-
[`TokenStream`] is empty. The second [`TokenStream`] is the rest of the [item]
258-
including other [attributes] on the [item]. The returned [`TokenStream`]
259-
replaces the [item] with an arbitrary number of [items].
250+
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].
260251
261252
r[macro.proc.attribute.namespace]
262253
The `proc_macro_attribute` attribute defines the attribute in the [macro namespace] in the root of the crate.
263254
264-
For example, this attribute macro takes the input stream and returns it as is,
265-
effectively being the no-op of attributes.
255+
For example, this attribute macro takes the input stream and returns it as is, effectively being the no-op of attributes.
266256
267257
<!-- ignore: test doesn't support proc-macro -->
268258
```rust,ignore
@@ -276,9 +266,7 @@ pub fn return_as_is(_attr: TokenStream, item: TokenStream) -> TokenStream {
276266
}
277267
```
278268
279-
This following example shows the stringified [`TokenStream`s] that the attribute
280-
macros see. The output will show in the output of the compiler. The output is
281-
shown in the comments after the function prefixed with "out:".
269+
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:".
282270

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

0 commit comments

Comments
 (0)