aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2025-08-01 17:31:36 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:37:02 +0200
commit6aeedda54162443a1969ab6410dca0a35acdca01 (patch)
tree2e10f5263f15963b2493470b7219661608c175d8 /gcc
parent73a77277d1aeaaaf422b6583e7dc75ac3013bc62 (diff)
downloadgcc-6aeedda54162443a1969ab6410dca0a35acdca01.zip
gcc-6aeedda54162443a1969ab6410dca0a35acdca01.tar.gz
gcc-6aeedda54162443a1969ab6410dca0a35acdca01.tar.bz2
gccrs: Prevent used after move on self param
gcc/rust/ChangeLog: * hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit): Remove use after move. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/hir/rust-ast-lower-implitem.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-implitem.cc b/gcc/rust/hir/rust-ast-lower-implitem.cc
index fc9fe1a..a35d661 100644
--- a/gcc/rust/hir/rust-ast-lower-implitem.cc
+++ b/gcc/rust/hir/rust-ast-lower-implitem.cc
@@ -278,6 +278,15 @@ ASTLowerTraitItem::visit (AST::Function &func)
function_params.push_back (hir_param);
}
+ if (func.has_self_param ())
+ {
+ // insert mappings for self
+ // TODO: Is this correct ? Looks fishy
+ mappings.insert_hir_self_param (&*self_param);
+ mappings.insert_location (self_param->get_mappings ().get_hirid (),
+ self_param->get_locus ());
+ }
+
HIR::TraitFunctionDecl decl (func.get_function_name (),
std::move (qualifiers),
std::move (generic_params),
@@ -301,14 +310,6 @@ ASTLowerTraitItem::visit (AST::Function &func)
= new HIR::TraitItemFunc (mapping, std::move (decl), std::move (block_expr),
func.get_outer_attrs (), func.get_locus ());
translated = trait_item;
- if (func.has_self_param ())
- {
- // insert mappings for self
- // TODO: Is this correct ? Looks fishy
- mappings.insert_hir_self_param (&*self_param);
- mappings.insert_location (self_param->get_mappings ().get_hirid (),
- self_param->get_locus ());
- }
// add the mappings for the function params at the end
for (auto &param : trait_item->get_decl ().get_function_params ())