-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Allow use macro imports to shadow global macros
#40501
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
cc #35896 |
use macro imports to shadow built macorsuse macro imports to shadow builtin macors
use macro imports to shadow builtin macorsuse macro imports to shadow builtin macros
82ce9da to
a19fde7
Compare
|
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. |
use macro imports to shadow builtin macrosuse macro imports to shadow global macros
|
Agreed -- I renamed "builtin scope" to "global scope". |
|
📌 Commit a0707df has been approved by |
|
☔ The latest upstream changes (presumably #40346) made this pull request unmergeable. Please resolve the merge conflicts. |
a0707df to
d123e76
Compare
|
@bors r=nrc |
|
📌 Commit d123e76 has been approved by |
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
|
🔒 Merge conflict |
d123e76 to
d64d381
Compare
|
@bors r=nrc |
|
📌 Commit d64d381 has been approved by |
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
|
⌛ Testing commit d64d381 with merge 7022e44... |
|
💔 Test failed - status-travis |
|
⌛ Testing commit d64d381 with merge 1a95c82... |
|
💔 Test failed - status-travis |
|
⌛ Testing commit d64d381 with merge 20ae752... |
|
💔 Test failed - status-travis |
|
⌛ Testing commit d64d381 with merge ae3186d... |
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
|
☀️ Test successful - status-appveyor, status-travis |
Terminology:
#[macro_use], or#![plugin(..)].macro_rules!.usemacro 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:r? @nrc