diff --git a/gcc/testsuite/rust/compile/name_resolution10.rs b/gcc/testsuite/rust/compile/name_resolution10.rs new file mode 100644 index 00000000000..33643bd1a14 --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution10.rs @@ -0,0 +1,19 @@ +// { dg-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" } + +#![feature(decl_macro)] + +pub mod foo { + pub mod bar { + pub mod baz { + // macros 2.0 get inserted in Ribs like items + pub macro boof() {} + } + } +} + +#[macro_export] +fn main() { + foo::bar::baz::boof!(); + crate::foo::bar::baz::boof!(); + self::foo::bar::baz::boof!(); +} diff --git a/gcc/testsuite/rust/compile/name_resolution6.rs b/gcc/testsuite/rust/compile/name_resolution6.rs new file mode 100644 index 00000000000..e4087e6281c --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution6.rs @@ -0,0 +1,28 @@ +// { 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 + } + } + } +} diff --git a/gcc/testsuite/rust/compile/name_resolution8.rs b/gcc/testsuite/rust/compile/name_resolution8.rs new file mode 100644 index 00000000000..6fb51703382 --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution8.rs @@ -0,0 +1,26 @@ +// { 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 + } + } +}