Skip to content

Commit 99c96cd

Browse files
ehusstraviscross
authored andcommitted
Unwrap macro_export
1 parent 752eab0 commit 99c96cd

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/macros-by-example.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ r[macro.decl.scope.path]
372372
### Path-based scope
373373

374374
r[macro.decl.scope.path.intro]
375-
By default, a macro has no path-based scope. However, if it has the
376-
`#[macro_export]` attribute, then it is declared in the crate root scope and can
377-
be referred to normally as such:
375+
By default, a macro has no path-based scope. However, if it has the `#[macro_export]` attribute, then it is declared in the crate root scope and can be referred to normally as such:
378376

379377
```rust
380378
self::m!();
@@ -394,8 +392,7 @@ mod mac {
394392
```
395393

396394
r[macro.decl.scope.path.export]
397-
Macros labeled with `#[macro_export]` are always `pub` and can be referred to
398-
by other crates, either by path or by `#[macro_use]` as described above.
395+
Macros labeled with `#[macro_export]` are always `pub` and can be referred to by other crates, either by path or by `#[macro_use]` as described above.
399396

400397
r[macro.decl.hygiene]
401398
## Hygiene
@@ -495,20 +492,11 @@ macro_rules! call_foo {
495492
fn foo() {}
496493
```
497494

498-
> **Version differences**: Prior to Rust 1.30, `$crate` and
499-
> `local_inner_macros` (below) were unsupported. They were added alongside
500-
> path-based imports of macros (described above), to ensure that helper macros
501-
> did not need to be manually imported by users of a macro-exporting crate.
502-
> Crates written for earlier versions of Rust that use helper macros need to be
503-
> modified to use `$crate` or `local_inner_macros` to work well with path-based
504-
> imports.
495+
> [!NOTE]
496+
> Prior to Rust 1.30, `$crate` and `local_inner_macros` (below) were unsupported. They were added alongside path-based imports of macros (described above), to ensure that helper macros did not need to be manually imported by users of a macro-exporting crate. Crates written for earlier versions of Rust that use helper macros need to be modified to use `$crate` or `local_inner_macros` to work well with path-based imports.
505497
506498
r[macro.decl.hygiene.local_inner_macros]
507-
When a macro is exported, the `#[macro_export]` attribute can have the
508-
`local_inner_macros` keyword added to automatically prefix all contained macro
509-
invocations with `$crate::`. This is intended primarily as a tool to migrate
510-
code written before `$crate` was added to the language to work with Rust 2018's
511-
path-based imports of macros. Its use is discouraged in new code.
499+
When a macro is exported, the `#[macro_export]` attribute can have the `local_inner_macros` keyword added to automatically prefix all contained macro invocations with `$crate::`. This is intended primarily as a tool to migrate code written before `$crate` was added to the language to work with Rust 2018's path-based imports of macros. Its use is discouraged in new code.
512500

513501
```rust
514502
#[macro_export(local_inner_macros)]

0 commit comments

Comments
 (0)