public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-7851] gccrs: Add multiple tests for non root proc macro
Date: Tue, 16 Jan 2024 18:04:01 +0000 (GMT)	[thread overview]
Message-ID: <20240116180402.18EDB385800C@sourceware.org> (raw)

https://gcc.gnu.org/g:ce7f0df47e83b16c3d7bedfbd7966f01d7ce14b1

commit r14-7851-gce7f0df47e83b16c3d7bedfbd7966f01d7ce14b1
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Wed Jul 26 12:47:57 2023 +0200

    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 <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 .../rust/compile/proc_macro_attribute_non_root_function.rs   |  6 ++++++
 .../rust/compile/proc_macro_attribute_non_root_method.rs     | 10 ++++++++++
 .../rust/compile/proc_macro_attribute_non_root_module.rs     |  6 ++++++
 .../rust/compile/proc_macro_derive_non_root_function.rs      |  6 ++++++
 .../rust/compile/proc_macro_derive_non_root_method.rs        | 12 ++++++++++++
 .../rust/compile/proc_macro_derive_non_root_module.rs        |  6 ++++++
 gcc/testsuite/rust/compile/proc_macro_non_root_function.rs   |  6 ++++++
 gcc/testsuite/rust/compile/proc_macro_non_root_method.rs     | 10 ++++++++++
 gcc/testsuite/rust/compile/proc_macro_non_root_module.rs     |  6 ++++++
 9 files changed, 68 insertions(+)

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 00000000000..709119caa0e
--- /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 00000000000..30f3196a976
--- /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 00000000000..60165bed851
--- /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 00000000000..69d5ca1fe09
--- /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 00000000000..523b37af11e
--- /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 00000000000..45d7a47f839
--- /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 00000000000..930994024be
--- /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 00000000000..ee52c324bab
--- /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 00000000000..1028612a35e
--- /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" }
+}

                 reply	other threads:[~2024-01-16 18:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240116180402.18EDB385800C@sourceware.org \
    --to=cohenarthur@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).