]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: lang-items: Add structural_{peq, teq}
authorArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Jan 2025 13:19:03 +0000 (14:19 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:06:59 +0000 (13:06 +0100)
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.

gcc/rust/util/rust-lang-item.cc
gcc/rust/util/rust-lang-item.h
gcc/testsuite/rust/compile/structural-eq-peq.rs [new file with mode: 0644]

index 145054ff9d723602bef2b5b73eaeb0c415bcaef7..92a76613b61d325176aca9e4d2d5a787dbf6bf45 100644 (file)
@@ -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>
index f30b93609b5e95bb4ce452771c2c7fe37c55495f..29b972702bd16b4eac8fe941e7c9ebc3760404e5 100644 (file)
@@ -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 (file)
index 0000000..d04c295
--- /dev/null
@@ -0,0 +1,9 @@
+#[lang = "structural_peq"]
+pub trait StructuralPartialEq {
+    // Empty.
+}
+
+#[lang = "structural_teq"]
+pub trait StructuralEq {
+    // Empty.
+}