// <http://www.gnu.org/licenses/>.
#include "rust-expand-visitor.h"
+#include "rust-attributes.h"
namespace Rust {
{
auto current = *it;
- it = attrs.erase (it);
- expand_outer_attribute (item, current.get_path ());
+ if (!is_builtin (current) && !is_derive (current))
+ {
+ it = attrs.erase (it);
+ expand_outer_attribute (item, current.get_path ());
+ }
+ else
+ {
+ it++;
+ }
}
}
{
auto current = *it;
- it = attrs.erase (it);
- expand_inner_attribute (item, current.get_path ());
+ if (!is_builtin (current) && !is_derive (current))
+ {
+ it = attrs.erase (it);
+ expand_inner_attribute (item, current.get_path ());
+ }
+ else
+ {
+ it++;
+ }
}
}
{
auto current = *it;
- if (is_derive (current))
+ if (!is_builtin (current) && is_derive (current))
{
it = attrs.erase (it);
// Downcasting checked in is_derive
&& !segments.empty () && "derive" == segments[0].get_segment_name ();
}
+bool
+ExpandVisitor::is_builtin (AST::Attribute &attr)
+{
+ auto &segments = attr.get_path ().get_segments ();
+ return !segments.empty ()
+ && !Analysis::BuiltinAttributeMappings::get ()
+ ->lookup_builtin (segments[0].get_segment_name ())
+ .is_error ();
+}
+
} // namespace Rust
{"link_section", CODE_GENERATION},
{"no_mangle", CODE_GENERATION},
{"repr", CODE_GENERATION},
+ {"rustc_builtin_macro", EXPANSION},
{"path", EXPANSION},
{"macro_use", NAME_RESOLUTION},
// FIXME: This is not implemented yet, see