Skip to content

Commit

Permalink
tests: Re-add macro nr2.0 test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Nov 15, 2023
1 parent a79665e commit bf97c5e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution10.rs
Original file line number Diff line number Diff line change
@@ -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!();
}
28 changes: 28 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution6.rs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
26 changes: 26 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution8.rs
Original file line number Diff line number Diff line change
@@ -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
}
}
}

0 comments on commit bf97c5e

Please sign in to comment.