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-7664] gccrs: expand: Allow empty derive attribute
Date: Tue, 16 Jan 2024 17:51:49 +0000 (GMT)	[thread overview]
Message-ID: <20240116175149.3008D385829A@sourceware.org> (raw)

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

commit r14-7664-gda450d345c948d9be1fca29d01fa1153c2ddf3bd
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Mon Jun 5 13:17:22 2023 +0200

    gccrs: expand: Allow empty derive attribute
    
    Changes derive macro expansion to accept empty derive attributes. This
    commit also add a test to prevent future regressions.
    
    gcc/rust/ChangeLog:
    
            * expand/rust-expand-visitor.cc (get_traits_to_derive): Change
            assertion to allow empty derive directives.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/derive_empty.rs: New test.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/expand/rust-expand-visitor.cc     | 2 +-
 gcc/testsuite/rust/compile/derive_empty.rs | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index 927d9225049..c7a5f573d7e 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -72,7 +72,7 @@ get_traits_to_derive (AST::Attribute &attr)
 	  = static_cast<AST::DelimTokenTree &> (input).get_token_trees ();
 
 	// erase the delimiters
-	rust_assert (tokens.size () >= 3);
+	rust_assert (tokens.size () >= 2);
 	tokens.erase (tokens.begin ());
 	tokens.pop_back ();
 
diff --git a/gcc/testsuite/rust/compile/derive_empty.rs b/gcc/testsuite/rust/compile/derive_empty.rs
new file mode 100644
index 00000000000..21c67f01d6c
--- /dev/null
+++ b/gcc/testsuite/rust/compile/derive_empty.rs
@@ -0,0 +1,6 @@
+#[derive()]
+struct UnderivedStruct;
+
+fn main() {
+    let _ = UnderivedStruct;
+}

                 reply	other threads:[~2024-01-16 17:51 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=20240116175149.3008D385829A@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).