Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor some attribute functions in rust-ast-lower-base.cc and rust-toplevel-name-resolver.cc #3345

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
9 changes: 3 additions & 6 deletions gcc/rust/hir/rust-ast-lower-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -993,12 +993,9 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block)
void
ASTLoweringBase::lower_macro_definition (AST::MacroRulesDefinition &def)
{
auto is_export = false;
for (const auto &attr : def.get_outer_attrs ())
if (attr.get_path ().as_string () == Values::Attributes::MACRO_EXPORT)
is_export = true;

if (is_export)


if (Analysis::Attributes::is_macro_export(def.get_outer_attrs()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like bad formating here you need space before the opening braces for the arguments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @philberty i did fix it but on clang formatting it reverts back to same. i fear it will fail the check so what should i do

{
mappings.insert_exported_macro (def);
mappings.insert_ast_item (&def);
Expand Down
1 change: 1 addition & 0 deletions gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "rust-ast-full.h"
#include "rust-hir-map.h"
#include "rust-attribute-values.h"
#include "rust-attributes.h"

namespace Rust {
namespace Resolver2_0 {
Expand Down
10 changes: 10 additions & 0 deletions gcc/rust/util/rust-attributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,17 @@ Attributes::is_known (const std::string &attribute_path)

return !lookup.is_error ();
}
bool
Attributes::is_macro_export (const AST::AttrVec outer_attrs)
{
for (const auto &attr : outer_attrs)

if (attr.get_path ().as_string () == Values::Attributes::MACRO_EXPORT)

return true;

return false;
}
using Attrs = Values::Attributes;

// https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_feature/builtin_attrs.rs.html#248
Expand Down
1 change: 1 addition & 0 deletions gcc/rust/util/rust-attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Attributes
{
public:
static bool is_known (const std::string &attribute_path);
static bool is_macro_export (const AST::AttrVec outer_attrs);
};

enum CompilerPass
Expand Down
Loading