Skip to content

Commit df4566d

Browse files
committed
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 <[email protected]>
1 parent 1d9edfc commit df4566d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

gcc/rust/hir/rust-ast-lower-implitem.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ ASTLowerTraitItem::visit (AST::Function &func)
278278
function_params.push_back (hir_param);
279279
}
280280

281+
if (func.has_self_param ())
282+
{
283+
// insert mappings for self
284+
// TODO: Is this correct ? Looks fishy
285+
mappings.insert_hir_self_param (&*self_param);
286+
mappings.insert_location (self_param->get_mappings ().get_hirid (),
287+
self_param->get_locus ());
288+
}
289+
281290
HIR::TraitFunctionDecl decl (func.get_function_name (),
282291
std::move (qualifiers),
283292
std::move (generic_params),
@@ -301,14 +310,6 @@ ASTLowerTraitItem::visit (AST::Function &func)
301310
= new HIR::TraitItemFunc (mapping, std::move (decl), std::move (block_expr),
302311
func.get_outer_attrs (), func.get_locus ());
303312
translated = trait_item;
304-
if (func.has_self_param ())
305-
{
306-
// insert mappings for self
307-
// TODO: Is this correct ? Looks fishy
308-
mappings.insert_hir_self_param (&*self_param);
309-
mappings.insert_location (self_param->get_mappings ().get_hirid (),
310-
self_param->get_locus ());
311-
}
312313

313314
// add the mappings for the function params at the end
314315
for (auto &param : trait_item->get_decl ().get_function_params ())

0 commit comments

Comments
 (0)