]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: expand: Remove proc macro fragment from expander
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 5 Jun 2023 13:21:15 +0000 (15:21 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:46:26 +0000 (18:46 +0100)
Procedural macros are no longer expanded on post order but rather
expanded from their parent. Hence they are no longer stored in the
expander which means this attribute can be removed. This commit also
remove the old expansion mechanism.

gcc/rust/ChangeLog:

* expand/rust-expand-visitor.h: Remove fragment collection fro
procedural macros.
* expand/rust-macro-expand.h (struct MacroExpander): Remove
procedural macro fragment from expander.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/expand/rust-expand-visitor.h
gcc/rust/expand/rust-macro-expand.h

index d86f0d03856a90baefd0ee2d85971ef10d7d248d..d1bdd8a820ad8367c9fc819668ea97fdb3e021f3 100644 (file)
@@ -127,8 +127,6 @@ public:
        value->accept_vis (*this);
 
        auto final_fragment = expander.take_expanded_fragment ();
-       auto proc_macro_fragment
-         = expander.take_expanded_proc_macro_fragment ();
 
        // FIXME: Is that correct? It seems *extremely* dodgy
        if (final_fragment.should_expand ())
@@ -144,19 +142,6 @@ public:
                  }
              }
          }
-       else if (proc_macro_fragment.should_expand ())
-         {
-           it = values.erase (it);
-           for (auto &node : proc_macro_fragment.get_nodes ())
-             {
-               auto new_node = extractor (node);
-               if (new_node != nullptr)
-                 {
-                   it = values.insert (it, std::move (new_node));
-                   it++;
-                 }
-             }
-         }
        else
          {
            ++it;
index 4274c124a25a3f42f1e4a2c7728339c46921e8e6..676a9d14790ed714ed9299533517a15651d0369e 100644 (file)
@@ -236,7 +236,6 @@ struct MacroExpander
     : cfg (cfg), crate (crate), session (session),
       sub_stack (SubstitutionScope ()),
       expanded_fragment (AST::Fragment::create_error ()),
-      expanded_proc_macro_fragment (AST::Fragment::create_error ()),
       has_changed_flag (false), resolver (Resolver::Resolver::get ()),
       mappings (Analysis::Mappings::get ())
   {}
@@ -338,22 +337,6 @@ struct MacroExpander
     return fragment;
   }
 
-  void set_expanded_proc_macro_fragment (AST::Fragment &&fragment)
-  {
-    if (!fragment.is_error ())
-      has_changed_flag = true;
-
-    expanded_proc_macro_fragment = std::move (fragment);
-  }
-
-  AST::Fragment take_expanded_proc_macro_fragment ()
-  {
-    auto fragment = std::move (expanded_proc_macro_fragment);
-    expanded_proc_macro_fragment = AST::Fragment::create_error ();
-
-    return fragment;
-  }
-
   void import_proc_macros (std::string extern_crate);
 
   template <typename T>
@@ -479,7 +462,6 @@ private:
   SubstitutionScope sub_stack;
   std::vector<ContextType> context;
   AST::Fragment expanded_fragment;
-  AST::Fragment expanded_proc_macro_fragment;
   bool has_changed_flag;
 
   AST::MacroRulesDefinition *last_def;