You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/macros-by-example.md
+5-17Lines changed: 5 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -372,9 +372,7 @@ r[macro.decl.scope.path]
372
372
### Path-based scope
373
373
374
374
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:
378
376
379
377
```rust
380
378
self::m!();
@@ -394,8 +392,7 @@ mod mac {
394
392
```
395
393
396
394
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.
399
396
400
397
r[macro.decl.hygiene]
401
398
## Hygiene
@@ -495,20 +492,11 @@ macro_rules! call_foo {
495
492
fnfoo() {}
496
493
```
497
494
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.
505
497
506
498
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.
0 commit comments