aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-02-20 09:11:21 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-02-20 09:37:09 +0000
commit35afe3943cc03ce35b3529a23f4fb9e3764c4c81 (patch)
treef8cd3d5c2c1131aaad81ef645cfb76e2627686d6 /gcc/rust/expand
parenta969379df8c239296104006453d1434e9c871bf0 (diff)
downloadgcc-35afe3943cc03ce35b3529a23f4fb9e3764c4c81.zip
gcc-35afe3943cc03ce35b3529a23f4fb9e3764c4c81.tar.gz
gcc-35afe3943cc03ce35b3529a23f4fb9e3764c4c81.tar.bz2
derive(Eq): Create copies of Eq typepath to avoid NodeId confusion
gcc/rust/ChangeLog: * expand/rust-derive-eq.cc: Copy `Eq` typepath.
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r--gcc/rust/expand/rust-derive-eq.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/rust/expand/rust-derive-eq.cc b/gcc/rust/expand/rust-derive-eq.cc
index 47a8350..dc173de 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),