Auto merge of #53778 - petrochenkov:shadrelax2, r=nikomatsakis
resolve: Relax shadowing restrictions on macro-expanded macros Previously any macro-expanded macros weren't allowed to shadow macros from outer scopes. Now only "more macro-expanded" macros cannot shadow "less macro-expanded" macros. See comments to `fn may_appear_after` and added tests for more details and examples. The functional changes are a21f6f588fc28c97533130ae44a6957b579ab58c and 46dd365ce9ca0a6b8653849b80267763c542842a, other commits are refactorings.
This commit is contained in:
commit
2d4e34ca8b
27 changed files with 1233 additions and 248 deletions
|
|
@ -1,8 +1,8 @@
|
|||
error[E0659]: `foo` is ambiguous
|
||||
--> $DIR/E0659.rs:25:5
|
||||
--> $DIR/E0659.rs:25:15
|
||||
|
|
||||
LL | collider::foo(); //~ ERROR E0659
|
||||
| ^^^^^^^^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `foo` could refer to the name imported here
|
||||
--> $DIR/E0659.rs:20:13
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ LL | use a::foo as other_foo; //~ ERROR the name `foo` is defined multiple t
|
|||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0659]: `foo` is ambiguous
|
||||
--> $DIR/duplicate.rs:56:9
|
||||
--> $DIR/duplicate.rs:56:15
|
||||
|
|
||||
LL | use self::foo::bar; //~ ERROR `foo` is ambiguous
|
||||
| ^^^^^^^^^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `foo` could refer to the name imported here
|
||||
--> $DIR/duplicate.rs:53:9
|
||||
|
|
@ -31,10 +31,10 @@ LL | use self::m2::*;
|
|||
= note: consider adding an explicit import of `foo` to disambiguate
|
||||
|
||||
error[E0659]: `foo` is ambiguous
|
||||
--> $DIR/duplicate.rs:45:5
|
||||
--> $DIR/duplicate.rs:45:8
|
||||
|
|
||||
LL | f::foo(); //~ ERROR `foo` is ambiguous
|
||||
| ^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `foo` could refer to the name imported here
|
||||
--> $DIR/duplicate.rs:34:13
|
||||
|
|
@ -49,10 +49,10 @@ LL | pub use b::*;
|
|||
= note: consider adding an explicit import of `foo` to disambiguate
|
||||
|
||||
error[E0659]: `foo` is ambiguous
|
||||
--> $DIR/duplicate.rs:46:5
|
||||
--> $DIR/duplicate.rs:46:8
|
||||
|
|
||||
LL | g::foo(); //~ ERROR `foo` is ambiguous
|
||||
| ^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `foo` could refer to the name imported here
|
||||
--> $DIR/duplicate.rs:39:13
|
||||
|
|
@ -70,7 +70,7 @@ error[E0659]: `foo` is ambiguous
|
|||
--> $DIR/duplicate.rs:59:9
|
||||
|
|
||||
LL | foo::bar(); //~ ERROR `foo` is ambiguous
|
||||
| ^^^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `foo` could refer to the name imported here
|
||||
--> $DIR/duplicate.rs:53:9
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `env` is ambiguous
|
|||
--> $DIR/glob-shadowing.rs:21:17
|
||||
|
|
||||
LL | let x = env!("PATH"); //~ ERROR `env` is ambiguous
|
||||
| ^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `env` could refer to the name imported here
|
||||
--> $DIR/glob-shadowing.rs:19:9
|
||||
|
|
@ -16,7 +16,7 @@ error[E0659]: `env` is ambiguous
|
|||
--> $DIR/glob-shadowing.rs:29:21
|
||||
|
|
||||
LL | let x = env!("PATH"); //~ ERROR `env` is ambiguous
|
||||
| ^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `env` could refer to the name imported here
|
||||
--> $DIR/glob-shadowing.rs:27:13
|
||||
|
|
@ -30,7 +30,7 @@ error[E0659]: `fenv` is ambiguous
|
|||
--> $DIR/glob-shadowing.rs:39:21
|
||||
|
|
||||
LL | let x = fenv!(); //~ ERROR `fenv` is ambiguous
|
||||
| ^^^^
|
||||
| ^^^^ ambiguous name
|
||||
|
|
||||
note: `fenv` could refer to the name imported here
|
||||
--> $DIR/glob-shadowing.rs:37:13
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ error[E0659]: `mac` is ambiguous
|
|||
--> $DIR/issue-53269.rs:18:5
|
||||
|
|
||||
LL | mac!(); //~ ERROR `mac` is ambiguous
|
||||
| ^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `mac` could refer to the name defined here
|
||||
--> $DIR/issue-53269.rs:13:1
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ mod inner2 {
|
|||
|
||||
fn main() {
|
||||
panic!(); //~ ERROR `panic` is ambiguous
|
||||
//~^ ERROR `panic` is ambiguous
|
||||
}
|
||||
|
||||
mod inner3 {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `exported` is ambiguous
|
|||
--> $DIR/local-modularized-tricky-fail-1.rs:38:1
|
||||
|
|
||||
LL | exported!(); //~ ERROR `exported` is ambiguous
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ ambiguous name
|
||||
|
|
||||
note: `exported` could refer to the name defined here
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:15:5
|
||||
|
|
@ -22,10 +22,10 @@ LL | use inner1::*;
|
|||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `include` is ambiguous
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:57:1
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:56:1
|
||||
|
|
||||
LL | include!(); //~ ERROR `include` is ambiguous
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ ambiguous name
|
||||
|
|
||||
note: `include` could refer to the name defined here
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:27:5
|
||||
|
|
@ -44,7 +44,7 @@ error[E0659]: `panic` is ambiguous
|
|||
--> $DIR/local-modularized-tricky-fail-1.rs:45:5
|
||||
|
|
||||
LL | panic!(); //~ ERROR `panic` is ambiguous
|
||||
| ^^^^^
|
||||
| ^^^^^ ambiguous name
|
||||
|
|
||||
note: `panic` could refer to the name defined here
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:21:5
|
||||
|
|
@ -60,10 +60,10 @@ LL | define_panic!();
|
|||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `panic` is ambiguous
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:45:5
|
||||
--> <panic macros>:1:13
|
||||
|
|
||||
LL | panic!(); //~ ERROR `panic` is ambiguous
|
||||
| ^^^^^^^^^
|
||||
LL | ( ) => ( { panic ! ( "explicit panic" ) } ) ; ( $ msg : expr ) => (
|
||||
| ^^^^^ ambiguous name
|
||||
|
|
||||
note: `panic` could refer to the name defined here
|
||||
--> $DIR/local-modularized-tricky-fail-1.rs:21:5
|
||||
|
|
@ -77,7 +77,6 @@ LL | define_panic!();
|
|||
| ---------------- in this macro invocation
|
||||
= note: `panic` is also a builtin macro
|
||||
= note: macro-expanded macros do not shadow
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `bar` is ambiguous
|
|||
--> $DIR/macro-paths.rs:23:5
|
||||
|
|
||||
LL | bar::m! { //~ ERROR ambiguous
|
||||
| ^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `bar` could refer to the name defined here
|
||||
--> $DIR/macro-paths.rs:24:9
|
||||
|
|
@ -20,7 +20,7 @@ error[E0659]: `baz` is ambiguous
|
|||
--> $DIR/macro-paths.rs:33:5
|
||||
|
|
||||
LL | baz::m! { //~ ERROR ambiguous
|
||||
| ^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `baz` could refer to the name defined here
|
||||
--> $DIR/macro-paths.rs:34:9
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `m` is ambiguous
|
|||
--> $DIR/macros.rs:48:5
|
||||
|
|
||||
LL | m!(); //~ ERROR ambiguous
|
||||
| ^
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/macros.rs:46:5
|
||||
|
|
@ -19,7 +19,7 @@ error[E0659]: `m` is ambiguous
|
|||
--> $DIR/macros.rs:26:5
|
||||
|
|
||||
LL | m! { //~ ERROR ambiguous
|
||||
| ^
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name imported here
|
||||
--> $DIR/macros.rs:27:13
|
||||
|
|
@ -37,7 +37,7 @@ error[E0659]: `m` is ambiguous
|
|||
--> $DIR/macros.rs:39:9
|
||||
|
|
||||
LL | m! { //~ ERROR ambiguous
|
||||
| ^
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name imported here
|
||||
--> $DIR/macros.rs:40:17
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `Foo` is ambiguous
|
|||
--> $DIR/rfc-1560-warning-cycle.rs:19:17
|
||||
|
|
||||
LL | fn f(_: Foo) {} //~ ERROR `Foo` is ambiguous
|
||||
| ^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `Foo` could refer to the name imported here
|
||||
--> $DIR/rfc-1560-warning-cycle.rs:17:13
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `panic` is ambiguous
|
|||
--> $DIR/shadow_builtin_macros.rs:43:5
|
||||
|
|
||||
LL | panic!(); //~ ERROR `panic` is ambiguous
|
||||
| ^^^^^
|
||||
| ^^^^^ ambiguous name
|
||||
|
|
||||
note: `panic` could refer to the name defined here
|
||||
--> $DIR/shadow_builtin_macros.rs:40:9
|
||||
|
|
@ -19,7 +19,7 @@ error[E0659]: `panic` is ambiguous
|
|||
--> $DIR/shadow_builtin_macros.rs:25:14
|
||||
|
|
||||
LL | fn f() { panic!(); } //~ ERROR ambiguous
|
||||
| ^^^^^
|
||||
| ^^^^^ ambiguous name
|
||||
|
|
||||
note: `panic` could refer to the name imported here
|
||||
--> $DIR/shadow_builtin_macros.rs:24:9
|
||||
|
|
@ -33,7 +33,7 @@ error[E0659]: `panic` is ambiguous
|
|||
--> $DIR/shadow_builtin_macros.rs:30:14
|
||||
|
|
||||
LL | fn f() { panic!(); } //~ ERROR ambiguous
|
||||
| ^^^^^
|
||||
| ^^^^^ ambiguous name
|
||||
|
|
||||
note: `panic` could refer to the name imported here
|
||||
--> $DIR/shadow_builtin_macros.rs:29:26
|
||||
|
|
@ -47,7 +47,7 @@ error[E0659]: `n` is ambiguous
|
|||
--> $DIR/shadow_builtin_macros.rs:59:5
|
||||
|
|
||||
LL | n!(); //~ ERROR ambiguous
|
||||
| ^
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `n` could refer to the name imported here
|
||||
--> $DIR/shadow_builtin_macros.rs:58:9
|
||||
|
|
|
|||
|
|
@ -17,3 +17,8 @@ macro_rules! mac {
|
|||
macro_rules! inline {
|
||||
() => ()
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! from_prelude {
|
||||
() => ()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ error[E0659]: `std` is ambiguous
|
|||
--> $DIR/macro-path-prelude-shadowing.rs:39:9
|
||||
|
|
||||
LL | std::panic!(); //~ ERROR `std` is ambiguous
|
||||
| ^^^^^^^^^^
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `std` could refer to the name imported here
|
||||
--> $DIR/macro-path-prelude-shadowing.rs:37:9
|
||||
|
|
|
|||
35
src/test/ui/macros/macro-shadowing-relaxed.rs
Normal file
35
src/test/ui/macros/macro-shadowing-relaxed.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-pass
|
||||
// aux-build:macro-in-other-crate.rs
|
||||
|
||||
#![feature(decl_macro)]
|
||||
|
||||
macro_rules! my_include {() => {
|
||||
// Outer
|
||||
macro m() {}
|
||||
#[macro_use(from_prelude)] extern crate macro_in_other_crate;
|
||||
|
||||
fn inner() {
|
||||
// Inner
|
||||
macro m() {}
|
||||
macro_rules! from_prelude { () => {} }
|
||||
|
||||
// OK, both `m` and `from_prelude` are macro-expanded,
|
||||
// but no more macro-expanded than their counterpart from outer scope.
|
||||
m!();
|
||||
from_prelude!();
|
||||
}
|
||||
}}
|
||||
|
||||
my_include!();
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -17,14 +17,14 @@ macro_rules! macro_one { () => {} }
|
|||
#[macro_use(macro_two)] extern crate two_macros;
|
||||
|
||||
macro_rules! m1 { () => {
|
||||
macro_rules! foo { () => {} } //~ ERROR `foo` is already in scope
|
||||
macro_rules! foo { () => {} }
|
||||
|
||||
#[macro_use] //~ ERROR `macro_two` is already in scope
|
||||
extern crate two_macros as __;
|
||||
}}
|
||||
m1!();
|
||||
|
||||
foo!();
|
||||
foo!(); //~ ERROR `foo` is ambiguous
|
||||
|
||||
macro_rules! m2 { () => {
|
||||
macro_rules! foo { () => {} }
|
||||
|
|
|
|||
|
|
@ -9,16 +9,27 @@ LL | m1!();
|
|||
|
|
||||
= note: macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)
|
||||
|
||||
error: `foo` is already in scope
|
||||
error[E0659]: `foo` is ambiguous
|
||||
--> $DIR/macro-shadowing.rs:27:1
|
||||
|
|
||||
LL | foo!(); //~ ERROR `foo` is ambiguous
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `foo` could refer to the name defined here
|
||||
--> $DIR/macro-shadowing.rs:20:5
|
||||
|
|
||||
LL | macro_rules! foo { () => {} } //~ ERROR `foo` is already in scope
|
||||
LL | macro_rules! foo { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | m1!();
|
||||
| ------ in this macro invocation
|
||||
note: `foo` could also refer to the name defined here
|
||||
--> $DIR/macro-shadowing.rs:15:1
|
||||
|
|
||||
= note: macro-expanded `macro_rules!`s may not shadow existing macros (see RFC 1560)
|
||||
LL | macro_rules! foo { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
|
|||
289
src/test/ui/macros/restricted-shadowing-legacy.rs
Normal file
289
src/test/ui/macros/restricted-shadowing-legacy.rs
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
// Legend:
|
||||
// `N` - number of combination, from 0 to 4*4*4=64
|
||||
// `Outer < Invoc` means that expansion that produced macro definition `Outer`
|
||||
// is a strict ancestor of expansion that produced macro definition `Inner`.
|
||||
// `>`, `=` and `Unordered` mean "strict descendant", "same" and
|
||||
// "not in ordering relation" for parent expansions.
|
||||
// `+` - possible configuration
|
||||
// `-` - configuration impossible due to properties of partial ordering
|
||||
// `-?` - configuration impossible due to block/scope syntax
|
||||
// `+?` - configuration possible only with legacy scoping
|
||||
|
||||
// N | Outer ~ Invoc | Invoc ~ Inner | Outer ~ Inner | Possible |
|
||||
// 1 | < | < | < | + |
|
||||
// 2 | < | < | = | - |
|
||||
// 3 | < | < | > | - |
|
||||
// 4 | < | < | Unordered | - |
|
||||
// 5 | < | = | < | + |
|
||||
// 6 | < | = | = | - |
|
||||
// 7 | < | = | > | - |
|
||||
// 8 | < | = | Unordered | - |
|
||||
// 9 | < | > | < | + |
|
||||
// 10 | < | > | = | + |
|
||||
// 11 | < | > | > | -? |
|
||||
// 12 | < | > | Unordered | -? |
|
||||
// 13 | < | Unordered | < | + |
|
||||
// 14 | < | Unordered | = | - |
|
||||
// 15 | < | Unordered | > | - |
|
||||
// 16 | < | Unordered | Unordered | -? |
|
||||
// 17 | = | < | < | + |
|
||||
// 18 | = | < | = | - |
|
||||
// 19 | = | < | > | - |
|
||||
// 20 | = | < | Unordered | - |
|
||||
// 21 | = | = | < | - |
|
||||
// 22 | = | = | = | + |
|
||||
// 23 | = | = | > | - |
|
||||
// 24 | = | = | Unordered | - |
|
||||
// 25 | = | > | < | - |
|
||||
// 26 | = | > | = | - |
|
||||
// 27 | = | > | > | -? |
|
||||
// 28 | = | > | Unordered | - |
|
||||
// 29 | = | Unordered | < | - |
|
||||
// 30 | = | Unordered | = | - |
|
||||
// 31 | = | Unordered | > | - |
|
||||
// 32 | = | Unordered | Unordered | -? |
|
||||
// 33 | > | < | < | +? |
|
||||
// 34 | > | < | = | +? |
|
||||
// 35 | > | < | > | +? |
|
||||
// 36 | > | < | Unordered | + |
|
||||
// 37 | > | = | < | - |
|
||||
// 38 | > | = | = | - |
|
||||
// 39 | > | = | > | + |
|
||||
// 40 | > | = | Unordered | - |
|
||||
// 41 | > | > | < | - |
|
||||
// 42 | > | > | = | - |
|
||||
// 43 | > | > | > | -? |
|
||||
// 44 | > | > | Unordered | - |
|
||||
// 45 | > | Unordered | < | - |
|
||||
// 46 | > | Unordered | = | - |
|
||||
// 47 | > | Unordered | > | -? |
|
||||
// 48 | > | Unordered | Unordered | -? |
|
||||
// 49 | Unordered | < | < | -? |
|
||||
// 50 | Unordered | < | = | - |
|
||||
// 51 | Unordered | < | > | - |
|
||||
// 52 | Unordered | < | Unordered | + |
|
||||
// 53 | Unordered | = | < | - |
|
||||
// 54 | Unordered | = | = | - |
|
||||
// 55 | Unordered | = | > | - |
|
||||
// 56 | Unordered | = | Unordered | + |
|
||||
// 57 | Unordered | > | < | - |
|
||||
// 58 | Unordered | > | = | - |
|
||||
// 59 | Unordered | > | > | + |
|
||||
// 60 | Unordered | > | Unordered | + |
|
||||
// 61 | Unordered | Unordered | < | +? |
|
||||
// 62 | Unordered | Unordered | = | +? |
|
||||
// 63 | Unordered | Unordered | > | +? |
|
||||
// 64 | Unordered | Unordered | Unordered | + |
|
||||
|
||||
#![feature(decl_macro, rustc_attrs)]
|
||||
|
||||
struct Right;
|
||||
// struct Wrong; // not defined
|
||||
|
||||
macro_rules! include { () => {
|
||||
macro_rules! gen_outer { () => {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
}}
|
||||
macro_rules! gen_inner { () => {
|
||||
macro_rules! m { () => { Right } }
|
||||
}}
|
||||
macro_rules! gen_invoc { () => {
|
||||
m!()
|
||||
}}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
fn check1() {
|
||||
macro_rules! m { () => {} }
|
||||
|
||||
macro_rules! gen_gen_inner_invoc { () => {
|
||||
gen_inner!();
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}}
|
||||
gen_gen_inner_invoc!();
|
||||
}
|
||||
|
||||
fn check5() {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
|
||||
macro_rules! gen_inner_invoc { () => {
|
||||
macro_rules! m { () => { Right } }
|
||||
m!(); // OK
|
||||
}}
|
||||
gen_inner_invoc!();
|
||||
}
|
||||
|
||||
fn check9() {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
|
||||
macro_rules! gen_inner_gen_invoc { () => {
|
||||
macro_rules! m { () => { Right } }
|
||||
gen_invoc!(); // OK
|
||||
}}
|
||||
gen_inner_gen_invoc!();
|
||||
}
|
||||
|
||||
fn check10() {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
|
||||
macro_rules! m { () => { Right } }
|
||||
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
|
||||
fn check13() {
|
||||
macro_rules! m { () => {} }
|
||||
|
||||
gen_inner!();
|
||||
|
||||
macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
|
||||
gen_invoc!();
|
||||
}
|
||||
|
||||
fn check17() {
|
||||
macro_rules! m { () => {} }
|
||||
|
||||
gen_inner!();
|
||||
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
|
||||
fn check22() {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
|
||||
macro_rules! m { () => { Right } }
|
||||
|
||||
m!(); // OK
|
||||
}
|
||||
|
||||
fn check36() {
|
||||
gen_outer!();
|
||||
|
||||
gen_inner!();
|
||||
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
|
||||
fn check39() {
|
||||
gen_outer!();
|
||||
|
||||
macro_rules! m { () => { Right } }
|
||||
|
||||
m!(); // OK
|
||||
}
|
||||
|
||||
fn check52() {
|
||||
gen_outer!();
|
||||
|
||||
macro_rules! gen_gen_inner_invoc { () => {
|
||||
gen_inner!();
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}}
|
||||
gen_gen_inner_invoc!();
|
||||
}
|
||||
|
||||
fn check56() {
|
||||
gen_outer!();
|
||||
|
||||
macro_rules! gen_inner_invoc { () => {
|
||||
macro_rules! m { () => { Right } }
|
||||
m!(); // OK
|
||||
}}
|
||||
gen_inner_invoc!();
|
||||
}
|
||||
|
||||
fn check59() {
|
||||
gen_outer!();
|
||||
|
||||
macro_rules! m { () => { Right } }
|
||||
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
|
||||
fn check60() {
|
||||
gen_outer!();
|
||||
|
||||
macro_rules! gen_inner_gen_invoc { () => {
|
||||
macro_rules! m { () => { Right } }
|
||||
gen_invoc!(); // OK
|
||||
}}
|
||||
gen_inner_gen_invoc!();
|
||||
}
|
||||
|
||||
fn check64() {
|
||||
gen_outer!();
|
||||
|
||||
gen_inner!();
|
||||
|
||||
macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
|
||||
gen_invoc!();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// These configurations are only possible with legacy macro scoping
|
||||
|
||||
fn check33() {
|
||||
macro_rules! gen_outer_gen_inner { () => {
|
||||
macro_rules! m { () => {} }
|
||||
gen_inner!();
|
||||
}}
|
||||
gen_outer_gen_inner!();
|
||||
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
|
||||
fn check34() {
|
||||
macro_rules! gen_outer_inner { () => {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
macro_rules! m { () => { Right } }
|
||||
}}
|
||||
gen_outer_inner!();
|
||||
|
||||
m!(); // OK
|
||||
}
|
||||
|
||||
fn check35() {
|
||||
macro_rules! gen_gen_outer_inner { () => {
|
||||
gen_outer!();
|
||||
macro_rules! m { () => { Right } }
|
||||
}}
|
||||
gen_gen_outer_inner!();
|
||||
|
||||
m!(); // OK
|
||||
}
|
||||
|
||||
fn check61() {
|
||||
macro_rules! gen_outer_gen_inner { () => {
|
||||
macro_rules! m { () => {} }
|
||||
gen_inner!();
|
||||
}}
|
||||
gen_outer_gen_inner!();
|
||||
|
||||
macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
|
||||
gen_invoc!();
|
||||
}
|
||||
|
||||
fn check62() {
|
||||
macro_rules! gen_outer_inner { () => {
|
||||
macro_rules! m { () => { Wrong } }
|
||||
macro_rules! m { () => { Right } }
|
||||
}}
|
||||
gen_outer_inner!();
|
||||
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
|
||||
fn check63() {
|
||||
macro_rules! gen_gen_outer_inner { () => {
|
||||
gen_outer!();
|
||||
macro_rules! m { () => { Right } }
|
||||
}}
|
||||
gen_gen_outer_inner!();
|
||||
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
}}
|
||||
|
||||
include!();
|
||||
|
||||
fn main() {}
|
||||
195
src/test/ui/macros/restricted-shadowing-legacy.stderr
Normal file
195
src/test/ui/macros/restricted-shadowing-legacy.stderr
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:101:13
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:97:9
|
||||
|
|
||||
LL | macro_rules! m { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:139:42
|
||||
|
|
||||
LL | macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:135:9
|
||||
|
|
||||
LL | macro_rules! m { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:148:9
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:144:9
|
||||
|
|
||||
LL | macro_rules! m { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:164:9
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:85:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Wrong } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:180:13
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:85:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Wrong } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:218:42
|
||||
|
|
||||
LL | macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:85:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Wrong } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:232:9
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:227:13
|
||||
|
|
||||
LL | macro_rules! m { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-legacy.rs:262:42
|
||||
|
|
||||
LL | macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:88:9
|
||||
|
|
||||
LL | macro_rules! m { () => { Right } }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-legacy.rs:257:13
|
||||
|
|
||||
LL | macro_rules! m { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
243
src/test/ui/macros/restricted-shadowing-modern.rs
Normal file
243
src/test/ui/macros/restricted-shadowing-modern.rs
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
// Legend:
|
||||
// `N` - number of combination, from 0 to 4*4*4=64
|
||||
// `Outer < Invoc` means that expansion that produced macro definition `Outer`
|
||||
// is a strict ancestor of expansion that produced macro definition `Inner`.
|
||||
// `>`, `=` and `Unordered` mean "strict descendant", "same" and
|
||||
// "not in ordering relation" for parent expansions.
|
||||
// `+` - possible configuration
|
||||
// `-` - configuration impossible due to properties of partial ordering
|
||||
// `-?` - configuration impossible due to block/scope syntax
|
||||
// `+?` - configuration possible only with legacy scoping
|
||||
|
||||
// N | Outer ~ Invoc | Invoc ~ Inner | Outer ~ Inner | Possible |
|
||||
// 1 | < | < | < | + |
|
||||
// 2 | < | < | = | - |
|
||||
// 3 | < | < | > | - |
|
||||
// 4 | < | < | Unordered | - |
|
||||
// 5 | < | = | < | + |
|
||||
// 6 | < | = | = | - |
|
||||
// 7 | < | = | > | - |
|
||||
// 8 | < | = | Unordered | - |
|
||||
// 9 | < | > | < | + |
|
||||
// 10 | < | > | = | + |
|
||||
// 11 | < | > | > | -? |
|
||||
// 12 | < | > | Unordered | -? |
|
||||
// 13 | < | Unordered | < | + |
|
||||
// 14 | < | Unordered | = | - |
|
||||
// 15 | < | Unordered | > | - |
|
||||
// 16 | < | Unordered | Unordered | -? |
|
||||
// 17 | = | < | < | + |
|
||||
// 18 | = | < | = | - |
|
||||
// 19 | = | < | > | - |
|
||||
// 20 | = | < | Unordered | - |
|
||||
// 21 | = | = | < | - |
|
||||
// 22 | = | = | = | + |
|
||||
// 23 | = | = | > | - |
|
||||
// 24 | = | = | Unordered | - |
|
||||
// 25 | = | > | < | - |
|
||||
// 26 | = | > | = | - |
|
||||
// 27 | = | > | > | -? |
|
||||
// 28 | = | > | Unordered | - |
|
||||
// 29 | = | Unordered | < | - |
|
||||
// 30 | = | Unordered | = | - |
|
||||
// 31 | = | Unordered | > | - |
|
||||
// 32 | = | Unordered | Unordered | -? |
|
||||
// 33 | > | < | < | -? |
|
||||
// 34 | > | < | = | -? |
|
||||
// 35 | > | < | > | -? |
|
||||
// 36 | > | < | Unordered | + |
|
||||
// 37 | > | = | < | - |
|
||||
// 38 | > | = | = | - |
|
||||
// 39 | > | = | > | + |
|
||||
// 40 | > | = | Unordered | - |
|
||||
// 41 | > | > | < | - |
|
||||
// 42 | > | > | = | - |
|
||||
// 43 | > | > | > | -? |
|
||||
// 44 | > | > | Unordered | - |
|
||||
// 45 | > | Unordered | < | - |
|
||||
// 46 | > | Unordered | = | - |
|
||||
// 47 | > | Unordered | > | -? |
|
||||
// 48 | > | Unordered | Unordered | -? |
|
||||
// 49 | Unordered | < | < | -? |
|
||||
// 50 | Unordered | < | = | - |
|
||||
// 51 | Unordered | < | > | - |
|
||||
// 52 | Unordered | < | Unordered | + |
|
||||
// 53 | Unordered | = | < | - |
|
||||
// 54 | Unordered | = | = | - |
|
||||
// 55 | Unordered | = | > | - |
|
||||
// 56 | Unordered | = | Unordered | + |
|
||||
// 57 | Unordered | > | < | - |
|
||||
// 58 | Unordered | > | = | - |
|
||||
// 59 | Unordered | > | > | + |
|
||||
// 60 | Unordered | > | Unordered | + |
|
||||
// 61 | Unordered | Unordered | < | -? |
|
||||
// 62 | Unordered | Unordered | = | -? |
|
||||
// 63 | Unordered | Unordered | > | -? |
|
||||
// 64 | Unordered | Unordered | Unordered | + |
|
||||
|
||||
#![feature(decl_macro, rustc_attrs)]
|
||||
|
||||
struct Right;
|
||||
// struct Wrong; // not defined
|
||||
|
||||
#[rustc_transparent_macro]
|
||||
macro include() {
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_outer() {
|
||||
macro m() { Wrong }
|
||||
}
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_inner() {
|
||||
macro m() { Right }
|
||||
}
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_invoc() {
|
||||
m!()
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
fn check1() {
|
||||
macro m() {}
|
||||
{
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_gen_inner_invoc() {
|
||||
gen_inner!();
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
gen_gen_inner_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check5() {
|
||||
macro m() { Wrong }
|
||||
{
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_inner_invoc() {
|
||||
macro m() { Right }
|
||||
m!(); // OK
|
||||
}
|
||||
gen_inner_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check9() {
|
||||
macro m() { Wrong }
|
||||
{
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_inner_gen_invoc() {
|
||||
macro m() { Right }
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
gen_inner_gen_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check10() {
|
||||
macro m() { Wrong }
|
||||
{
|
||||
macro m() { Right }
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
fn check13() {
|
||||
macro m() {}
|
||||
{
|
||||
gen_inner!();
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
|
||||
gen_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check17() {
|
||||
macro m() {}
|
||||
{
|
||||
gen_inner!();
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
}
|
||||
|
||||
fn check22() {
|
||||
macro m() { Wrong }
|
||||
{
|
||||
macro m() { Right }
|
||||
m!(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
fn check36() {
|
||||
gen_outer!();
|
||||
{
|
||||
gen_inner!();
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
}
|
||||
|
||||
fn check39() {
|
||||
gen_outer!();
|
||||
{
|
||||
macro m() { Right }
|
||||
m!(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
fn check52() {
|
||||
gen_outer!();
|
||||
{
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_gen_inner_invoc() {
|
||||
gen_inner!();
|
||||
m!(); //~ ERROR `m` is ambiguous
|
||||
}
|
||||
gen_gen_inner_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check56() {
|
||||
gen_outer!();
|
||||
{
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_inner_invoc() {
|
||||
macro m() { Right }
|
||||
m!(); // OK
|
||||
}
|
||||
gen_inner_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check59() {
|
||||
gen_outer!();
|
||||
{
|
||||
macro m() { Right }
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
fn check60() {
|
||||
gen_outer!();
|
||||
{
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_inner_gen_invoc() {
|
||||
macro m() { Right }
|
||||
gen_invoc!(); // OK
|
||||
}
|
||||
gen_inner_gen_invoc!();
|
||||
}
|
||||
}
|
||||
|
||||
fn check64() {
|
||||
gen_outer!();
|
||||
{
|
||||
gen_inner!();
|
||||
#[rustc_transparent_macro]
|
||||
macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
|
||||
gen_invoc!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
include!();
|
||||
|
||||
fn main() {}
|
||||
147
src/test/ui/macros/restricted-shadowing-modern.stderr
Normal file
147
src/test/ui/macros/restricted-shadowing-modern.stderr
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-modern.rs:106:17
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:91:9
|
||||
|
|
||||
LL | macro m() { Right }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:101:9
|
||||
|
|
||||
LL | macro m() {}
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-modern.rs:149:33
|
||||
|
|
||||
LL | macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:91:9
|
||||
|
|
||||
LL | macro m() { Right }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:145:9
|
||||
|
|
||||
LL | macro m() {}
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-modern.rs:158:13
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:91:9
|
||||
|
|
||||
LL | macro m() { Right }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:155:9
|
||||
|
|
||||
LL | macro m() {}
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-modern.rs:174:13
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:91:9
|
||||
|
|
||||
LL | macro m() { Right }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:87:9
|
||||
|
|
||||
LL | macro m() { Wrong }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-modern.rs:192:17
|
||||
|
|
||||
LL | m!(); //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:91:9
|
||||
|
|
||||
LL | macro m() { Right }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:87:9
|
||||
|
|
||||
LL | macro m() { Wrong }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error[E0659]: `m` is ambiguous
|
||||
--> $DIR/restricted-shadowing-modern.rs:235:33
|
||||
|
|
||||
LL | macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
|
||||
| ^ ambiguous name
|
||||
|
|
||||
note: `m` could refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:91:9
|
||||
|
|
||||
LL | macro m() { Right }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
note: `m` could also refer to the name defined here
|
||||
--> $DIR/restricted-shadowing-modern.rs:87:9
|
||||
|
|
||||
LL | macro m() { Wrong }
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
...
|
||||
LL | include!();
|
||||
| ----------- in this macro invocation
|
||||
= note: macro-expanded macros do not shadow
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
@ -9,11 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
// aux-build:define_macro.rs
|
||||
// error-pattern: `bar` is already in scope
|
||||
|
||||
macro_rules! bar { () => {} }
|
||||
define_macro!(bar);
|
||||
bar!();
|
||||
bar!(); //~ ERROR `bar` is ambiguous
|
||||
|
||||
macro_rules! m { () => { #[macro_use] extern crate define_macro; } }
|
||||
m!();
|
||||
|
|
|
|||
|
|
@ -1,11 +1,22 @@
|
|||
error: `bar` is already in scope
|
||||
error[E0659]: `bar` is ambiguous
|
||||
--> $DIR/out-of-order-shadowing.rs:15:1
|
||||
|
|
||||
LL | bar!(); //~ ERROR `bar` is ambiguous
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
note: `bar` could refer to the name defined here
|
||||
--> $DIR/out-of-order-shadowing.rs:14:1
|
||||
|
|
||||
LL | define_macro!(bar);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
note: `bar` could also refer to the name defined here
|
||||
--> $DIR/out-of-order-shadowing.rs:13:1
|
||||
|
|
||||
= note: macro-expanded `macro_rules!`s may not shadow existing macros (see RFC 1560)
|
||||
LL | macro_rules! bar { () => {} }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: macro-expanded macros do not shadow
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue