-
Notifications
You must be signed in to change notification settings - Fork 163
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
base: master
Are you sure you want to change the base?
refactor some attribute functions in rust-ast-lower-base.cc and rust-toplevel-name-resolver.cc #3345
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -168,15 +169,15 @@ TopLevel::visit (AST::ExternCrate &crate) | |
crate.get_referenced_crate ()); | ||
} | ||
|
||
static bool | ||
is_macro_export (AST::MacroRulesDefinition &def) | ||
{ | ||
for (const auto &attr : def.get_outer_attrs ()) | ||
if (attr.get_path ().as_string () == Values::Attributes::MACRO_EXPORT) | ||
return true; | ||
// static bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to remove this comment since you have moved the function over to another file |
||
// is_macro_export (AST::MacroRulesDefinition &def) | ||
// { | ||
// for (const auto &attr : def.get_outer_attrs ()) | ||
// if (attr.get_path ().as_string () == Values::Attributes::MACRO_EXPORT) | ||
// return true; | ||
|
||
return false; | ||
} | ||
// return false; | ||
// } | ||
|
||
void | ||
TopLevel::visit (AST::MacroRulesDefinition ¯o) | ||
|
@@ -186,7 +187,7 @@ TopLevel::visit (AST::MacroRulesDefinition ¯o) | |
// crate if they are marked with #[macro_export]. The execption to this is | ||
// macros 2.0, which get resolved and inserted like regular items. | ||
|
||
if (is_macro_export (macro)) | ||
if (Analysis::Attributes::is_macro_export (macro.get_outer_attrs())) | ||
{ | ||
auto res = ctx.macros.insert_at_root (macro.get_rule_name (), | ||
macro.get_node_id ()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,18 @@ Attributes::is_known (const std::string &attribute_path) | |
|
||
return !lookup.is_error (); | ||
} | ||
bool | ||
Attributes::is_macro_export (AST::AttrVec outer_attrs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing const reference here |
||
{ | ||
for (auto &attr : outer_attrs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const please |
||
{ | ||
if (attr.get_path ().as_string() == Values::Attributes::MACRO_EXPORT) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can get rid of this braces here in the if statement |
||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
using Attrs = Values::Attributes; | ||
|
||
|
There was a problem hiding this comment.
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