diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-12-12 18:30:09 +0100 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2025-01-29 10:45:07 +0000 |
commit | 22d1661fd1d74922e299e35018d7e3763a0bb49c (patch) | |
tree | 668753c1aa78e82b36f51a40d19f51935789f199 /gcc | |
parent | 88fa2ca42f90be216f53fceaa5b008113a64991b (diff) | |
download | gcc-22d1661fd1d74922e299e35018d7e3763a0bb49c.zip gcc-22d1661fd1d74922e299e35018d7e3763a0bb49c.tar.gz gcc-22d1661fd1d74922e299e35018d7e3763a0bb49c.tar.bz2 |
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-enumitem.cc | 9 |
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 7d8f7e4..ac85075 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 |