Skip to content

Commit 9768e0e

Browse files
authored
Merge pull request #2057 from rust-lang/TC/loosen-mbe-last-macro-imported-wins
Avoid specifying "last import wins" for MBEs
2 parents aa999e9 + d5c876c commit 9768e0e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/macros-by-example.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,12 @@ When `macro_use` is used on a module, the module's macro scope extends beyond th
390390
r[macro.decl.scope.macro_use.prelude]
391391
Specifying `macro_use` on an `extern crate` declaration in the crate root imports exported macros from that crate.
392392
393-
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.
393+
Macros imported this way are imported into the [`macro_use` prelude], not textually, which means that they can be shadowed by any other name. Macros imported by `macro_use` can be used before the import statement.
394+
395+
> [!NOTE]
396+
> `rustc` currently prefers the last macro imported in case of conflict. Don't rely on this. This behavior is unusual, as imports in Rust are generally order-independent. This behavior of `macro_use` may change in the future.
397+
>
398+
> For details, see [Rust issue #148025](https://github.com/rust-lang/rust/issues/148025).
394399
395400
When using the [MetaWord] syntax, all exported macros are imported. When using the [MetaListIdents] syntax, only the specified macros are imported.
396401

0 commit comments

Comments
 (0)