[gcc r15-8817] gccrs: derive(Eq): Create copies of Eq typepath to avoid NodeId confusion
Arthur Cohen
cohenarthur@gcc.gnu.org
Mon Mar 24 12:38:44 GMT 2025
https://gcc.gnu.org/g:a4d2184f4305f631eec342b0b5e7fb31981cd31d
commit r15-8817-ga4d2184f4305f631eec342b0b5e7fb31981cd31d
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Feb 20 09:11:21 2025 +0000
gccrs: derive(Eq): Create copies of Eq typepath to avoid NodeId confusion
gcc/rust/ChangeLog:
* expand/rust-derive-eq.cc: Copy `Eq` typepath.
Diff:
---
gcc/rust/expand/rust-derive-eq.cc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/expand/rust-derive-eq.cc b/gcc/rust/expand/rust-derive-eq.cc
index 47a8350d2ffc..dc173defd67e 100644
--- a/gcc/rust/expand/rust-derive-eq.cc
+++ b/gcc/rust/expand/rust-derive-eq.cc
@@ -113,13 +113,17 @@ DeriveEq::eq_impls (
std::unique_ptr<AssociatedItem> &&fn, std::string name,
const std::vector<std::unique_ptr<GenericParam>> &type_generics)
{
+ // We create two copies of the type-path to avoid duplicate NodeIds
auto eq = builder.type_path ({"core", "cmp", "Eq"}, true);
+ auto eq_bound
+ = builder.trait_bound (builder.type_path ({"core", "cmp", "Eq"}, true));
+
auto steq = builder.type_path (LangItem::Kind::STRUCTURAL_TEQ);
auto trait_items = vec (std::move (fn));
auto eq_generics
- = setup_impl_generics (name, type_generics, builder.trait_bound (eq));
+ = setup_impl_generics (name, type_generics, std::move (eq_bound));
auto steq_generics = setup_impl_generics (name, type_generics);
auto eq_impl = builder.trait_impl (eq, std::move (eq_generics.self_type),
More information about the Gcc-cvs
mailing list