From: Arthur Cohen Date: Thu, 30 Jan 2025 13:19:03 +0000 (+0100) Subject: gccrs: lang-items: Add structural_{peq, teq} X-Git-Tag: basepoints/gcc-16~787 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62a8f1539c0483d84fd1b313acc0d12560f20b62;p=thirdparty%2Fgcc.git gccrs: 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 --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc index 145054ff9d7..92a76613b61 100644 --- a/gcc/rust/util/rust-lang-item.cc +++ b/gcc/rust/util/rust-lang-item.cc @@ -112,6 +112,9 @@ const BiMap 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 diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index f30b93609b5..29b972702bd 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 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 00000000000..d04c295037f --- /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. +}