]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Explicitly use an empty vector for structural eq
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 5 Aug 2025 08:55:33 +0000 (10:55 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:34 +0000 (20:58 +0100)
Previous code was technically valid since the moved from vector was
empty but explicitly setting it empty with it's own name will help.

gcc/rust/ChangeLog:

* expand/rust-derive-eq.cc: Use empty vector explicitly.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/expand/rust-derive-eq.cc

index 7da137fb5c27e6e7367fcd160a6640f2650efdf1..17332a47937ea5f99786af301f0ed50cee3361fd 100644 (file)
@@ -128,9 +128,13 @@ DeriveEq::eq_impls (
   auto eq_impl = builder.trait_impl (eq, std::move (eq_generics.self_type),
                                     std::move (trait_items),
                                     std::move (eq_generics.impl));
+
+  // StructuralEq is a marker trait
+  decltype (trait_items) steq_trait_items = {};
+
   auto steq_impl
     = builder.trait_impl (steq, std::move (steq_generics.self_type),
-                         std::move (trait_items),
+                         std::move (steq_trait_items),
                          std::move (steq_generics.impl));
 
   return vec (std::move (eq_impl), std::move (steq_impl));