From: Arthur Cohen <[email protected]>
gcc/rust/ChangeLog:
* expand/rust-derive-ord.cc (is_last): Remove.
(DeriveOrd::visit_tuple): Fix implementation.
---
gcc/rust/expand/rust-derive-ord.cc | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/gcc/rust/expand/rust-derive-ord.cc
b/gcc/rust/expand/rust-derive-ord.cc
index 2403e9c2a33..e39c6b44ca4 100644
--- a/gcc/rust/expand/rust-derive-ord.cc
+++ b/gcc/rust/expand/rust-derive-ord.cc
@@ -123,15 +123,6 @@ DeriveOrd::make_cmp_arms ()
builder.match_arm (std::move (non_equal))};
}
-template <typename T>
-inline bool
-is_last (T &elt, std::vector<T> &vec)
-{
- rust_assert (!vec.empty ());
-
- return &elt == &vec.back ();
-}
-
std::unique_ptr<Expr>
DeriveOrd::recursive_match (std::vector<SelfOther> &&members)
{
@@ -210,7 +201,14 @@ DeriveOrd::visit_struct (StructStruct &item)
// straightforward once we have `visit_struct` working
void
DeriveOrd::visit_tuple (TupleStruct &item)
-{}
+{
+ auto fields = SelfOther::indexes (builder, item.get_fields ());
+
+ auto match_expr = recursive_match (std::move (fields));
+
+ expanded = cmp_impl (builder.block (std::move (match_expr)),
+ item.get_identifier (), item.get_generic_params ());
+}
// for enums, we need to generate a match for each of the enum's variant that
// contains data and then do the same thing as visit_struct or visit_enum. if
--
2.49.0