Skip to content

Commit c4fff54

Browse files
ehusstraviscross
authored andcommitted
Minor update of macro_use
More closely align with the template, and some minor word tweaks.
1 parent 6b5d780 commit c4fff54

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/macros-by-example.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,28 +326,29 @@ fn foo() {
326326
// m!(); // Error: m is not in scope.
327327
```
328328

329+
<!-- template:attributes -->
329330
r[macro.decl.scope.macro_use]
330331
### The `macro_use` attribute
331332

332333
r[macro.decl.scope.macro_use.intro]
333334
The *`macro_use` [attribute][attributes]* has two purposes. It may be used on modules to extend the scope of macros defined within them, and it may be used on [`extern crate`][items.extern-crate] to import macros from another crate.
334335

335336
r[macro.decl.scope.macro_use.syntax]
336-
When used on a module, the `macro_use` attribute uses the [MetaWord] syntax and thus does not take any inputs.
337+
When used on a module, the `macro_use` attribute uses the [MetaWord] syntax.
337338

338-
When used on an `extern crate`, it uses either the [MetaWord] or [MetaListIdents] syntax.
339+
When used on an `extern crate`, it uses either the [MetaWord] or [MetaListIdents] syntax (described in [macro.decl.scope.macro_use.prelude]).
339340

340341
r[macro.decl.scope.macro_use.allowed-positions]
341342
The `macro_use` attribute may be applied to modules or `extern crate`.
342343

343344
> [!NOTE]
344-
> `rustc` currently warns in other positions, but this may be rejected in the future.
345+
> `rustc` ignores use in other positions but lints against it. This may become an error in the future.
345346
346347
r[macro.decl.scope.macro_use.extern-crate-self]
347348
The `macro_use` attribute may not be used on [`extern crate self`].
348349

349350
r[macro.decl.scope.macro_use.duplicates]
350-
Duplicate instances of `macro_use` that are in the [MetaWord] syntax have no effect if there is already a `macro_use` with the [MetaWord] syntax.
351+
The `macro_use` attribute may be used any number of times on a form.
351352

352353
Multiple instances of `macro_use` that are in the [MetaListIdents] syntax may be specified. The union of all specified macros to import will be imported.
353354

@@ -370,7 +371,7 @@ When `macro_use` is used on a module, it causes the module's macro scope to not
370371
> ```
371372
372373
r[macro.decl.scope.macro_use.prelude]
373-
When `macro_use` is used on an `extern crate` declaration in the crate root, it imports exported macros from that crate.
374+
Specifying `macro_use` on an `extern crate` declaration in the crate root imports exported macros from that crate.
374375
375376
Macros imported this way are imported into the [`macro_use` prelude], not textually, which means that they can be shadowed by any other name. While macros imported by `macro_use` can be used before the import statement, in case of a conflict, the last macro imported wins.
376377

0 commit comments

Comments
 (0)