Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions gcc/rust/expand/rust-derive-cmp-common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
namespace Rust {
namespace AST {

static PathInExpression
reconstruct_path (const PathInExpression &path)
{
return PathInExpression (path.get_segments (), path.get_outer_attrs (),
path.get_locus (), path.opening_scope_resolution ());
}

SelfOther
SelfOther::index (Builder builder, int idx)
{
Expand Down Expand Up @@ -96,9 +103,8 @@ EnumMatchBuilder::tuple (EnumItem &variant_raw)
});
}

// TODO: Replace with `reconstruct()` instead of building these twice
auto self_variant_path = builder.variant_path (enum_path, variant_path);
auto other_variant_path = builder.variant_path (enum_path, variant_path);
auto other_variant_path = reconstruct_path (self_variant_path);

auto self_pattern_items = std::unique_ptr<TupleStructItems> (
new TupleStructItemsNoRest (std::move (self_patterns)));
Expand Down Expand Up @@ -159,9 +165,8 @@ EnumMatchBuilder::strukt (EnumItem &variant_raw)
});
}

// TODO: Replace with `reconstruct()` instead of building these twice
auto self_variant_path = builder.variant_path (enum_path, variant_path);
auto other_variant_path = builder.variant_path (enum_path, variant_path);
auto other_variant_path = reconstruct_path (self_variant_path);

auto self_elts = StructPatternElements (std::move (self_fields));
auto other_elts = StructPatternElements (std::move (other_fields));
Expand Down