-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #40501 - jseyfried:shadow_builtin_macros, r=nrc
Allow `use` macro imports to shadow global macros Terminology: - global scope: builtin macros, macros from the prelude, `#[macro_use]`, or `#![plugin(..)]`. - legacy scope: crate-local `macro_rules!`. - modern scope: `use` macro imports, `macro` (once implemented). Today, the legacy scope can shadow the global scope (modulo RFC 1560 expanded shadowing restrictions). However, the modern scope cannot shadow or be shadowed by either the global or legacy scopes, leading to ambiguity errors. This PR allows the modern scope to shadow the global scope (subject to some restrictions). More specifically, a name in the global scope is as shadowable as a glob import in the module `self`. In other words, we imagine a special, implicit glob import in each module item: ```rust mod foo { #[lexical_only] // Not accessible via `foo::<name>`, like pre-RFC 1560 `use` imports. #[shadowable_by_legacy_scope] // for back-compat use <global_macros>::*; } ``` r? @nrc
- Loading branch information
Showing
5 changed files
with
175 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.