Allow use
macro imports to shadow global macros by jseyfried · Pull Request #40501 · rust-lang/rust (original) (raw)
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation24 Commits2 Checks0 Files changed
Conversation
This file contains hidden or 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
[ Show hidden characters]({{ revealButtonHref }})
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:
mod foo {
#[lexical_only] // Not accessible via foo::<name>
, like pre-RFC 1560 use
imports.
#[shadowable_by_legacy_scope] // for back-compat
use ::*;
}
r? @nrc
jseyfried changed the title
Allow Allow use
macro imports to shadow built macorsuse
macro imports to shadow builtin macors
jseyfried changed the title
Allow Allow use
macro imports to shadow builtin macorsuse
macro imports to shadow builtin macros
I think the terminology could be improved - built-in suggests that it is part of the compiler, but only a small subset of macros are and they are (iirc) in the prelude too. If I understand correctly, the distinction is more between legacy-imported and legacy-local?
LGTM, I'd like to fix (or better understand) the naming issue, but r+ with that.
jseyfried changed the title
Allow Allow use
macro imports to shadow builtin macrosuse
macro imports to shadow global macros
Agreed -- I renamed "builtin scope" to "global scope".
@bors r=nrc
📌 Commit a0707df has been approved by nrc
bors added a commit that referenced this pull request
Rollup of 22 pull requests
- Successful merges: #40241, #40346, #40348, #40377, #40398, #40409, #40441, #40445, #40509, #40521, #40523, #40532, #40538, #40564, #40581, #40583, #40588, #40589, #40590, #40603, #40611, #40621
- Failed merges: #40501, #40541
☔ The latest upstream changes (presumably #40346) made this pull request unmergeable. Please resolve the merge conflicts.
📌 Commit d123e76 has been approved by nrc
frewsxcv added a commit to frewsxcv/rust that referenced this pull request
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:
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
bors added a commit that referenced this pull request
📌 Commit d64d381 has been approved by nrc
alexcrichton added a commit to alexcrichton/rust that referenced this pull request
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:
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
bors added a commit that referenced this pull request
Rollup of 11 pull requests
- Successful merges: #40347, #40501, #40516, #40524, #40540, #40642, #40683, #40764, #40778, #40807, #40809
- Failed merges: #40771
bors added a commit that referenced this pull request
Rollup of 11 pull requests
- Successful merges: #40347, #40501, #40516, #40524, #40540, #40642, #40683, #40764, #40778, #40807, #40809
- Failed merges: #40771
⌛ Testing commit d64d381 with merge 7022e44...
⌛ Testing commit d64d381 with merge 1a95c82...
⌛ Testing commit d64d381 with merge 20ae752...
⌛ Testing commit d64d381 with merge ae3186d...
bors added a commit that referenced this pull request
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:
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