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
This moves it to the macro_export section (since it is part of that
macro).
There are slight wording differences. One new addition is to clarify
that it only works for single-segment paths.
Adding `local_inner_macros` tothe `macro_export` attributealsocausesallsingle-segmentmacroinvocationsinthemacrodefinitiontohaveanimplicit `$crate::` prefix.Thisisintendedprimarilyasatooltomigratecodewrittenbefore [`$crate`] wasaddedtothelanguagetoworkwithRust2018'spath-basedimportsofmacros.Itsuse is discouraged in new code.
> 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.
557
-
558
-
r[macro.decl.hygiene.local_inner_macros]
559
-
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.
560
-
561
-
```rust
562
-
#[macro_export(local_inner_macros)]
563
-
macro_rules!helped {
564
-
() => { helper!() } // Automatically converted to $crate::helper!().
565
-
}
566
-
567
-
#[macro_export]
568
-
macro_rules!helper {
569
-
() => { () }
570
-
}
571
-
```
572
+
> Prior to Rust 1.30, `$crate` and [`local_inner_macros`][macro.decl.scope.macro_export.local_inner_macros] were unsupported. They were added alongside [path-based imports of macros][macro.decl.scope.macro_export], 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.
0 commit comments