]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Clone expr instead of taking it
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 12 Dec 2024 17:30:09 +0000 (18:30 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:06:56 +0000 (13:06 +0100)
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>
gcc/rust/typecheck/rust-hir-type-check-enumitem.cc

index 4bf7b72c1e94328da252d1ca2ceeba2e592a5cc9..7fa4b43d187bfb18edf155494049ea9884e6d43c 100644 (file)
@@ -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