Uh oh!
There was an error while loading. Please reload this page.
Allow use macro imports to shadow global macros - #40501
Conversation
use macro imports to shadow built macorsuse macro imports to shadow builtin macorsuse macro imports to shadow builtin macorsuse macro imports to shadow builtin macros82ce9da to
a19fde7Comparenrc
commented
Mar 15, 2017
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? |
nrc
commented
Mar 15, 2017
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 macrosjseyfried
commented
Mar 16, 2017
Agreed -- I renamed "builtin scope" to "global scope". |
bors
commented
Mar 16, 2017
📌 Commit a0707df has been approved by |
bors
commented
Mar 19, 2017
☔ The latest upstream changes (presumably #40346) made this pull request unmergeable. Please resolve the merge conflicts. |
a0707df to
d123e76Comparejseyfried
commented
Mar 24, 2017
@bors r=nrc |
bors
commented
Mar 24, 2017
📌 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? @nrcbors
commented
Mar 24, 2017
🔒 Merge conflict |
d123e76 to
d64d381Comparejseyfried
commented
Mar 24, 2017
@bors r=nrc |
bors
commented
Mar 24, 2017
📌 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? @nrcbors
commented
Mar 25, 2017
⌛ Testing commit d64d381 with merge 7022e44... |
bors
commented
Mar 25, 2017
💔 Test failed - status-travis |
arielb1
commented
Mar 25, 2017
bors
commented
Mar 25, 2017
⌛ Testing commit d64d381 with merge 1a95c82... |
bors
commented
Mar 25, 2017
💔 Test failed - status-travis |
arielb1
commented
Mar 25, 2017
bors
commented
Mar 25, 2017
⌛ Testing commit d64d381 with merge 20ae752... |
bors
commented
Mar 25, 2017
💔 Test failed - status-travis |
arielb1
commented
Mar 25, 2017
bors
commented
Mar 26, 2017
⌛ Testing commit d64d381 with merge ae3186d... |
arielb1
commented
Mar 26, 2017
bors
commented
Mar 26, 2017
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? @nrcbors
commented
Mar 26, 2017
☀️ 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