From 058682f736b6a0936480bbefb35c0fe0e97a00f5 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 22 May 2023 11:22:45 +0200 Subject: enr: Cleanup #[macro_use] accumulation gcc/rust/ChangeLog: * resolve/rust-early-name-resolver.cc (EarlyNameResolver::go): Cleanup order of calls when accumulating #[macro_use] macros. (EarlyNameResolver::visit): Likewise. --- gcc/rust/resolve/rust-early-name-resolver.cc | 38 ++++++++++++---------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'gcc') diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index 85fd71e..f6ec8c7 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -85,18 +85,15 @@ EarlyNameResolver::go (AST::Crate &crate) scoped (crate.get_node_id (), [&items, &new_items, this] { for (auto &&item : items) { + auto new_macros = std::vector> (); + if (item->get_ast_kind () == AST::Kind::MODULE) - { - auto macros = accumulate_escaped_macros ( - *static_cast (item.get ())); - new_items.emplace_back (std::move (item)); - std::move (macros.begin (), macros.end (), - std::back_inserter (new_items)); - } - else - { - new_items.emplace_back (std::move (item)); - } + new_macros = accumulate_escaped_macros ( + *static_cast (item.get ())); + + new_items.emplace_back (std::move (item)); + std::move (new_macros.begin (), new_macros.end (), + std::back_inserter (new_items)); } }); @@ -636,18 +633,15 @@ EarlyNameResolver::visit (AST::Module &module) scoped (module.get_node_id (), [&items, &new_items, this] { for (auto &&item : items) { + auto new_macros = std::vector> (); + if (item->get_ast_kind () == AST::Kind::MODULE) - { - auto macros = accumulate_escaped_macros ( - *static_cast (item.get ())); - new_items.emplace_back (std::move (item)); - std::move (macros.begin (), macros.end (), - std::back_inserter (new_items)); - } - else - { - new_items.emplace_back (std::move (item)); - } + new_macros = accumulate_escaped_macros ( + *static_cast (item.get ())); + + new_items.emplace_back (std::move (item)); + std::move (new_macros.begin (), new_macros.end (), + std::back_inserter (new_items)); } }); -- cgit v1.1