File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -83,11 +83,12 @@ by using an underscore with the form `extern crate foo as _`. This may be
8383useful for crates that only need to be linked, but are never referenced, and
8484will avoid being reported as unused.
8585
86- The `#[macro_use]` attribute will work as usual and import the macro names
86+ The [ `#[macro_use]` attribute] will work as usual and import the macro names
8787into the macro - use prelude.
8888
8989[IDENTIFIER]: identifiers. html
9090[RFC 940]: https: // github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md
91+ [`#[macro_use]` attribute]: attributes. html#macro - related- attributes
9192[`alloc`]: https: // doc.rust-lang.org/alloc/
9293[`crate :: `]: paths. html#crate
9394[`proc_macro`]: https: // doc.rust-lang.org/proc_macro/
Original file line number Diff line number Diff line change @@ -180,6 +180,21 @@ fn main() {
180180}
181181```
182182
183+ The unique, unnameable symbols are created after macro expansion so that
184+ macros may safely emit multiple references to ` _ ` imports. For example, the
185+ following should not produce an error:
186+
187+ ``` rust
188+ macro_rules! m {
189+ ($ item : item ) => { $ item $ item }
190+ }
191+
192+ m! (use std as _;);
193+ // This expands to:
194+ // use std as _;
195+ // use std as _;
196+ ```
197+
183198[ IDENTIFIER ] : identifiers.html
184199[ _SimplePath_ ] : paths.html#simple-paths
185200[ `extern crate` ] : items/extern-crates.html
You can’t perform that action at this time.
0 commit comments