]> git.lizzy.rs Git - rust.git/commitdiff
Add test cases for possible restricted shadowing configurations
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Thu, 30 Aug 2018 01:56:55 +0000 (04:56 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 8 Sep 2018 11:15:11 +0000 (14:15 +0300)
Whitelist `#[rustc_transparent_macro]` so it's not interpreted as a potential attribute macro

src/libsyntax/feature_gate.rs
src/test/ui/macros/restricted-shadowing-legacy.rs [new file with mode: 0644]
src/test/ui/macros/restricted-shadowing-legacy.stderr [new file with mode: 0644]
src/test/ui/macros/restricted-shadowing-modern.rs [new file with mode: 0644]
src/test/ui/macros/restricted-shadowing-modern.stderr [new file with mode: 0644]

index e3ea3563d853bb6fc6e2b9bc85f1b56fdddaf852..cee6f3e261c4f0aa4ddac3e8887d1d84754a7643 100644 (file)
@@ -966,6 +966,10 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool {
                                      "the `#[rustc_test_marker]` attribute \
                                       is used internally to track tests",
                                      cfg_fn!(rustc_attrs))),
+    ("rustc_transparent_macro", Whitelisted, Gated(Stability::Unstable,
+                                                   "rustc_attrs",
+                                                   "used internally for testing macro hygiene",
+                                                    cfg_fn!(rustc_attrs))),
 
     // RFC #2094
     ("nll", Whitelisted, Gated(Stability::Unstable,
diff --git a/src/test/ui/macros/restricted-shadowing-legacy.rs b/src/test/ui/macros/restricted-shadowing-legacy.rs
new file mode 100644 (file)
index 0000000..7950dce
--- /dev/null
@@ -0,0 +1,281 @@
+// Legend:
+// `+` - 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)]
+
+macro_rules! include { () => {
+    macro_rules! gen_outer { () => {
+        macro_rules! m { () => {} }
+    }}
+    macro_rules! gen_inner { () => {
+        macro_rules! m { () => {} }
+    }}
+    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 { () => {} }
+
+        macro_rules! gen_inner_invoc { () => {
+            macro_rules! m { () => {} }
+            m!(); // OK
+        }}
+        gen_inner_invoc!();
+    }
+
+    fn check9() {
+        macro_rules! m { () => {} }
+
+        macro_rules! gen_inner_gen_invoc { () => {
+            macro_rules! m { () => {} }
+            gen_invoc!(); // OK
+        }}
+        gen_inner_gen_invoc!();
+    }
+
+    fn check10() {
+        macro_rules! m { () => {} }
+
+        macro_rules! m { () => {} }
+
+        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 { () => {} }
+
+        macro_rules! m { () => {} }
+
+        m!(); // OK
+    }
+
+    fn check36() {
+        gen_outer!();
+
+        gen_inner!();
+
+        m!(); //~ ERROR `m` is ambiguous
+    }
+
+    fn check39() {
+        gen_outer!();
+
+        macro_rules! m { () => {} }
+
+        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 { () => {} }
+            m!(); // OK
+        }}
+        gen_inner_invoc!();
+    }
+
+    fn check59() {
+        gen_outer!();
+
+        macro_rules! m { () => {} }
+
+        gen_invoc!(); // OK
+    }
+
+    fn check60() {
+        gen_outer!();
+
+        macro_rules! gen_inner_gen_invoc { () => {
+            macro_rules! m { () => {} }
+            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 { () => {} }
+            macro_rules! m { () => {} }
+        }}
+        gen_outer_inner!();
+
+        m!(); // OK
+    }
+
+    fn check35() {
+        macro_rules! gen_gen_outer_inner { () => {
+            gen_outer!();
+            macro_rules! m { () => {} }
+        }}
+        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 { () => {} }
+            macro_rules! m { () => {} }
+        }}
+        gen_outer_inner!();
+
+        gen_invoc!(); // OK
+    }
+
+    fn check63() {
+        macro_rules! gen_gen_outer_inner { () => {
+            gen_outer!();
+            macro_rules! m { () => {} }
+        }}
+        gen_gen_outer_inner!();
+
+        gen_invoc!(); // OK
+    }
+}}
+
+include!();
+
+fn main() {}
diff --git a/src/test/ui/macros/restricted-shadowing-legacy.stderr b/src/test/ui/macros/restricted-shadowing-legacy.stderr
new file mode 100644 (file)
index 0000000..cd06934
--- /dev/null
@@ -0,0 +1,195 @@
+error[E0659]: `m` is ambiguous
+  --> $DIR/restricted-shadowing-legacy.rs:93:13
+   |
+LL |             m!(); //~ ERROR `m` is ambiguous
+   |             ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:89: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:131:42
+   |
+LL |         macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
+   |                                          ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:127: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:140:9
+   |
+LL |         m!(); //~ ERROR `m` is ambiguous
+   |         ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:136: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:156:9
+   |
+LL |         m!(); //~ ERROR `m` is ambiguous
+   |         ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:77: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:172:13
+   |
+LL |             m!(); //~ ERROR `m` is ambiguous
+   |             ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:77: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:210:42
+   |
+LL |         macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
+   |                                          ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:77: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:224:9
+   |
+LL |         m!(); //~ ERROR `m` is ambiguous
+   |         ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:219: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:254:42
+   |
+LL |         macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
+   |                                          ^
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:80:9
+   |
+LL |         macro_rules! m { () => {} }
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-legacy.rs:249: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`.
diff --git a/src/test/ui/macros/restricted-shadowing-modern.rs b/src/test/ui/macros/restricted-shadowing-modern.rs
new file mode 100644 (file)
index 0000000..2052810
--- /dev/null
@@ -0,0 +1,235 @@
+// Legend:
+// `+` - 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)]
+
+#[rustc_transparent_macro]
+macro include() {
+    #[rustc_transparent_macro]
+    macro gen_outer() {
+        macro m() {}
+    }
+    #[rustc_transparent_macro]
+    macro gen_inner() {
+        macro m() {}
+    }
+    #[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() {}
+        {
+            #[rustc_transparent_macro]
+            macro gen_inner_invoc() {
+                macro m() {}
+                m!(); // OK
+            }
+            gen_inner_invoc!();
+        }
+    }
+
+    fn check9() {
+        macro m() {}
+        {
+            #[rustc_transparent_macro]
+            macro gen_inner_gen_invoc() {
+                macro m() {}
+                gen_invoc!(); // OK
+            }
+            gen_inner_gen_invoc!();
+        }
+    }
+
+    fn check10() {
+        macro m() {}
+        {
+            macro m() {}
+            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() {}
+        {
+            macro m() {}
+            m!(); // OK
+        }
+    }
+
+    fn check36() {
+        gen_outer!();
+        {
+            gen_inner!();
+            m!(); //~ ERROR `m` is ambiguous
+        }
+    }
+
+    fn check39() {
+        gen_outer!();
+        {
+            macro m() {}
+            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() {}
+                m!(); // OK
+            }
+            gen_inner_invoc!();
+        }
+    }
+
+    fn check59() {
+        gen_outer!();
+        {
+            macro m() {}
+            gen_invoc!(); // OK
+        }
+    }
+
+    fn check60() {
+        gen_outer!();
+        {
+            #[rustc_transparent_macro]
+            macro gen_inner_gen_invoc() {
+                macro m() {}
+                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() {}
diff --git a/src/test/ui/macros/restricted-shadowing-modern.stderr b/src/test/ui/macros/restricted-shadowing-modern.stderr
new file mode 100644 (file)
index 0000000..8d64c6c
--- /dev/null
@@ -0,0 +1,165 @@
+error[E0659]: `m` is ambiguous
+  --> $DIR/restricted-shadowing-modern.rs:98:17
+   |
+LL |                 m!(); //~ ERROR `m` is ambiguous
+   |                 ^
+...
+LL | include!();
+   | ----------- in this macro invocation
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:83:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:93: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:141:33
+   |
+LL |             macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
+   |                                 ^
+...
+LL | include!();
+   | ----------- in this macro invocation
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:83:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:137: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:150:13
+   |
+LL |             m!(); //~ ERROR `m` is ambiguous
+   |             ^
+...
+LL | include!();
+   | ----------- in this macro invocation
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:83:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:147: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:166:13
+   |
+LL |             m!(); //~ ERROR `m` is ambiguous
+   |             ^
+...
+LL | include!();
+   | ----------- in this macro invocation
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:83:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:79: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:184:17
+   |
+LL |                 m!(); //~ ERROR `m` is ambiguous
+   |                 ^
+...
+LL | include!();
+   | ----------- in this macro invocation
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:83:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:79: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:227:33
+   |
+LL |             macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
+   |                                 ^
+...
+LL | include!();
+   | ----------- in this macro invocation
+   |
+note: `m` could refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:83:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+LL | include!();
+   | ----------- in this macro invocation
+note: `m` could also refer to the name defined here
+  --> $DIR/restricted-shadowing-modern.rs:79:9
+   |
+LL |         macro m() {}
+   |         ^^^^^^^^^^^^
+...
+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`.