diff --git a/src/items/extern-crates.md b/src/items/extern-crates.md index a3e9b43d9..3c61ce220 100644 --- a/src/items/extern-crates.md +++ b/src/items/extern-crates.md @@ -83,11 +83,12 @@ by using an underscore with the form `extern crate foo as _`. This may be useful for crates that only need to be linked, but are never referenced, and will avoid being reported as unused. -The `#[macro_use]` attribute will work as usual and import the macro names +The [`#[macro_use]` attribute] will work as usual and import the macro names into the macro-use prelude. [IDENTIFIER]: identifiers.html [RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md +[`#[macro_use]` attribute]: attributes.html#macro-related-attributes [`alloc`]: https://doc.rust-lang.org/alloc/ [`crate::`]: paths.html#crate [`proc_macro`]: https://doc.rust-lang.org/proc_macro/ diff --git a/src/items/use-declarations.md b/src/items/use-declarations.md index fc3e62f70..264d52a54 100644 --- a/src/items/use-declarations.md +++ b/src/items/use-declarations.md @@ -180,6 +180,21 @@ fn main() { } ``` +The unique, unnameable symbols are created after macro expansion so that +macros may safely emit multiple references to `_` imports. For example, the +following should not produce an error: + +```rust +macro_rules! m { + ($item: item) => { $item $item } +} + +m!(use std as _;); +// This expands to: +// use std as _; +// use std as _; +``` + [IDENTIFIER]: identifiers.html [_SimplePath_]: paths.html#simple-paths [`extern crate`]: items/extern-crates.html