diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index 63452318113..342ab906e86 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -21,25 +21,17 @@ #include "rust-name-resolver.h" #include "rust-macro-builtins.h" #include "rust-attribute-values.h" +#include "rust-attributes.h" namespace Rust { namespace Resolver { // Check if a module contains the `#[macro_use]` attribute -static bool -is_macro_use_module (const AST::Module &mod) -{ - for (const auto &attr : mod.get_outer_attrs ()) - if (attr.get_path ().as_string () == Values::Attributes::MACRO_USE) - return true; - - return false; -} std::vector> EarlyNameResolver::accumulate_escaped_macros (AST::Module &module) { - if (!is_macro_use_module (module)) + if (!Analysis::Attributes::is_macro_use_module (module)) return {}; // Parse the module's items if they haven't been expanded and the file diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc index 45ebf8c6546..7a4ee8811a5 100644 --- a/gcc/rust/util/rust-attributes.cc +++ b/gcc/rust/util/rust-attributes.cc @@ -37,6 +37,15 @@ Attributes::is_known (const std::string &attribute_path) return !lookup.is_error (); } +bool +Attributes::is_macro_use_module (const AST::Module &mod) +{ + for (const auto &attr : mod.get_outer_attrs ()) + if (attr.get_path ().as_string () == Values::Attributes::MACRO_USE) + return true; + + return false; +} using Attrs = Values::Attributes; diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h index c341b3e0a5d..434b8604f13 100644 --- a/gcc/rust/util/rust-attributes.h +++ b/gcc/rust/util/rust-attributes.h @@ -29,6 +29,7 @@ class Attributes { public: static bool is_known (const std::string &attribute_path); + static bool is_macro_use_module (const AST::Module &mod); }; enum CompilerPass