From: Pierre-Emmanuel Patry <[email protected]>

Those functions are part of a proc macro context and no longer require
an explicit long name about their context.

gcc/rust/ChangeLog:

        * expand/rust-macro-expand.h (struct MacroExpander): Apply new name.
        * resolve/rust-early-name-resolver-2.0.cc 
(Early::visit_derive_attribute):
        Likewise.
        (Early::visit_non_builtin_attribute): Likewise.
        * resolve/rust-toplevel-name-resolver-2.0.cc 
(TopLevel::visit_extern_crate):
        Likewise.
        * util/rust-hir-map.cc (ProcMacroMappings::insert_bang_proc_macros):
        Use new member name.
        (ProcMacroMappings::lookup_derive_proc_macros): Likewise.
        (ProcMacroMappings::lookup_bang_proc_macros): Likewise.
        (ProcMacroMappings::lookup_attribute_proc_macros): Likewise.
        (ProcMacroMappings::insert_derive_proc_macro_def): Likewise.
        (ProcMacroMappings::insert_derive_def): Likewise.
        (ProcMacroMappings::insert_bang_proc_macro_def): Likewise.
        (ProcMacroMappings::insert_bang_def): Likewise.
        (ProcMacroMappings::insert_attribute_proc_macro_def): Likewise.
        (ProcMacroMappings::insert_attribute_def): Likewise.
        (ProcMacroMappings::lookup_derive_proc_macro_def): Likewise.
        (ProcMacroMappings::lookup_derive_def): Likewise.
        (ProcMacroMappings::lookup_bang_proc_macro_def): Likewise.
        (ProcMacroMappings::lookup_bang_def): Likewise.
        (ProcMacroMappings::lookup_attribute_proc_macro_def): Likewise.
        (ProcMacroMappings::lookup_attribute_def): Likewise.
        (ProcMacroMappings::insert_derive_invocation): Likewise.
        (ProcMacroMappings::lookup_derive_proc_macro_invocation): Likewise.
        (ProcMacroMappings::lookup_derive_invocation): Likewise.
        (ProcMacroMappings::insert_bang_invocation): Likewise.
        (ProcMacroMappings::lookup_bang_invocation): Likewise.
        (ProcMacroMappings::insert_attribute_invocation): Likewise.
        (ProcMacroMappings::lookup_attribute_invocation): Likewise.
        * util/rust-hir-map.h (class ProcMacroMappings): Rename member maps as
        well as some functions to remove the proc macro mention.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/b077e3ff59dd351caf344e5bf6dac94349de62ca

The commit has NOT been mentioned in any issue.

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4878

 gcc/rust/expand/rust-macro-expand.h           |  6 +-
 .../resolve/rust-early-name-resolver-2.0.cc   | 12 ++--
 .../rust-toplevel-name-resolver-2.0.cc        |  6 +-
 gcc/rust/util/rust-hir-map.cc                 | 62 +++++++++----------
 gcc/rust/util/rust-hir-map.h                  | 39 +++++-------
 5 files changed, 59 insertions(+), 66 deletions(-)

diff --git a/gcc/rust/expand/rust-macro-expand.h 
b/gcc/rust/expand/rust-macro-expand.h
index ddd433c39..02de84220 100644
--- a/gcc/rust/expand/rust-macro-expand.h
+++ b/gcc/rust/expand/rust-macro-expand.h
@@ -412,7 +412,7 @@ struct MacroExpander
   AST::Fragment expand_derive_proc_macro (T &item, AST::SimplePath &path)
   {
     tl::optional<CustomDeriveProcMacro &> macro
-      = mappings.pmacro_mappings.lookup_derive_proc_macro_invocation (path);
+      = mappings.pmacro_mappings.lookup_derive_invocation (path);
     if (!macro.has_value ())
       {
        rust_error_at (path.get_locus (), "macro not found");
@@ -435,7 +435,7 @@ struct MacroExpander
                                        AST::MacroInvocation &invocation)
   {
     tl::optional<BangProcMacro &> macro
-      = mappings.pmacro_mappings.lookup_bang_proc_macro_invocation 
(invocation);
+      = mappings.pmacro_mappings.lookup_bang_invocation (invocation);
     if (!macro.has_value ())
       {
        rust_error_at (invocation.get_locus (), "macro not found");
@@ -457,7 +457,7 @@ struct MacroExpander
   AST::Fragment expand_attribute_proc_macro (T &item, AST::SimplePath &path)
   {
     tl::optional<AttributeProcMacro &> macro
-      = mappings.pmacro_mappings.lookup_attribute_proc_macro_invocation (path);
+      = mappings.pmacro_mappings.lookup_attribute_invocation (path);
     if (!macro.has_value ())
       {
        rust_error_at (path.get_locus (), "macro not found");
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index d4d0cb8e1..d45536717 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -402,12 +402,12 @@ Early::visit_derive_attribute (AST::Attribute &attr,
          continue;
        }
 
-      auto pm_def = mappings.pmacro_mappings.lookup_derive_proc_macro_def (
+      auto pm_def = mappings.pmacro_mappings.lookup_derive_def (
        ns_def->definition.get_node_id ());
 
       if (pm_def.has_value ())
-       mappings.pmacro_mappings.insert_derive_proc_macro_invocation (
-         trait, pm_def.value ());
+       mappings.pmacro_mappings.insert_derive_invocation (trait,
+                                                          pm_def.value ());
     }
 }
 
@@ -425,14 +425,14 @@ Early::visit_non_builtin_attribute (AST::Attribute &attr,
                            name.c_str ()));
       return;
     }
-  auto pm_def = mappings.pmacro_mappings.lookup_attribute_proc_macro_def (
+  auto pm_def = mappings.pmacro_mappings.lookup_attribute_def (
     ns_def->definition.get_node_id ());
 
   if (!pm_def.has_value ())
     return;
 
-  mappings.pmacro_mappings.insert_attribute_proc_macro_invocation (
-    attr.get_path (), pm_def.value ());
+  mappings.pmacro_mappings.insert_attribute_invocation (attr.get_path (),
+                                                       pm_def.value ());
 }
 
 void
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 88b946649..4b2fae0dd 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -199,19 +199,19 @@ TopLevel::visit_extern_crate (AST::ExternCrate 
&extern_crate, AST::Crate &crate,
     {
       insert_macros (derive_macros.value (), ctx);
       for (auto &macro : derive_macros.value ())
-       mappings.pmacro_mappings.insert_derive_proc_macro_def (macro);
+       mappings.pmacro_mappings.insert_derive_def (macro);
     }
   if (attribute_macros.has_value ())
     {
       insert_macros (attribute_macros.value (), ctx);
       for (auto &macro : attribute_macros.value ())
-       mappings.pmacro_mappings.insert_attribute_proc_macro_def (macro);
+       mappings.pmacro_mappings.insert_attribute_def (macro);
     }
   if (bang_macros.has_value ())
     {
       insert_macros (bang_macros.value (), ctx);
       for (auto &macro : bang_macros.value ())
-       mappings.pmacro_mappings.insert_bang_proc_macro_def (macro);
+       mappings.pmacro_mappings.insert_bang_def (macro);
     }
 
   // We do *NOT* visit the crate because loaded crates are resolved
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index af3d6f222..a5eefa9e8 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -1137,37 +1137,37 @@ void
 ProcMacroMappings::insert_derive_proc_macros (
   CrateNum num, std::vector<CustomDeriveProcMacro> macros)
 {
-  auto it = procmacrosDeriveMappings.find (num);
-  rust_assert (it == procmacrosDeriveMappings.end ());
+  auto it = deriveMappings.find (num);
+  rust_assert (it == deriveMappings.end ());
 
-  procmacrosDeriveMappings[num] = macros;
+  deriveMappings[num] = macros;
 }
 
 void
 ProcMacroMappings::insert_bang_proc_macros (CrateNum num,
                                            std::vector<BangProcMacro> macros)
 {
-  auto it = procmacrosBangMappings.find (num);
-  rust_assert (it == procmacrosBangMappings.end ());
+  auto it = bangMappings.find (num);
+  rust_assert (it == bangMappings.end ());
 
-  procmacrosBangMappings[num] = macros;
+  bangMappings[num] = macros;
 }
 
 void
 ProcMacroMappings::insert_attribute_proc_macros (
   CrateNum num, std::vector<AttributeProcMacro> macros)
 {
-  auto it = procmacrosAttributeMappings.find (num);
-  rust_assert (it == procmacrosAttributeMappings.end ());
+  auto it = attributeMappings.find (num);
+  rust_assert (it == attributeMappings.end ());
 
-  procmacrosAttributeMappings[num] = macros;
+  attributeMappings[num] = macros;
 }
 
 tl::optional<std::vector<CustomDeriveProcMacro> &>
 ProcMacroMappings::lookup_derive_proc_macros (CrateNum num)
 {
-  auto it = procmacrosDeriveMappings.find (num);
-  if (it == procmacrosDeriveMappings.end ())
+  auto it = deriveMappings.find (num);
+  if (it == deriveMappings.end ())
     return tl::nullopt;
 
   return it->second;
@@ -1176,8 +1176,8 @@ ProcMacroMappings::lookup_derive_proc_macros (CrateNum 
num)
 tl::optional<std::vector<BangProcMacro> &>
 ProcMacroMappings::lookup_bang_proc_macros (CrateNum num)
 {
-  auto it = procmacrosBangMappings.find (num);
-  if (it == procmacrosBangMappings.end ())
+  auto it = bangMappings.find (num);
+  if (it == bangMappings.end ())
     return tl::nullopt;
 
   return it->second;
@@ -1186,15 +1186,15 @@ ProcMacroMappings::lookup_bang_proc_macros (CrateNum 
num)
 tl::optional<std::vector<AttributeProcMacro> &>
 ProcMacroMappings::lookup_attribute_proc_macros (CrateNum num)
 {
-  auto it = procmacrosAttributeMappings.find (num);
-  if (it == procmacrosAttributeMappings.end ())
+  auto it = attributeMappings.find (num);
+  if (it == attributeMappings.end ())
     return tl::nullopt;
 
   return it->second;
 }
 
 void
-ProcMacroMappings::insert_derive_proc_macro_def (CustomDeriveProcMacro macro)
+ProcMacroMappings::insert_derive_def (CustomDeriveProcMacro macro)
 {
   auto it = procmacroDeriveMappings.find (macro.get_node_id ());
   rust_assert (it == procmacroDeriveMappings.end ());
@@ -1203,7 +1203,7 @@ ProcMacroMappings::insert_derive_proc_macro_def 
(CustomDeriveProcMacro macro)
 }
 
 void
-ProcMacroMappings::insert_bang_proc_macro_def (BangProcMacro macro)
+ProcMacroMappings::insert_bang_def (BangProcMacro macro)
 {
   auto it = procmacroBangMappings.find (macro.get_node_id ());
   rust_assert (it == procmacroBangMappings.end ());
@@ -1212,7 +1212,7 @@ ProcMacroMappings::insert_bang_proc_macro_def 
(BangProcMacro macro)
 }
 
 void
-ProcMacroMappings::insert_attribute_proc_macro_def (AttributeProcMacro macro)
+ProcMacroMappings::insert_attribute_def (AttributeProcMacro macro)
 {
   auto it = procmacroAttributeMappings.find (macro.get_node_id ());
   rust_assert (it == procmacroAttributeMappings.end ());
@@ -1221,7 +1221,7 @@ ProcMacroMappings::insert_attribute_proc_macro_def 
(AttributeProcMacro macro)
 }
 
 tl::optional<CustomDeriveProcMacro &>
-ProcMacroMappings::lookup_derive_proc_macro_def (NodeId id)
+ProcMacroMappings::lookup_derive_def (NodeId id)
 {
   auto it = procmacroDeriveMappings.find (id);
   if (it == procmacroDeriveMappings.end ())
@@ -1231,7 +1231,7 @@ ProcMacroMappings::lookup_derive_proc_macro_def (NodeId 
id)
 }
 
 tl::optional<BangProcMacro &>
-ProcMacroMappings::lookup_bang_proc_macro_def (NodeId id)
+ProcMacroMappings::lookup_bang_def (NodeId id)
 {
   auto it = procmacroBangMappings.find (id);
   if (it == procmacroBangMappings.end ())
@@ -1241,7 +1241,7 @@ ProcMacroMappings::lookup_bang_proc_macro_def (NodeId id)
 }
 
 tl::optional<AttributeProcMacro &>
-ProcMacroMappings::lookup_attribute_proc_macro_def (NodeId id)
+ProcMacroMappings::lookup_attribute_def (NodeId id)
 {
   auto it = procmacroAttributeMappings.find (id);
   if (it == procmacroAttributeMappings.end ())
@@ -1251,8 +1251,8 @@ ProcMacroMappings::lookup_attribute_proc_macro_def 
(NodeId id)
 }
 
 void
-ProcMacroMappings::insert_derive_proc_macro_invocation (
-  AST::SimplePath &invoc, CustomDeriveProcMacro def)
+ProcMacroMappings::insert_derive_invocation (AST::SimplePath &invoc,
+                                            CustomDeriveProcMacro def)
 {
   auto it = procmacroDeriveInvocations.find (invoc.get_node_id ());
   rust_assert (it == procmacroDeriveInvocations.end ());
@@ -1261,7 +1261,7 @@ ProcMacroMappings::insert_derive_proc_macro_invocation (
 }
 
 tl::optional<CustomDeriveProcMacro &>
-ProcMacroMappings::lookup_derive_proc_macro_invocation (AST::SimplePath &invoc)
+ProcMacroMappings::lookup_derive_invocation (AST::SimplePath &invoc)
 {
   auto it = procmacroDeriveInvocations.find (invoc.get_node_id ());
   if (it == procmacroDeriveInvocations.end ())
@@ -1271,8 +1271,8 @@ ProcMacroMappings::lookup_derive_proc_macro_invocation 
(AST::SimplePath &invoc)
 }
 
 void
-ProcMacroMappings::insert_bang_proc_macro_invocation (
-  AST::MacroInvocation &invoc, BangProcMacro def)
+ProcMacroMappings::insert_bang_invocation (AST::MacroInvocation &invoc,
+                                          BangProcMacro def)
 {
   auto it = procmacroBangInvocations.find (invoc.get_node_id ());
   rust_assert (it == procmacroBangInvocations.end ());
@@ -1281,8 +1281,7 @@ ProcMacroMappings::insert_bang_proc_macro_invocation (
 }
 
 tl::optional<BangProcMacro &>
-ProcMacroMappings::lookup_bang_proc_macro_invocation (
-  AST::MacroInvocation &invoc)
+ProcMacroMappings::lookup_bang_invocation (AST::MacroInvocation &invoc)
 {
   auto it = procmacroBangInvocations.find (invoc.get_node_id ());
   if (it == procmacroBangInvocations.end ())
@@ -1292,8 +1291,8 @@ ProcMacroMappings::lookup_bang_proc_macro_invocation (
 }
 
 void
-ProcMacroMappings::insert_attribute_proc_macro_invocation (
-  AST::SimplePath &invoc, AttributeProcMacro def)
+ProcMacroMappings::insert_attribute_invocation (AST::SimplePath &invoc,
+                                               AttributeProcMacro def)
 {
   auto it = procmacroAttributeInvocations.find (invoc.get_node_id ());
   rust_assert (it == procmacroAttributeInvocations.end ());
@@ -1302,8 +1301,7 @@ ProcMacroMappings::insert_attribute_proc_macro_invocation 
(
 }
 
 tl::optional<AttributeProcMacro &>
-ProcMacroMappings::lookup_attribute_proc_macro_invocation (
-  AST::SimplePath &invoc)
+ProcMacroMappings::lookup_attribute_invocation (AST::SimplePath &invoc)
 {
   auto it = procmacroAttributeInvocations.find (invoc.get_node_id ());
   if (it == procmacroAttributeInvocations.end ())
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index a7f631608..c0041399f 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -110,11 +110,9 @@ public:
 
 class ProcMacroMappings
 {
-  std::map<CrateNum, std::vector<CustomDeriveProcMacro>>
-    procmacrosDeriveMappings;
-  std::map<CrateNum, std::vector<BangProcMacro>> procmacrosBangMappings;
-  std::map<CrateNum, std::vector<AttributeProcMacro>>
-    procmacrosAttributeMappings;
+  std::map<CrateNum, std::vector<CustomDeriveProcMacro>> deriveMappings;
+  std::map<CrateNum, std::vector<BangProcMacro>> bangMappings;
+  std::map<CrateNum, std::vector<AttributeProcMacro>> attributeMappings;
 
   std::map<NodeId, CustomDeriveProcMacro> procmacroDeriveMappings;
   std::map<NodeId, BangProcMacro> procmacroBangMappings;
@@ -138,28 +136,25 @@ public:
   tl::optional<std::vector<AttributeProcMacro> &>
   lookup_attribute_proc_macros (CrateNum num);
 
-  void insert_derive_proc_macro_def (CustomDeriveProcMacro macro);
-  void insert_bang_proc_macro_def (BangProcMacro macro);
-  void insert_attribute_proc_macro_def (AttributeProcMacro macro);
+  void insert_derive_def (CustomDeriveProcMacro macro);
+  void insert_bang_def (BangProcMacro macro);
+  void insert_attribute_def (AttributeProcMacro macro);
 
-  tl::optional<CustomDeriveProcMacro &>
-  lookup_derive_proc_macro_def (NodeId id);
-  tl::optional<BangProcMacro &> lookup_bang_proc_macro_def (NodeId id);
-  tl::optional<AttributeProcMacro &>
-  lookup_attribute_proc_macro_def (NodeId id);
+  tl::optional<CustomDeriveProcMacro &> lookup_derive_def (NodeId id);
+  tl::optional<BangProcMacro &> lookup_bang_def (NodeId id);
+  tl::optional<AttributeProcMacro &> lookup_attribute_def (NodeId id);
 
   tl::optional<CustomDeriveProcMacro &>
-  lookup_derive_proc_macro_invocation (AST::SimplePath &invoc);
+  lookup_derive_invocation (AST::SimplePath &invoc);
   tl::optional<BangProcMacro &>
-  lookup_bang_proc_macro_invocation (AST::MacroInvocation &invoc_id);
+  lookup_bang_invocation (AST::MacroInvocation &invoc_id);
   tl::optional<AttributeProcMacro &>
-  lookup_attribute_proc_macro_invocation (AST::SimplePath &invoc);
-  void insert_derive_proc_macro_invocation (AST::SimplePath &invoc,
-                                           CustomDeriveProcMacro def);
-  void insert_bang_proc_macro_invocation (AST::MacroInvocation &invoc,
-                                         BangProcMacro def);
-  void insert_attribute_proc_macro_invocation (AST::SimplePath &invoc,
-                                              AttributeProcMacro def);
+  lookup_attribute_invocation (AST::SimplePath &invoc);
+  void insert_derive_invocation (AST::SimplePath &invoc,
+                                CustomDeriveProcMacro def);
+  void insert_bang_invocation (AST::MacroInvocation &invoc, BangProcMacro def);
+  void insert_attribute_invocation (AST::SimplePath &invoc,
+                                   AttributeProcMacro def);
 };
 
 class Mappings
-- 
2.55.0

Reply via email to