From: Pierre-Emmanuel Patry Date: Wed, 26 Jul 2023 10:47:57 +0000 (+0200) Subject: gccrs: Add multiple tests for non root proc macro X-Git-Tag: basepoints/gcc-15~2288 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce7f0df47e83b16c3d7bedfbd7966f01d7ce14b1;p=thirdparty%2Fgcc.git gccrs: Add multiple tests for non root proc macro Add multiple tests to prevent regressions on procedural macros errors when one is declared outside of the crate's top level. gcc/testsuite/ChangeLog: * rust/compile/proc_macro_attribute_non_root_function.rs: New test. * rust/compile/proc_macro_attribute_non_root_method.rs: New test. * rust/compile/proc_macro_attribute_non_root_module.rs: New test. * rust/compile/proc_macro_derive_non_root_function.rs: New test. * rust/compile/proc_macro_derive_non_root_method.rs: New test. * rust/compile/proc_macro_derive_non_root_module.rs: New test. * rust/compile/proc_macro_non_root_function.rs: New test. * rust/compile/proc_macro_non_root_method.rs: New test. * rust/compile/proc_macro_non_root_module.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- diff --git a/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_function.rs b/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_function.rs new file mode 100644 index 000000000000..709119caa0ed --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_function.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +fn outer_function() { + #[proc_macro_attribute] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_attribute.. must currently reside in the root of the crate" } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_method.rs b/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_method.rs new file mode 100644 index 000000000000..30f3196a976e --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_method.rs @@ -0,0 +1,10 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +struct DummyStruct; + +impl DummyStruct { + pub fn method(self) { + #[proc_macro_attribute] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_attribute.. must currently reside in the root of the crate" } + } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_module.rs b/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_module.rs new file mode 100644 index 000000000000..60165bed851e --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_attribute_non_root_module.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +mod test_module { + #[proc_macro_attribute] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_attribute.. must currently reside in the root of the crate" } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_derive_non_root_function.rs b/gcc/testsuite/rust/compile/proc_macro_derive_non_root_function.rs new file mode 100644 index 000000000000..69d5ca1fe092 --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_derive_non_root_function.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +fn outer_function() { + #[proc_macro_derive(SomeTrait)] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_derive.. must currently reside in the root of the crate" } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_derive_non_root_method.rs b/gcc/testsuite/rust/compile/proc_macro_derive_non_root_method.rs new file mode 100644 index 000000000000..523b37af11ee --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_derive_non_root_method.rs @@ -0,0 +1,12 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +trait SomeTrait {} + +struct DummyStruct; + +impl DummyStruct { + pub fn method(self) { + #[proc_macro_derive(SomeTrait)] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_derive.. must currently reside in the root of the crate" } + } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_derive_non_root_module.rs b/gcc/testsuite/rust/compile/proc_macro_derive_non_root_module.rs new file mode 100644 index 000000000000..45d7a47f8393 --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_derive_non_root_module.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +mod test_module { + #[proc_macro_derive(SomeTrait)] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_derive.. must currently reside in the root of the crate" } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_non_root_function.rs b/gcc/testsuite/rust/compile/proc_macro_non_root_function.rs new file mode 100644 index 000000000000..930994024bee --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_non_root_function.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +fn outer_function() { + #[proc_macro] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro.. must currently reside in the root of the crate" } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_non_root_method.rs b/gcc/testsuite/rust/compile/proc_macro_non_root_method.rs new file mode 100644 index 000000000000..ee52c324babc --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_non_root_method.rs @@ -0,0 +1,10 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +struct DummyStruct; + +impl DummyStruct { + pub fn method(self) { + #[proc_macro] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro.. must currently reside in the root of the crate" } + } +} diff --git a/gcc/testsuite/rust/compile/proc_macro_non_root_module.rs b/gcc/testsuite/rust/compile/proc_macro_non_root_module.rs new file mode 100644 index 000000000000..1028612a35ec --- /dev/null +++ b/gcc/testsuite/rust/compile/proc_macro_non_root_module.rs @@ -0,0 +1,6 @@ +// { dg-additional-options "-frust-crate-type=proc-macro" } + +mod test_module { + #[proc_macro] + pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro.. must currently reside in the root of the crate" } +}