Skip to content

Commit

Permalink
Clone expr instead of taking it
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
P-E-P committed Jan 6, 2025
1 parent c03fc1c commit 01060d0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gcc/rust/typecheck/rust-hir-type-check-enumitem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 01060d0

Please sign in to comment.