aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-12-12 18:30:09 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-24 13:06:56 +0100
commit178e5f85b48918f49d194b1c48635b2130646578 (patch)
treef0689dfc49e6001616608ac6c20be2824d55d47c
parent0529a772896c36fd72565710c587ce6103a05d2a (diff)
downloadgcc-178e5f85b48918f49d194b1c48635b2130646578.zip
gcc-178e5f85b48918f49d194b1c48635b2130646578.tar.gz
gcc-178e5f85b48918f49d194b1c48635b2130646578.tar.bz2
gccrs: Clone expr instead of taking it
We're reusing the value, it could therefore not be taken be should be cloned. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Clone expr instead of taking it. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-enumitem.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
index 4bf7b72..7fa4b43 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
@@ -142,10 +142,11 @@ TypeCheckEnumItem::visit (HIR::EnumItemDiscriminant &item)
rust_assert (canonical_path.has_value ());
RustIdent ident{*canonical_path, item.get_locus ()};
- variant = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
- item.get_mappings ().get_defid (),
- item.get_identifier ().as_string (), ident,
- item.take_discriminant_expression ());
+ variant
+ = new TyTy::VariantDef (item.get_mappings ().get_hirid (),
+ item.get_mappings ().get_defid (),
+ item.get_identifier ().as_string (), ident,
+ item.get_discriminant_expression ().clone_expr ());
}
void