about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-20 20:25:31 -0700
committerbors <bors@rust-lang.org>2013-07-20 20:25:31 -0700
commitd029ebfc5f69f830fe24b4c8a979970d9a7d297d (patch)
tree80d9e825ff9f805d15c98441560c6decf85f0739 /src/libsyntax/ext
parent8476419fefda988f66ab6b2a1847e402133a0a29 (diff)
parentcc760a647ac0094814f592d08813ebae0b3bec47 (diff)
downloadrust-d029ebfc5f69f830fe24b4c8a979970d9a7d297d.tar.gz
rust-d029ebfc5f69f830fe24b4c8a979970d9a7d297d.zip
auto merge of #7902 : huonw/rust/attr++, r=cmr,pcwalton
This does a number of things, but especially dramatically reduce the
number of allocations performed for operations involving attributes/
meta items:

- Converts ast::meta_item & ast::attribute and other associated enums
  to CamelCase.
- Converts several standalone functions in syntax::attr into methods,
  defined on two traits AttrMetaMethods & AttributeMethods. The former
  is common to both MetaItem and Attribute since the latter is a thin
  wrapper around the former.
- Deletes functions that are unnecessary due to iterators.
- Converts other standalone functions to use iterators and the generic
  AttrMetaMethods rather than allocating a lot of new vectors (e.g. the
  old code would have to allocate a new vector to use functions that
  operated on &[meta_item] on &[attribute].)
- Moves the core algorithm of the #[cfg] matching to syntax::attr,
  similar to find_inline_attr and find_linkage_metas.

This doesn't have much of an effect on the speed of #[cfg] stripping,
despite hugely reducing the number of allocations performed; presumably
most of the time is spent in the ast folder rather than doing attribute
checks.

Also fixes the Eq instance of MetaItem_ to correctly ignore spans, so
that `rustc --cfg 'foo(bar)'` now works.
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/auto_encode.rs4
-rw-r--r--src/libsyntax/ext/base.rs2
-rw-r--r--src/libsyntax/ext/build.rs41
-rw-r--r--src/libsyntax/ext/deriving/clone.rs10
-rw-r--r--src/libsyntax/ext/deriving/cmp/eq.rs4
-rw-r--r--src/libsyntax/ext/deriving/cmp/ord.rs4
-rw-r--r--src/libsyntax/ext/deriving/cmp/totaleq.rs9
-rw-r--r--src/libsyntax/ext/deriving/cmp/totalord.rs4
-rw-r--r--src/libsyntax/ext/deriving/decodable.rs4
-rw-r--r--src/libsyntax/ext/deriving/encodable.rs4
-rw-r--r--src/libsyntax/ext/deriving/generic.rs5
-rw-r--r--src/libsyntax/ext/deriving/iter_bytes.rs4
-rw-r--r--src/libsyntax/ext/deriving/mod.rs19
-rw-r--r--src/libsyntax/ext/deriving/rand.rs4
-rw-r--r--src/libsyntax/ext/deriving/to_str.rs4
-rw-r--r--src/libsyntax/ext/deriving/zero.rs4
-rw-r--r--src/libsyntax/ext/expand.rs19
17 files changed, 72 insertions, 73 deletions
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 64d2644b383..4ada7f7479b 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -17,7 +17,7 @@ use ext::base::*;
 pub fn expand_auto_encode(
     cx: @ExtCtxt,
     span: span,
-    _mitem: @ast::meta_item,
+    _mitem: @ast::MetaItem,
     in_items: ~[@ast::item]
 ) -> ~[@ast::item] {
     cx.span_err(span, "`#[auto_encode]` is deprecated, use `#[deriving(Encodable)]` instead");
@@ -27,7 +27,7 @@ pub fn expand_auto_encode(
 pub fn expand_auto_decode(
     cx: @ExtCtxt,
     span: span,
-    _mitem: @ast::meta_item,
+    _mitem: @ast::MetaItem,
     in_items: ~[@ast::item]
 ) -> ~[@ast::item] {
     cx.span_err(span, "`#[auto_decode]` is deprecated, use `#[deriving(Decodable)]` instead");
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 2f86a0460d1..753d32fee5a 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -36,7 +36,7 @@ pub struct MacroDef {
 
 pub type ItemDecorator = @fn(@ExtCtxt,
                              span,
-                             @ast::meta_item,
+                             @ast::MetaItem,
                              ~[@ast::item])
                           -> ~[@ast::item];
 
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 59754f5519e..df5f3d8d895 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -163,7 +163,7 @@ pub trait AstBuilder {
 
     // items
     fn item(&self, span: span,
-            name: ident, attrs: ~[ast::attribute], node: ast::item_) -> @ast::item;
+            name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item;
 
     fn arg(&self, span: span, name: ident, ty: ast::Ty) -> ast::arg;
     // XXX unused self
@@ -199,7 +199,7 @@ pub trait AstBuilder {
     fn item_struct(&self, span: span, name: ident, struct_def: ast::struct_def) -> @ast::item;
 
     fn item_mod(&self, span: span,
-                name: ident, attrs: ~[ast::attribute],
+                name: ident, attrs: ~[ast::Attribute],
                 vi: ~[ast::view_item], items: ~[@ast::item]) -> @ast::item;
 
     fn item_ty_poly(&self,
@@ -209,11 +209,11 @@ pub trait AstBuilder {
                     generics: Generics) -> @ast::item;
     fn item_ty(&self, span: span, name: ident, ty: ast::Ty) -> @ast::item;
 
-    fn attribute(&self, sp: span, mi: @ast::meta_item) -> ast::attribute;
+    fn attribute(&self, sp: span, mi: @ast::MetaItem) -> ast::Attribute;
 
-    fn meta_word(&self, sp: span, w: @str) -> @ast::meta_item;
-    fn meta_list(&self, sp: span, name: @str, mis: ~[@ast::meta_item]) -> @ast::meta_item;
-    fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::meta_item;
+    fn meta_word(&self, sp: span, w: @str) -> @ast::MetaItem;
+    fn meta_list(&self, sp: span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem;
+    fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::MetaItem;
 
     fn view_use(&self, sp: span,
                 vis: ast::visibility, vp: ~[@ast::view_path]) -> ast::view_item;
@@ -657,7 +657,7 @@ impl AstBuilder for @ExtCtxt {
     }
 
     fn item(&self, span: span,
-            name: ident, attrs: ~[ast::attribute], node: ast::item_) -> @ast::item {
+            name: ident, attrs: ~[ast::Attribute], node: ast::item_) -> @ast::item {
         // XXX: Would be nice if our generated code didn't violate
         // Rust coding conventions
         @ast::item { ident: name,
@@ -754,7 +754,7 @@ impl AstBuilder for @ExtCtxt {
     }
 
     fn item_mod(&self, span: span, name: ident,
-                attrs: ~[ast::attribute],
+                attrs: ~[ast::Attribute],
                 vi: ~[ast::view_item],
                 items: ~[@ast::item]) -> @ast::item {
         self.item(
@@ -777,23 +777,22 @@ impl AstBuilder for @ExtCtxt {
         self.item_ty_poly(span, name, ty, ast_util::empty_generics())
     }
 
-    fn attribute(&self, sp: span, mi: @ast::meta_item) -> ast::attribute {
-        respan(sp,
-               ast::attribute_ {
-                   style: ast::attr_outer,
-                   value: mi,
-                   is_sugared_doc: false
-               })
+    fn attribute(&self, sp: span, mi: @ast::MetaItem) -> ast::Attribute {
+        respan(sp, ast::Attribute_ {
+            style: ast::AttrOuter,
+            value: mi,
+            is_sugared_doc: false,
+        })
     }
 
-    fn meta_word(&self, sp: span, w: @str) -> @ast::meta_item {
-        @respan(sp, ast::meta_word(w))
+    fn meta_word(&self, sp: span, w: @str) -> @ast::MetaItem {
+        @respan(sp, ast::MetaWord(w))
     }
-    fn meta_list(&self, sp: span, name: @str, mis: ~[@ast::meta_item]) -> @ast::meta_item {
-        @respan(sp, ast::meta_list(name, mis))
+    fn meta_list(&self, sp: span, name: @str, mis: ~[@ast::MetaItem]) -> @ast::MetaItem {
+        @respan(sp, ast::MetaList(name, mis))
     }
-    fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::meta_item {
-        @respan(sp, ast::meta_name_value(name, respan(sp, value)))
+    fn meta_name_value(&self, sp: span, name: @str, value: ast::lit_) -> @ast::MetaItem {
+        @respan(sp, ast::MetaNameValue(name, respan(sp, value)))
     }
 
     fn view_use(&self, sp: span,
diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs
index edaf2b8cae6..02dcb2cdbc9 100644
--- a/src/libsyntax/ext/deriving/clone.rs
+++ b/src/libsyntax/ext/deriving/clone.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -16,7 +16,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_clone(cx: @ExtCtxt,
                              span: span,
-                             mitem: @meta_item,
+                             mitem: @MetaItem,
                              in_items: ~[@item])
                           -> ~[@item] {
     let trait_def = TraitDef {
@@ -40,9 +40,9 @@ pub fn expand_deriving_clone(cx: @ExtCtxt,
 }
 
 pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
-                                 span: span,
-                                 mitem: @meta_item,
-                                 in_items: ~[@item])
+                                  span: span,
+                                  mitem: @MetaItem,
+                                  in_items: ~[@item])
     -> ~[@item] {
     let trait_def = TraitDef {
         path: Path::new(~["std", "clone", "DeepClone"]),
diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs
index cea88bb7bbb..a7d9db59130 100644
--- a/src/libsyntax/ext/deriving/cmp/eq.rs
+++ b/src/libsyntax/ext/deriving/cmp/eq.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -16,7 +16,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_eq(cx: @ExtCtxt,
                           span: span,
-                          mitem: @meta_item,
+                          mitem: @MetaItem,
                           in_items: ~[@item]) -> ~[@item] {
     // structures are equal if all fields are equal, and non equal, if
     // any fields are not equal or if the enum variants are different
diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs
index 3b9691cd42c..d532eedd291 100644
--- a/src/libsyntax/ext/deriving/cmp/ord.rs
+++ b/src/libsyntax/ext/deriving/cmp/ord.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use ast;
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -17,7 +17,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_ord(cx: @ExtCtxt,
                            span: span,
-                           mitem: @meta_item,
+                           mitem: @MetaItem,
                            in_items: ~[@item]) -> ~[@item] {
     macro_rules! md (
         ($name:expr, $op:expr, $equal:expr) => {
diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs
index 70ac4d3d4c1..8285de1d561 100644
--- a/src/libsyntax/ext/deriving/cmp/totaleq.rs
+++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs
@@ -8,17 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
 use ext::deriving::generic::*;
 
 pub fn expand_deriving_totaleq(cx: @ExtCtxt,
-                          span: span,
-                          mitem: @meta_item,
-                          in_items: ~[@item]) -> ~[@item] {
-
+                               span: span,
+                               mitem: @MetaItem,
+                               in_items: ~[@item]) -> ~[@item] {
     fn cs_equals(cx: @ExtCtxt, span: span, substr: &Substructure) -> @expr {
         cs_and(|cx, span, _, _| cx.expr_bool(span, false),
                cx, span, substr)
diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs
index 84d7320fe1c..01dacdfe453 100644
--- a/src/libsyntax/ext/deriving/cmp/totalord.rs
+++ b/src/libsyntax/ext/deriving/cmp/totalord.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -17,7 +17,7 @@ use std::cmp::{Ordering, Equal, Less, Greater};
 
 pub fn expand_deriving_totalord(cx: @ExtCtxt,
                                 span: span,
-                                mitem: @meta_item,
+                                mitem: @MetaItem,
                                 in_items: ~[@item]) -> ~[@item] {
     let trait_def = TraitDef {
         path: Path::new(~["std", "cmp", "TotalOrd"]),
diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs
index 405f9e3438b..bde0a345b10 100644
--- a/src/libsyntax/ext/deriving/decodable.rs
+++ b/src/libsyntax/ext/deriving/decodable.rs
@@ -16,7 +16,7 @@ encodable.rs for more.
 use std::vec;
 use std::uint;
 
-use ast::{meta_item, item, expr, m_mutbl};
+use ast::{MetaItem, item, expr, m_mutbl};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -24,7 +24,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_decodable(cx: @ExtCtxt,
                                  span: span,
-                                 mitem: @meta_item,
+                                 mitem: @MetaItem,
                                  in_items: ~[@item]) -> ~[@item] {
     let trait_def = TraitDef {
         path: Path::new_(~["extra", "serialize", "Decodable"], None,
diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs
index 5514fd0b6ab..1f969b4e078 100644
--- a/src/libsyntax/ext/deriving/encodable.rs
+++ b/src/libsyntax/ext/deriving/encodable.rs
@@ -75,7 +75,7 @@ would yield functions like:
     }
 */
 
-use ast::{meta_item, item, expr, m_imm, m_mutbl};
+use ast::{MetaItem, item, expr, m_imm, m_mutbl};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -83,7 +83,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_encodable(cx: @ExtCtxt,
                                  span: span,
-                                 mitem: @meta_item,
+                                 mitem: @MetaItem,
                                  in_items: ~[@item]) -> ~[@item] {
     let trait_def = TraitDef {
         path: Path::new_(~["extra", "serialize", "Encodable"], None,
diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs
index a50f4d70f0e..04bbe5ae1d6 100644
--- a/src/libsyntax/ext/deriving/generic.rs
+++ b/src/libsyntax/ext/deriving/generic.rs
@@ -281,7 +281,7 @@ pub type EnumNonMatchFunc<'self> =
 impl<'self> TraitDef<'self> {
     pub fn expand(&self, cx: @ExtCtxt,
                   span: span,
-                  _mitem: @ast::meta_item,
+                  _mitem: @ast::MetaItem,
                   in_items: ~[@ast::item]) -> ~[@ast::item] {
         let mut result = ~[];
         for in_items.iter().advance |item| {
@@ -361,7 +361,8 @@ impl<'self> TraitDef<'self> {
         let doc_attr = cx.attribute(
             span,
             cx.meta_name_value(span,
-                               @"doc", ast::lit_str(@"Automatically derived.")));
+                               @"doc",
+                               ast::lit_str(@"Automatically derived.")));
         cx.item(
             span,
             ::parse::token::special_idents::clownshoes_extensions,
diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs
index be13e103a72..57a4f0899b5 100644
--- a/src/libsyntax/ext/deriving/iter_bytes.rs
+++ b/src/libsyntax/ext/deriving/iter_bytes.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{meta_item, item, expr, and};
+use ast::{MetaItem, item, expr, and};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -17,7 +17,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
                                   span: span,
-                                  mitem: @meta_item,
+                                  mitem: @MetaItem,
                                   in_items: ~[@item]) -> ~[@item] {
     let trait_def = TraitDef {
         path: Path::new(~["std", "to_bytes", "IterBytes"]),
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index 537d9efbb26..cde7dcc5dbe 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -18,7 +18,8 @@ library.
 
 */
 
-use ast::{enum_def, ident, item, Generics, meta_item, struct_def};
+use ast::{enum_def, ident, item, Generics, struct_def};
+use ast::{MetaItem, MetaList, MetaNameValue, MetaWord};
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
 use codemap::span;
@@ -58,26 +59,24 @@ pub type ExpandDerivingEnumDefFn<'self> = &'self fn(@ExtCtxt,
 
 pub fn expand_meta_deriving(cx: @ExtCtxt,
                             _span: span,
-                            mitem: @meta_item,
+                            mitem: @MetaItem,
                             in_items: ~[@item])
                          -> ~[@item] {
-    use ast::{meta_list, meta_name_value, meta_word};
-
     match mitem.node {
-        meta_name_value(_, ref l) => {
+        MetaNameValue(_, ref l) => {
             cx.span_err(l.span, "unexpected value in `deriving`");
             in_items
         }
-        meta_word(_) | meta_list(_, []) => {
+        MetaWord(_) | MetaList(_, []) => {
             cx.span_warn(mitem.span, "empty trait list in `deriving`");
             in_items
         }
-        meta_list(_, ref titems) => {
+        MetaList(_, ref titems) => {
             do titems.rev_iter().fold(in_items) |in_items, &titem| {
                 match titem.node {
-                    meta_name_value(tname, _) |
-                    meta_list(tname, _) |
-                    meta_word(tname) => {
+                    MetaNameValue(tname, _) |
+                    MetaList(tname, _) |
+                    MetaWord(tname) => {
                         macro_rules! expand(($func:path) => ($func(cx, titem.span,
                                                                    titem, in_items)));
                         match tname.as_slice() {
diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs
index 823f21401ca..2966a8c114d 100644
--- a/src/libsyntax/ext/deriving/rand.rs
+++ b/src/libsyntax/ext/deriving/rand.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use ast;
-use ast::{meta_item, item, expr, ident};
+use ast::{MetaItem, item, expr, ident};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::{AstBuilder, Duplicate};
@@ -19,7 +19,7 @@ use std::vec;
 
 pub fn expand_deriving_rand(cx: @ExtCtxt,
                             span: span,
-                            mitem: @meta_item,
+                            mitem: @MetaItem,
                             in_items: ~[@item])
     -> ~[@item] {
     let trait_def = TraitDef {
diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs
index c9d63d2c416..9b544eb0796 100644
--- a/src/libsyntax/ext/deriving/to_str.rs
+++ b/src/libsyntax/ext/deriving/to_str.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use ast;
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -17,7 +17,7 @@ use ext::deriving::generic::*;
 
 pub fn expand_deriving_to_str(cx: @ExtCtxt,
                               span: span,
-                              mitem: @meta_item,
+                              mitem: @MetaItem,
                               in_items: ~[@item])
     -> ~[@item] {
     let trait_def = TraitDef {
diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs
index 5bee804d582..3c9e842473c 100644
--- a/src/libsyntax/ext/deriving/zero.rs
+++ b/src/libsyntax/ext/deriving/zero.rs
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{meta_item, item, expr};
+use ast::{MetaItem, item, expr};
 use codemap::span;
 use ext::base::ExtCtxt;
 use ext::build::AstBuilder;
@@ -18,7 +18,7 @@ use std::vec;
 
 pub fn expand_deriving_zero(cx: @ExtCtxt,
                             span: span,
-                            mitem: @meta_item,
+                            mitem: @MetaItem,
                             in_items: ~[@item])
     -> ~[@item] {
     let trait_def = TraitDef {
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 2f1d320fef7..e78254f11f5 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -14,6 +14,7 @@ use ast::{illegal_ctxt};
 use ast;
 use ast_util::{new_rename, new_mark, resolve};
 use attr;
+use attr::AttrMetaMethods;
 use codemap;
 use codemap::{span, ExpnInfo, NameAndSpan};
 use ext::base::*;
@@ -126,7 +127,7 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
     // the item into a new set of items.
     let new_items = do vec::flat_map(module_.items) |item| {
         do item.attrs.rev_iter().fold(~[*item]) |items, attr| {
-            let mname = attr::get_attr_name(attr);
+            let mname = attr.name();
 
             match (*extsbox).find(&intern(mname)) {
               Some(@SE(ItemDecorator(dec_fn))) => {
@@ -196,8 +197,8 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
 }
 
 // does this attribute list contain "macro_escape" ?
-pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool {
-    attrs.iter().any(|attr| "macro_escape" == attr::get_attr_name(attr))
+pub fn contains_macro_escape(attrs: &[ast::Attribute]) -> bool {
+    attr::contains_name(attrs, "macro_escape")
 }
 
 // Support for item-position macro invocations, exactly the same
@@ -793,7 +794,7 @@ pub fn new_ident_resolver() ->
 mod test {
     use super::*;
     use ast;
-    use ast::{attribute_, attr_outer, meta_word, empty_ctxt};
+    use ast::{Attribute_, AttrOuter, MetaWord, empty_ctxt};
     use codemap;
     use codemap::spanned;
     use parse;
@@ -883,14 +884,14 @@ mod test {
         assert_eq!(contains_macro_escape (attrs2),false);
     }
 
-    // make a "meta_word" outer attribute with the given name
-    fn make_dummy_attr(s: @str) -> ast::attribute {
+    // make a MetaWord outer attribute with the given name
+    fn make_dummy_attr(s: @str) -> ast::Attribute {
         spanned {
             span:codemap::dummy_sp(),
-            node: attribute_ {
-                style: attr_outer,
+            node: Attribute_ {
+                style: AttrOuter,
                 value: @spanned {
-                    node: meta_word(s),
+                    node: MetaWord(s),
                     span: codemap::dummy_sp(),
                 },
                 is_sugared_doc: false,