[gcc/devel/rust/master] Clone expr instead of taking it
Thomas Schwinge
tschwinge@gcc.gnu.org
Wed Mar 26 14:09:42 GMT 2025
https://gcc.gnu.org/g:22d1661fd1d74922e299e35018d7e3763a0bb49c
commit 22d1661fd1d74922e299e35018d7e3763a0bb49c
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Thu Dec 12 18:30:09 2024 +0100
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>
Diff:
---
gcc/rust/typecheck/rust-hir-type-check-enumitem.cc | 9 +++++----
1 file 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 7d8f7e4c2655..ac850752f2d2 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
More information about the Gcc-cvs
mailing list