gcc/testsuite/ChangeLog:
* rust/compile/name_resolution6.rs: New test.
* rust/compile/name_resolution7.rs: New test.
* rust/compile/name_resolution8.rs: New test.
* rust/compile/name_resolution9.rs: New test.
--- /dev/null
+// { dg-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
+
+pub mod foo {
+ pub mod bar {
+ pub mod baz {
+ pub mod qux {
+ #[macro_export]
+ macro_rules! foo {
+ (one) => {};
+ }
+
+ pub fn foo() {}
+ }
+ }
+
+ fn f() {
+ fn inner() {
+ macro_rules! foo {
+ (two) => {};
+ }
+
+ foo!(two); // ok, textual scope
+ crate::foo!(one); // ok, path res
+ super::super::foo!(one); // ok, path res
+ }
+ }
+ }
+}
--- /dev/null
+// { dg-options "-frust-name-resolution-2.0" }
+
+// check that macros by example do not get inserted in ribs like regular items
+pub mod foo {
+ pub mod bar {
+ pub mod baz {
+ pub mod qux {
+ macro_rules! foo {
+ (one) => {};
+ }
+ }
+ }
+ }
+}
+
+crate::foo::bar::baz::qux::foo!(); // { dg-error "could not resolve macro invocation" }
+foo::bar::baz::qux::foo!(); // { dg-error "could not resolve macro invocation" }
--- /dev/null
+// { dg-options "-frust-name-resolution-2.0" }
+
+// check that macros by example get exported to the crate's root with #[macro_export]
+pub mod foo {
+ pub mod bar {
+ pub mod baz {
+ pub mod qux {
+ #[macro_export]
+ macro_rules! foo {
+ (one) => {};
+ }
+ }
+ }
+ }
+}
+
+crate::foo!(one); // ok
+foo!(one); // ok
+
+mod a {
+ mod b {
+ mod c {
+ super::super::super::foo!(one); // ok
+ }
+ }
+}
--- /dev/null
+// { dg-options "-frust-name-resolution-2.0" }
+
+pub mod foo {
+ pub mod bar {
+ fn f() {
+ super::super::super::foo!(); // { dg-error "too many leading .super. keywords" }
+ // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 }
+
+ super::crate::foo!(); // { dg-error "leading path segment .crate. can only be used" }
+ // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 }
+
+
+ crate::foo::bar::super::foo!(); // { dg-error "leading path segment .super. can only be used" }
+ // { dg-error "could not resolve macro invocation" "" { target *-*-* } .-1 }
+ }
+ }
+}