]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #40501 - jseyfried:shadow_builtin_macros, r=nrc
authorbors <bors@rust-lang.org>
Sun, 26 Mar 2017 11:45:13 +0000 (11:45 +0000)
committerbors <bors@rust-lang.org>
Sun, 26 Mar 2017 11:45:13 +0000 (11:45 +0000)
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


Trivial merge