diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-07-26 12:47:57 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2023-07-27 14:20:52 +0000 |
commit | 1bc8f08453e4db8a679dd95b9ee635aeb8eb1b07 (patch) | |
tree | 67d5d195887aa0cf01d4c67b11480b968b7e5bf0 /gcc | |
parent | 67b2057b7aa82f71dd1310123ec0cd1388b21a2f (diff) | |
download | gcc-1bc8f08453e4db8a679dd95b9ee635aeb8eb1b07.zip gcc-1bc8f08453e4db8a679dd95b9ee635aeb8eb1b07.tar.gz gcc-1bc8f08453e4db8a679dd95b9ee635aeb8eb1b07.tar.bz2 |
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 <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
9 files changed, 68 insertions, 0 deletions
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 0000000..709119c --- /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 0000000..30f3196 --- /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 0000000..60165be --- /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 0000000..69d5ca1 --- /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 0000000..523b37a --- /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 0000000..45d7a47 --- /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 0000000..9309940 --- /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 0000000..ee52c324 --- /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 0000000..1028612 --- /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" } +} |