https://gcc.gnu.org/g:9d6bd59e86946aeea41551f8ab227f3954235029

commit 9d6bd59e86946aeea41551f8ab227f3954235029
Author: Arthur Cohen <arthur.co...@embecosm.com>
Date:   Thu Jan 30 14:19:03 2025 +0100

    lang-items: Add structural_{peq, teq}
    
    These lang items are used when deriving Eq and PartialEq, and will be 
checked when compiling pattern matching.
    
    gcc/rust/ChangeLog:
    
            * util/rust-lang-item.cc: New items.
            * util/rust-lang-item.h: Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/structural-eq-peq.rs: New test.

Diff:
---
 gcc/rust/util/rust-lang-item.cc                 | 3 +++
 gcc/rust/util/rust-lang-item.h                  | 3 +++
 gcc/testsuite/rust/compile/structural-eq-peq.rs | 9 +++++++++
 3 files changed, 15 insertions(+)

diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc
index 091c6b67ea53..9fcd325dba50 100644
--- a/gcc/rust/util/rust-lang-item.cc
+++ b/gcc/rust/util/rust-lang-item.cc
@@ -112,6 +112,9 @@ const BiMap<std::string, LangItem::Kind> 
Rust::LangItem::lang_items = {{
   {"from_ok", Kind::TRY_FROM_OK},
 
   {"from", Kind::FROM_FROM},
+
+  {"structural_peq", Kind::STRUCTURAL_PEQ},
+  {"structural_teq", Kind::STRUCTURAL_TEQ},
 }};
 
 tl::optional<LangItem::Kind>
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index b5abf615d594..61d6454e6606 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -144,6 +144,9 @@ public:
 
     // NOTE: This is not a lang item in later versions of Rust
     FROM_FROM,
+
+    STRUCTURAL_PEQ,
+    STRUCTURAL_TEQ,
   };
 
   static const BiMap<std::string, Kind> lang_items;
diff --git a/gcc/testsuite/rust/compile/structural-eq-peq.rs 
b/gcc/testsuite/rust/compile/structural-eq-peq.rs
new file mode 100644
index 000000000000..d04c295037f5
--- /dev/null
+++ b/gcc/testsuite/rust/compile/structural-eq-peq.rs
@@ -0,0 +1,9 @@
+#[lang = "structural_peq"]
+pub trait StructuralPartialEq {
+    // Empty.
+}
+
+#[lang = "structural_teq"]
+pub trait StructuralEq {
+    // Empty.
+}

Reply via email to