about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2015-03-05 04:48:54 +0200
committerEduard Burtescu <edy.burt@gmail.com>2015-03-11 23:39:15 +0200
commit98491827b920884e4ea1182dcacce2a650dde861 (patch)
treeea55dc4ff5b7e7007183f78ca8cb0896957df352 /src
parentf899513a30165946a75ff7f515ab37a226e72172 (diff)
downloadrust-98491827b920884e4ea1182dcacce2a650dde861.tar.gz
rust-98491827b920884e4ea1182dcacce2a650dde861.zip
syntax: move indirection around {Trait,Impl}Item, from within.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/metadata/encoder.rs26
-rw-r--r--src/librustc/middle/astencode.rs8
-rw-r--r--src/librustc/middle/dead.rs4
-rw-r--r--src/librustc/middle/reachable.rs2
-rw-r--r--src/librustc/middle/stability.rs18
-rw-r--r--src/librustc/middle/ty.rs46
-rw-r--r--src/librustc_privacy/lib.rs26
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs26
-rw-r--r--src/librustc_resolve/lib.rs9
-rw-r--r--src/librustc_trans/save/mod.rs10
-rw-r--r--src/librustc_trans/trans/base.rs12
-rw-r--r--src/librustc_trans/trans/inline.rs68
-rw-r--r--src/librustc_trans/trans/meth.rs11
-rw-r--r--src/librustc_typeck/astconv.rs2
-rw-r--r--src/librustc_typeck/check/mod.rs16
-rw-r--r--src/librustc_typeck/check/wf.rs2
-rw-r--r--src/librustc_typeck/coherence/mod.rs2
-rw-r--r--src/librustc_typeck/collect.rs29
-rw-r--r--src/librustdoc/doctree.rs4
-rw-r--r--src/libsyntax/ast.rs12
-rw-r--r--src/libsyntax/ast_map/blocks.rs4
-rw-r--r--src/libsyntax/ast_map/mod.rs52
-rw-r--r--src/libsyntax/ast_util.rs56
-rw-r--r--src/libsyntax/ext/base.rs55
-rw-r--r--src/libsyntax/ext/deriving/generic/mod.rs14
-rw-r--r--src/libsyntax/ext/expand.rs18
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs2
-rw-r--r--src/libsyntax/fold.rs49
-rw-r--r--src/libsyntax/parse/parser.rs26
-rw-r--r--src/libsyntax/print/pprust.rs19
-rw-r--r--src/libsyntax/visit.rs8
31 files changed, 274 insertions, 362 deletions
diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs
index 08263eb8e6a..44c01eba2ce 100644
--- a/src/librustc/metadata/encoder.rs
+++ b/src/librustc/metadata/encoder.rs
@@ -851,7 +851,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
                                    associated_type: &ty::AssociatedType,
                                    impl_path: PathElems,
                                    parent_id: NodeId,
-                                   typedef_opt: Option<P<ast::Typedef>>) {
+                                   typedef_opt: Option<&ast::Typedef>) {
     debug!("encode_info_for_associated_type({:?},{:?})",
            associated_type.def_id,
            token::get_name(associated_type.name));
@@ -873,13 +873,9 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
     let elem = ast_map::PathName(associated_type.name);
     encode_path(rbml_w, impl_path.chain(Some(elem).into_iter()));
 
-    match typedef_opt {
-        None => {}
-        Some(typedef) => {
-            encode_attributes(rbml_w, &typedef.attrs);
-            encode_type(ecx, rbml_w, ty::node_id_to_type(ecx.tcx,
-                                                         typedef.id));
-        }
+    if let Some(typedef) = typedef_opt {
+        encode_attributes(rbml_w, &typedef.attrs);
+        encode_type(ecx, rbml_w, ty::node_id_to_type(ecx.tcx, typedef.id));
     }
 
     rbml_w.end_tag();
@@ -1226,7 +1222,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
         let num_implemented_methods = ast_items.len();
         for (i, &trait_item_def_id) in items.iter().enumerate() {
             let ast_item = if i < num_implemented_methods {
-                Some(&ast_items[i])
+                Some(&*ast_items[i])
             } else {
                 None
             };
@@ -1265,7 +1261,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
                                                     &**associated_type,
                                                     path.clone(),
                                                     item.id,
-                                                    Some((*typedef).clone()))
+                                                    Some(typedef))
                 }
                 (ty::TypeTraitItem(ref associated_type), _) => {
                     encode_info_for_associated_type(ecx,
@@ -1387,7 +1383,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
 
             encode_parent_sort(rbml_w, 't');
 
-            let trait_item = &ms[i];
+            let trait_item = &*ms[i];
             let encode_trait_item = |rbml_w: &mut Encoder| {
                 // If this is a static method, we've already
                 // encoded this.
@@ -1397,15 +1393,15 @@ fn encode_info_for_item(ecx: &EncodeContext,
                     encode_bounds_and_type_for_item(rbml_w, ecx, item_def_id.def_id().local_id());
                 }
             };
-            match trait_item {
-                &ast::RequiredMethod(ref m) => {
+            match *trait_item {
+                ast::RequiredMethod(ref m) => {
                     encode_attributes(rbml_w, &m.attrs);
                     encode_trait_item(rbml_w);
                     encode_item_sort(rbml_w, 'r');
                     encode_method_argument_names(rbml_w, &*m.decl);
                 }
 
-                &ast::ProvidedMethod(ref m) => {
+                ast::ProvidedMethod(ref m) => {
                     encode_attributes(rbml_w, &m.attrs);
                     encode_trait_item(rbml_w);
                     encode_item_sort(rbml_w, 'p');
@@ -1413,7 +1409,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
                     encode_method_argument_names(rbml_w, &*m.pe_fn_decl());
                 }
 
-                &ast::TypeTraitItem(ref associated_type) => {
+                ast::TypeTraitItem(ref associated_type) => {
                     encode_attributes(rbml_w,
                                       &associated_type.attrs);
                     encode_item_sort(rbml_w, 't');
diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs
index 9d712c7c0fc..20b0307f47a 100644
--- a/src/librustc/middle/astencode.rs
+++ b/src/librustc/middle/astencode.rs
@@ -425,9 +425,9 @@ fn simplify_ast(ii: e::InlinedItemRef) -> ast::InlinedItem {
                 }
                 ast::TypeTraitItem(ref associated_type) => {
                     ast::TypeTraitItem(
-                        P(fold::noop_fold_associated_type(
-                            (**associated_type).clone(),
-                            &mut fld)))
+                        fold::noop_fold_associated_type(
+                            (*associated_type).clone(),
+                            &mut fld))
                 }
             })
         }
@@ -441,7 +441,7 @@ fn simplify_ast(ii: e::InlinedItemRef) -> ast::InlinedItem {
                 }
                 ast::TypeImplItem(ref td) => {
                     ast::TypeImplItem(
-                        P(fold::noop_fold_typedef((**td).clone(), &mut fld)))
+                        fold::noop_fold_typedef((*td).clone(), &mut fld))
                 }
             })
         }
diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs
index 2d837ce52b5..37cb23ff4f0 100644
--- a/src/librustc/middle/dead.rs
+++ b/src/librustc/middle/dead.rs
@@ -357,7 +357,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
             }
             ast::ItemImpl(_, _, _, Some(ref _trait_ref), _, ref impl_items) => {
                 for impl_item in impl_items {
-                    match *impl_item {
+                    match **impl_item {
                         ast::MethodImplItem(ref method) => {
                             self.worklist.push(method.id);
                         }
@@ -586,7 +586,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
             ast::ProvidedMethod(ref method) => {
                 visit::walk_block(self, &*method.pe_body())
             }
-            ast::RequiredMethod(_) => {}
+            ast::RequiredMethod(_) |
             ast::TypeTraitItem(_) => {}
         }
     }
diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs
index 45d565ec693..35f904c2ee8 100644
--- a/src/librustc/middle/reachable.rs
+++ b/src/librustc/middle/reachable.rs
@@ -315,7 +315,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
                 match *impl_item {
                     ast::MethodImplItem(ref method) => {
                         let did = self.tcx.map.get_parent_did(search_item);
-                        if method_might_be_inlined(self.tcx, &**method, did) {
+                        if method_might_be_inlined(self.tcx, method, did) {
                             visit::walk_block(self, method.pe_body())
                         }
                     }
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index 3599ba5a0f7..d1a02ff82e5 100644
--- a/src/librustc/middle/stability.rs
+++ b/src/librustc/middle/stability.rs
@@ -22,8 +22,7 @@ use syntax::codemap::{Span, DUMMY_SP};
 use syntax::{attr, visit};
 use syntax::ast;
 use syntax::ast::{Attribute, Block, Crate, DefId, FnDecl, NodeId, Variant};
-use syntax::ast::{Item, RequiredMethod, ProvidedMethod, TraitItem};
-use syntax::ast::{TypeMethod, Method, Generics, StructField, TypeTraitItem};
+use syntax::ast::{Item, TypeMethod, Method, Generics, StructField};
 use syntax::ast_util::is_local;
 use syntax::attr::{Stability, AttrMetaMethods};
 use syntax::visit::{FnKind, FkMethod, Visitor};
@@ -134,19 +133,20 @@ impl<'a, 'v> Visitor<'v> for Annotator<'a> {
         // a stability attribute, so we don't recurse.
     }
 
-    fn visit_trait_item(&mut self, t: &TraitItem) {
+    fn visit_trait_item(&mut self, t: &ast::TraitItem) {
         let (id, attrs, sp) = match *t {
-            RequiredMethod(TypeMethod {id, ref attrs, span, ..}) => (id, attrs, span),
+            ast::RequiredMethod(TypeMethod {id, ref attrs, span, ..}) => (id, attrs, span),
 
             // work around lack of pattern matching for @ types
-            ProvidedMethod(ref method) => {
-                match **method {
+            ast::ProvidedMethod(ref method) => {
+                match *method {
                     Method {ref attrs, id, span, ..} => (id, attrs, span),
                 }
             }
 
-            TypeTraitItem(ref typedef) => (typedef.ty_param.id, &typedef.attrs,
-                                           typedef.ty_param.span),
+            ast::TypeTraitItem(ref typedef) => {
+                (typedef.ty_param.id, &typedef.attrs, typedef.ty_param.span)
+            }
         };
         self.annotate(id, true, attrs, sp, |v| visit::walk_trait_item(v, t), true);
     }
@@ -335,7 +335,7 @@ pub fn check_item(tcx: &ty::ctxt, item: &ast::Item, warn_about_defns: bool,
             let trait_items = ty::trait_items(tcx, trait_did);
 
             for impl_item in impl_items {
-                let (ident, span) = match *impl_item {
+                let (ident, span) = match **impl_item {
                     ast::MethodImplItem(ref method) => {
                         (match method.node {
                             ast::MethDecl(ident, _, _, _, _, _, _, _) => ident,
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 4cb4d343de7..f6920dc52cd 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -5080,39 +5080,23 @@ pub fn provided_source(cx: &ctxt, id: ast::DefId) -> Option<ast::DefId> {
 pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
                                     -> Vec<Rc<Method<'tcx>>> {
     if is_local(id) {
-        match cx.map.find(id.node) {
-            Some(ast_map::NodeItem(item)) => {
-                match item.node {
-                    ItemTrait(_, _, _, ref ms) => {
-                        let (_, p) =
-                            ast_util::split_trait_methods(&ms[..]);
-                        p.iter()
-                         .map(|m| {
-                            match impl_or_trait_item(
-                                    cx,
-                                    ast_util::local_def(m.id)) {
-                                MethodTraitItem(m) => m,
-                                TypeTraitItem(_) => {
-                                    cx.sess.bug("provided_trait_methods(): \
-                                                 split_trait_methods() put \
-                                                 associated types in the \
-                                                 provided method bucket?!")
-                                }
-                            }
-                         }).collect()
-                    }
-                    _ => {
-                        cx.sess.bug(&format!("provided_trait_methods: `{:?}` is \
-                                             not a trait",
-                                            id))
+        if let ItemTrait(_, _, _, ref ms) = cx.map.expect_item(id.node).node {
+            ms.iter().filter_map(|ti| {
+                if let ast::ProvidedMethod(ref m) = **ti {
+                    match impl_or_trait_item(cx, ast_util::local_def(m.id)) {
+                        MethodTraitItem(m) => Some(m),
+                        TypeTraitItem(_) => {
+                            cx.sess.bug("provided_trait_methods(): \
+                                         associated type found from \
+                                         looking up ProvidedMethod?!")
+                        }
                     }
+                } else {
+                    None
                 }
-            }
-            _ => {
-                cx.sess.bug(&format!("provided_trait_methods: `{:?}` is not a \
-                                     trait",
-                                    id))
-            }
+            }).collect()
+        } else {
+            cx.sess.bug(&format!("provided_trait_methods: `{:?}` is not a trait", id))
         }
     } else {
         csearch::get_provided_trait_methods(cx, id)
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index c766b20389e..a979c491995 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -94,7 +94,7 @@ impl<'v> Visitor<'v> for ParentVisitor {
             // private.
             ast::ItemTrait(_, _, _, ref methods) if item.vis != ast::Public => {
                 for m in methods {
-                    match *m {
+                    match **m {
                         ast::ProvidedMethod(ref m) => {
                             self.parents.insert(m.id, item.id);
                         }
@@ -280,7 +280,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
 
                 if public_ty || public_trait {
                     for impl_item in impl_items {
-                        match *impl_item {
+                        match **impl_item {
                             ast::MethodImplItem(ref method) => {
                                 let meth_public =
                                     match method.pe_explicit_self().node {
@@ -301,7 +301,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
             // is public
             ast::ItemTrait(_, _, _, ref methods) if public_first => {
                 for method in methods {
-                    match *method {
+                    match **method {
                         ast::ProvidedMethod(ref m) => {
                             debug!("provided {}", m.id);
                             self.exported_items.insert(m.id);
@@ -1088,7 +1088,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
                                 "visibility qualifiers have no effect on trait \
                                  impls");
                 for impl_item in impl_items {
-                    match *impl_item {
+                    match **impl_item {
                         ast::MethodImplItem(ref m) => {
                             check_inherited(m.span, m.pe_vis(), "");
                         }
@@ -1123,7 +1123,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
 
             ast::ItemTrait(_, _, _, ref methods) => {
                 for m in methods {
-                    match *m {
+                    match **m {
                         ast::ProvidedMethod(ref m) => {
                             check_inherited(m.span, m.pe_vis(),
                                             "unnecessary visibility");
@@ -1165,7 +1165,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
         match item.node {
             ast::ItemImpl(_, _, _, _, _, ref impl_items) => {
                 for impl_item in impl_items {
-                    match *impl_item {
+                    match **impl_item {
                         ast::MethodImplItem(ref m) => {
                             check_inherited(tcx, m.span, m.pe_vis());
                         }
@@ -1188,7 +1188,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
 
             ast::ItemTrait(_, _, _, ref methods) => {
                 for m in methods {
-                    match *m {
+                    match **m {
                         ast::RequiredMethod(..) => {}
                         ast::ProvidedMethod(ref m) => check_inherited(tcx, m.span,
                                                                 m.pe_vis()),
@@ -1352,7 +1352,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
                     trait_ref.is_some() ||
                     impl_items.iter()
                               .any(|impl_item| {
-                                  match *impl_item {
+                                  match **impl_item {
                                       ast::MethodImplItem(ref m) => {
                                           self.exported_items.contains(&m.id)
                                       }
@@ -1369,9 +1369,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
                     match *trait_ref {
                         None => {
                             for impl_item in impl_items {
-                                match *impl_item {
+                                match **impl_item {
                                     ast::MethodImplItem(ref method) => {
-                                        visit::walk_method_helper(self, &**method)
+                                        visit::walk_method_helper(self, method)
                                     }
                                     ast::TypeImplItem(_) => {}
                                 }
@@ -1395,7 +1395,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
 
                             // Those in 3. are warned with this call.
                             for impl_item in impl_items {
-                                match *impl_item {
+                                match **impl_item {
                                     ast::MethodImplItem(..) => {},
                                     ast::TypeImplItem(ref typedef) => {
                                         self.visit_ty(&typedef.typ);
@@ -1409,14 +1409,14 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
                     // methods will be visible as `Public::foo`.
                     let mut found_pub_static = false;
                     for impl_item in impl_items {
-                        match *impl_item {
+                        match **impl_item {
                             ast::MethodImplItem(ref method) => {
                                 if method.pe_explicit_self().node ==
                                         ast::SelfStatic &&
                                         self.exported_items
                                             .contains(&method.id) {
                                     found_pub_static = true;
-                                    visit::walk_method_helper(self, &**method);
+                                    visit::walk_method_helper(self, method);
                                 }
                             }
                             ast::TypeImplItem(_) => {}
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 67e2b409c8e..48fb03e1efb 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -48,7 +48,7 @@ use syntax::ast::UnnamedField;
 use syntax::ast::{Variant, ViewPathGlob, ViewPathList, ViewPathSimple};
 use syntax::ast::{Visibility};
 use syntax::ast;
-use syntax::ast_util::{self, local_def};
+use syntax::ast_util::{self, local_def, PostExpansionMethod};
 use syntax::attr::AttrMetaMethods;
 use syntax::parse::token::{self, special_idents};
 use syntax::codemap::{Span, DUMMY_SP};
@@ -525,28 +525,32 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
 
                 // Add the names of all the items to the trait info.
                 for trait_item in items {
-                    let (name, trait_item_id) = match *trait_item {
+                    let (name, trait_item_id) = match **trait_item {
                         ast::RequiredMethod(_) |
                         ast::ProvidedMethod(_) => {
-                            let ty_m = ast_util::trait_item_to_ty_method(trait_item);
-
-                            let name = ty_m.ident.name;
+                            let (id, name, span) = match **trait_item {
+                                ast::RequiredMethod(ref m) => {
+                                    (m.id, m.ident.name, m.span)
+                                }
+                                ast::ProvidedMethod(ref m) => {
+                                    (m.id, m.pe_ident().name, m.span)
+                                }
+                                _ => unreachable!()
+                            };
 
                             // Add it as a name in the trait module.
-                            let def = DefMethod(local_def(ty_m.id),
+                            let def = DefMethod(local_def(id),
                                                 FromTrait(local_def(item.id)));
 
                             let method_name_bindings =
                                 self.add_child(name,
                                                &module_parent,
                                                ForbidDuplicateTypesAndValues,
-                                               ty_m.span);
+                                               span);
                             // NB: not IMPORTABLE
-                            method_name_bindings.define_value(def,
-                                                              ty_m.span,
-                                                              PUBLIC);
+                            method_name_bindings.define_value(def, span, PUBLIC);
 
-                            (name, local_def(ty_m.id))
+                            (name, local_def(id))
                         }
                         ast::TypeTraitItem(ref associated_type) => {
                             let def = DefAssociatedTy(local_def(item.id),
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index ccca99f8b4e..cb1540e0f4f 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -86,6 +86,7 @@ use syntax::ast_util::{PostExpansionMethod, local_def, walk_pat};
 use syntax::attr::AttrMetaMethods;
 use syntax::ext::mtwt;
 use syntax::parse::token::{self, special_names, special_idents};
+use syntax::ptr::P;
 use syntax::codemap::{self, Span, Pos};
 use syntax::visit::{self, Visitor};
 
@@ -2812,7 +2813,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                         //
                         // FIXME #4951: Do we need a node ID here?
 
-                        let type_parameters = match *trait_item {
+                        let type_parameters = match **trait_item {
                             ast::RequiredMethod(ref ty_m) => {
                                 HasTypeParameters(&ty_m.generics,
                                                   FnSpace,
@@ -3049,7 +3050,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                               generics: &Generics,
                               opt_trait_reference: &Option<TraitRef>,
                               self_type: &Ty,
-                              impl_items: &[ImplItem]) {
+                              impl_items: &[P<ImplItem>]) {
         // If applicable, create a rib for the type parameters.
         self.with_type_parameter_rib(HasTypeParameters(generics,
                                                        TypeSpace,
@@ -3065,7 +3066,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
 
                 this.with_current_self_type(self_type, |this| {
                     for impl_item in impl_items {
-                        match *impl_item {
+                        match **impl_item {
                             MethodImplItem(ref method) => {
                                 // If this is a trait impl, ensure the method
                                 // exists in trait
@@ -3079,7 +3080,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
                                                       FnSpace,
                                                       MethodRibKind);
                                 this.with_type_parameter_rib(type_parameters, |this| {
-                                    visit::walk_method_helper(this, &**method);
+                                    visit::walk_method_helper(this, method);
                                 });
                             }
                             TypeImplItem(ref typedef) => {
diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs
index 3c6cb5f9de9..13e3db4ba75 100644
--- a/src/librustc_trans/save/mod.rs
+++ b/src/librustc_trans/save/mod.rs
@@ -656,7 +656,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
                     type_parameters: &ast::Generics,
                     trait_ref: &Option<ast::TraitRef>,
                     typ: &ast::Ty,
-                    impl_items: &Vec<ast::ImplItem>) {
+                    impl_items: &[P<ast::ImplItem>]) {
         let trait_id = trait_ref.as_ref().and_then(|tr| self.lookup_type_ref(tr.ref_id));
         match typ.node {
             // Common case impl for a struct or something basic.
@@ -698,9 +698,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
 
         self.process_generic_params(type_parameters, item.span, "", item.id);
         for impl_item in impl_items {
-            match *impl_item {
+            match **impl_item {
                 ast::MethodImplItem(ref method) => {
-                    visit::walk_method_helper(self, &**method)
+                    visit::walk_method_helper(self, method)
                 }
                 ast::TypeImplItem(ref typedef) => {
                     visit::walk_ty(self, &*typedef.typ)
@@ -713,7 +713,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
                      item: &ast::Item,
                      generics: &ast::Generics,
                      trait_refs: &OwnedSlice<ast::TyParamBound>,
-                     methods: &Vec<ast::TraitItem>) {
+                     methods: &[P<ast::TraitItem>]) {
         let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id));
         let val = self.span.snippet(item.span);
         let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait);
@@ -1296,7 +1296,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
                                             qualname,
                                             method_type.id);
             }
-            ast::ProvidedMethod(ref method) => self.process_method(&**method),
+            ast::ProvidedMethod(ref method) => self.process_method(method),
             ast::TypeTraitItem(_) => {}
         }
     }
diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs
index f49905613d2..77df121580d 100644
--- a/src/librustc_trans/trans/base.rs
+++ b/src/librustc_trans/trans/base.rs
@@ -1283,7 +1283,7 @@ fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>)
                                   in has_nested_returns")
                 }
                 ast::TypeTraitItem(_) => {
-                    tcx.sess.bug("unexpected variant: type trait item in \
+                    tcx.sess.bug("unexpected variant: associated type trait item in \
                                   has_nested_returns")
                 }
             }
@@ -1299,7 +1299,7 @@ fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>)
                     }
                 }
                 ast::TypeImplItem(_) => {
-                    tcx.sess.bug("unexpected variant: type impl item in \
+                    tcx.sess.bug("unexpected variant: associated type impl item in \
                                   has_nested_returns")
                 }
             }
@@ -2826,18 +2826,18 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                                     method in get_item_val()");
                 }
                 ast::ProvidedMethod(ref m) => {
-                    register_method(ccx, id, &**m)
+                    register_method(ccx, id, m)
                 }
             }
         }
 
         ast_map::NodeImplItem(ii) => {
             match *ii {
-                ast::MethodImplItem(ref m) => register_method(ccx, id, &**m),
+                ast::MethodImplItem(ref m) => register_method(ccx, id, m),
                 ast::TypeImplItem(ref typedef) => {
                     ccx.sess().span_bug(typedef.span,
-                                        "unexpected variant: required impl \
-                                         method in get_item_val()")
+                                        "unexpected variant: associated type \
+                                        in get_item_val()")
                 }
             }
         }
diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs
index 14f92334073..14889190a85 100644
--- a/src/librustc_trans/trans/inline.rs
+++ b/src/librustc_trans/trans/inline.rs
@@ -129,56 +129,54 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId)
              with a non-item parent");
         }
         csearch::FoundAst::Found(&ast::IITraitItem(_, ref trait_item)) => {
-            match *trait_item {
+            let id = match *trait_item {
+                ast::ProvidedMethod(ref mth) => mth.id,
                 ast::RequiredMethod(_) => ccx.sess().bug("found RequiredMethod IITraitItem"),
-                ast::ProvidedMethod(ref mth) => {
-                    ccx.external().borrow_mut().insert(fn_id, Some(mth.id));
-                    ccx.external_srcs().borrow_mut().insert(mth.id, fn_id);
+                ast::TypeTraitItem(_) => ccx.sess().bug("found TypeTraitItem IITraitItem"),
+            };
+            ccx.external().borrow_mut().insert(fn_id, Some(id));
+            ccx.external_srcs().borrow_mut().insert(id, fn_id);
 
-                    ccx.stats().n_inlines.set(ccx.stats().n_inlines.get() + 1);
+            ccx.stats().n_inlines.set(ccx.stats().n_inlines.get() + 1);
 
-                    // If this is a default method, we can't look up the
-                    // impl type. But we aren't going to translate anyways, so
-                    // don't.
-                    local_def(mth.id)
-                }
-                ast::TypeTraitItem(_) => {
-                    ccx.sess().bug("found TypeTraitItem IITraitItem")
-                }
-            }
+            // If this is a default method, we can't look up the
+            // impl type. But we aren't going to translate anyways, so
+            // don't.
+            local_def(id)
         }
         csearch::FoundAst::Found(&ast::IIImplItem(impl_did, ref impl_item)) => {
-            match *impl_item {
+            let (id, monomorphic_method) = match *impl_item {
                 ast::MethodImplItem(ref mth) => {
-                    ccx.external().borrow_mut().insert(fn_id, Some(mth.id));
-                    ccx.external_srcs().borrow_mut().insert(mth.id, fn_id);
-
-                    ccx.stats().n_inlines.set(ccx.stats().n_inlines.get() + 1);
-
                     let impl_tpt = ty::lookup_item_type(ccx.tcx(), impl_did);
                     let unparameterized = impl_tpt.generics.types.is_empty() &&
                             mth.pe_generics().ty_params.is_empty();
 
-                    let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());
-                    if unparameterized {
-                        let llfn = get_item_val(ccx, mth.id);
-                        trans_fn(ccx,
-                                 &*mth.pe_fn_decl(),
-                                 &*mth.pe_body(),
-                                 llfn,
-                                 empty_substs,
-                                 mth.id,
-                                 &[]);
-                        // Use InternalLinkage so LLVM can optimize more
-                        // aggressively.
-                        SetLinkage(llfn, InternalLinkage);
-                    }
-                    local_def(mth.id)
+                    (mth.id, if unparameterized { Some(mth) } else { None })
                 }
                 ast::TypeImplItem(_) => {
                     ccx.sess().bug("found TypeImplItem IIImplItem")
                 }
+            };
+
+            ccx.external().borrow_mut().insert(fn_id, Some(id));
+            ccx.external_srcs().borrow_mut().insert(id, fn_id);
+
+            ccx.stats().n_inlines.set(ccx.stats().n_inlines.get() + 1);
+
+            if let Some(mth) = monomorphic_method {
+                let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty());
+                let llfn = get_item_val(ccx, mth.id);
+                trans_fn(ccx,
+                         &*mth.pe_fn_decl(),
+                         &*mth.pe_body(),
+                         llfn,
+                         empty_substs,
+                         mth.id,
+                         &[]);
+                // Use InternalLinkage so LLVM can optimize more aggressively.
+                SetLinkage(llfn, InternalLinkage);
             }
+            local_def(id)
         }
     };
 
diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs
index 0c82d681eed..8bbd688d63c 100644
--- a/src/librustc_trans/trans/meth.rs
+++ b/src/librustc_trans/trans/meth.rs
@@ -43,6 +43,7 @@ use syntax::parse::token;
 use syntax::{ast, ast_map, attr, visit};
 use syntax::ast_util::PostExpansionMethod;
 use syntax::codemap::DUMMY_SP;
+use syntax::ptr::P;
 
 // drop_glue pointer, size, align.
 const VTABLE_OFFSET: uint = 3;
@@ -53,7 +54,7 @@ const VTABLE_OFFSET: uint = 3;
 /// see `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
 pub fn trans_impl(ccx: &CrateContext,
                   name: ast::Ident,
-                  impl_items: &[ast::ImplItem],
+                  impl_items: &[P<ast::ImplItem>],
                   generics: &ast::Generics,
                   id: ast::NodeId) {
     let _icx = push_ctxt("meth::trans_impl");
@@ -66,9 +67,9 @@ pub fn trans_impl(ccx: &CrateContext,
     if !generics.ty_params.is_empty() {
         let mut v = TransItemVisitor{ ccx: ccx };
         for impl_item in impl_items {
-            match *impl_item {
+            match **impl_item {
                 ast::MethodImplItem(ref method) => {
-                    visit::walk_method_helper(&mut v, &**method);
+                    visit::walk_method_helper(&mut v, method);
                 }
                 ast::TypeImplItem(_) => {}
             }
@@ -76,7 +77,7 @@ pub fn trans_impl(ccx: &CrateContext,
         return;
     }
     for impl_item in impl_items {
-        match *impl_item {
+        match **impl_item {
             ast::MethodImplItem(ref method) => {
                 if method.pe_generics().ty_params.len() == 0 {
                     let trans_everywhere = attr::requests_inline(&method.attrs);
@@ -99,7 +100,7 @@ pub fn trans_impl(ccx: &CrateContext,
                 let mut v = TransItemVisitor {
                     ccx: ccx,
                 };
-                visit::walk_method_helper(&mut v, &**method);
+                visit::walk_method_helper(&mut v, method);
             }
             ast::TypeImplItem(_) => {}
         }
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 2c7a9bf8020..9d364df5553 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -1096,7 +1096,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
         match this.tcx().map.expect_item(trait_did.node).node {
             ast::ItemTrait(_, _, _, ref trait_items) => {
                 trait_items.iter().filter_map(|i| {
-                    if let ast::TypeTraitItem(ref assoc) = *i {
+                    if let ast::TypeTraitItem(ref assoc) = **i {
                         if assoc.ty_param.ident.name == assoc_name {
                             return Some(ast_util::local_def(assoc.ty_param.id));
                         }
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 44500ce0bbb..c625d826713 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -739,9 +739,9 @@ pub fn check_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
           }
 
         for impl_item in impl_items {
-            match *impl_item {
+            match **impl_item {
                 ast::MethodImplItem(ref m) => {
-                    check_method_body(ccx, &impl_pty.generics, &**m);
+                    check_method_body(ccx, &impl_pty.generics, m);
                 }
                 ast::TypeImplItem(_) => {
                     // Nothing to do here.
@@ -754,13 +754,13 @@ pub fn check_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx ast::Item) {
         check_trait_on_unimplemented(ccx, generics, it);
         let trait_def = ty::lookup_trait_def(ccx.tcx, local_def(it.id));
         for trait_method in trait_methods {
-            match *trait_method {
+            match **trait_method {
                 RequiredMethod(..) => {
                     // Nothing to do, since required methods don't have
                     // bodies to check.
                 }
                 ProvidedMethod(ref m) => {
-                    check_method_body(ccx, &trait_def.generics, &**m);
+                    check_method_body(ccx, &trait_def.generics, m);
                 }
                 TypeTraitItem(_) => {
                     // Nothing to do.
@@ -876,7 +876,7 @@ fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
 fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                             impl_span: Span,
                                             impl_trait_ref: &ty::TraitRef<'tcx>,
-                                            impl_items: &[ast::ImplItem]) {
+                                            impl_items: &[P<ast::ImplItem>]) {
     // Locate trait methods
     let tcx = ccx.tcx;
     let trait_items = ty::trait_items(tcx, impl_trait_ref.def_id);
@@ -884,7 +884,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     // Check existing impl methods to see if they are both present in trait
     // and compatible with trait signature
     for impl_item in impl_items {
-        match *impl_item {
+        match **impl_item {
             ast::MethodImplItem(ref impl_method) => {
                 let impl_method_def_id = local_def(impl_method.id);
                 let impl_item_ty = ty::impl_or_trait_item(ccx.tcx,
@@ -978,7 +978,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             ty::MethodTraitItem(ref trait_method) => {
                 let is_implemented =
                     impl_items.iter().any(|ii| {
-                        match *ii {
+                        match **ii {
                             ast::MethodImplItem(ref m) => {
                                 m.pe_ident().name == trait_method.name
                             }
@@ -993,7 +993,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             }
             ty::TypeTraitItem(ref associated_type) => {
                 let is_implemented = impl_items.iter().any(|ii| {
-                    match *ii {
+                    match **ii {
                         ast::TypeImplItem(ref typedef) => {
                             typedef.ident.name == associated_type.name
                         }
diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs
index 32bd40ebda2..6c7c3cf08bc 100644
--- a/src/librustc_typeck/check/wf.rs
+++ b/src/librustc_typeck/check/wf.rs
@@ -501,7 +501,7 @@ impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
     fn visit_trait_item(&mut self, t: &'v ast::TraitItem) {
         match t {
             &ast::TraitItem::ProvidedMethod(_) |
-            &ast::TraitItem::TypeTraitItem(_) => {},
+            &ast::TraitItem::TypeTraitItem(_) => {}
             &ast::TraitItem::RequiredMethod(ref method) => {
                 match ty::impl_or_trait_item(self.tcx(), local_def(method.id)) {
                     ty::ImplOrTraitItem::MethodTraitItem(ty_method) => {
diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs
index a06dcbaf556..b990ba0ab24 100644
--- a/src/librustc_typeck/coherence/mod.rs
+++ b/src/librustc_typeck/coherence/mod.rs
@@ -279,7 +279,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
                 let mut items: Vec<ImplOrTraitItemId> =
                         ast_items.iter()
                                  .map(|ast_item| {
-                            match *ast_item {
+                            match **ast_item {
                                 ast::MethodImplItem(ref ast_method) => {
                                     MethodTraitItemId(
                                         local_def(ast_method.id))
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index bd68802f262..4d98aed8006 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -631,17 +631,16 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             // For each method, construct a suitable ty::Method and
             // store it into the `tcx.impl_or_trait_items` table:
             for trait_item in trait_items {
-                match *trait_item {
+                match **trait_item {
                     ast::RequiredMethod(_) |
                     ast::ProvidedMethod(_) => {
-                        let ty_method = Rc::new(match *trait_item {
+                        let ty_method = Rc::new(match **trait_item {
                             ast::RequiredMethod(ref m) => {
                                 ty_method_of_trait_method(
                                     ccx,
                                     trait_id,
                                     &trait_def.generics,
                                     &trait_predicates,
-                                    &trait_items[..],
                                     &m.id,
                                     &m.ident.name,
                                     &m.explicit_self,
@@ -656,7 +655,6 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                     trait_id,
                                     &trait_def.generics,
                                     &trait_predicates,
-                                    &trait_items[..],
                                     &m.id,
                                     &m.pe_ident().name,
                                     m.pe_explicit_self(),
@@ -702,7 +700,7 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
             // Add an entry mapping
             let trait_item_def_ids =
                 Rc::new(trait_items.iter().map(|ti| {
-                    match *ti {
+                    match **ti {
                         ast::RequiredMethod(ref ty_method) => {
                             ty::MethodTraitItemId(local_def(ty_method.id))
                         }
@@ -736,7 +734,6 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
                                            trait_id: ast::NodeId,
                                            trait_generics: &ty::Generics<'tcx>,
                                            trait_bounds: &ty::GenericPredicates<'tcx>,
-                                           _trait_items: &[ast::TraitItem],
                                            m_id: &ast::NodeId,
                                            m_name: &ast::Name,
                                            m_explicit_self: &ast::ExplicitSelf,
@@ -1016,9 +1013,9 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
 
             let mut methods = Vec::new();
             for impl_item in impl_items {
-                match *impl_item {
+                match **impl_item {
                     ast::MethodImplItem(ref method) => {
-                        methods.push(&**method);
+                        methods.push(method);
                     }
                     ast::TypeImplItem(ref typedef) => {
                         if opt_trait_ref.is_none() {
@@ -1059,7 +1056,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
                             parent_visibility);
 
             for impl_item in impl_items {
-                match *impl_item {
+                match **impl_item {
                     ast::MethodImplItem(ref method) => {
                         let body_id = method.pe_body().id;
                         check_method_self_type(ccx,
@@ -1099,9 +1096,9 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
             let untransformed_rcvr_ty = ty::mk_self_type(tcx);
             convert_methods(ccx,
                             TraitContainer(local_def(it.id)),
-                            trait_items.iter().filter_map(|m| match *m {
+                            trait_items.iter().filter_map(|m| match **m {
                                 ast::RequiredMethod(_) => None,
-                                ast::ProvidedMethod(ref m) => Some(&**m),
+                                ast::ProvidedMethod(ref m) => Some(m),
                                 ast::TypeTraitItem(_) => None,
                             }),
                             untransformed_rcvr_ty,
@@ -1118,7 +1115,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
             // we have a method type stored for every method.
             for trait_item in trait_items {
                 let self_type = ty::mk_self_type(tcx);
-                match *trait_item {
+                match **trait_item {
                     ast::RequiredMethod(ref type_method) => {
                         let rscope = BindingRscope::new();
                         check_method_self_type(ccx,
@@ -1139,7 +1136,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
                     ast::TypeTraitItem(ref associated_type) => {
                         convert_associated_type(ccx,
                                                 &*trait_def,
-                                                &**associated_type);
+                                                associated_type);
                     }
                 }
             }
@@ -1354,7 +1351,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     let associated_type_names: Vec<_> =
         items.iter()
              .filter_map(|item| {
-                 match *item {
+                 match **item {
                      ast::RequiredMethod(_) | ast::ProvidedMethod(_) => None,
                      ast::TypeTraitItem(ref data) => Some(data.ty_param.ident.name),
                  }
@@ -1484,13 +1481,13 @@ fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &ast::Item)
                                                  ast_generics: &ast::Generics,
                                                  trait_predicates: &ty::GenericPredicates<'tcx>,
                                                  self_trait_ref: &Rc<ty::TraitRef<'tcx>>,
-                                                 trait_items: &[ast::TraitItem])
+                                                 trait_items: &[P<ast::TraitItem>])
                                                  -> Vec<ty::Predicate<'tcx>>
     {
         trait_items
             .iter()
             .flat_map(|trait_item| {
-                let assoc_type_def = match *trait_item {
+                let assoc_type_def = match **trait_item {
                     ast::TypeTraitItem(ref assoc_type) => &assoc_type.ty_param,
                     ast::RequiredMethod(..) | ast::ProvidedMethod(..) => {
                         return vec!().into_iter();
diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs
index 8143926982f..5a4deaa2e72 100644
--- a/src/librustdoc/doctree.rs
+++ b/src/librustdoc/doctree.rs
@@ -174,7 +174,7 @@ pub struct Constant {
 pub struct Trait {
     pub unsafety: ast::Unsafety,
     pub name: Ident,
-    pub items: Vec<ast::TraitItem>, //should be TraitItem
+    pub items: Vec<P<ast::TraitItem>>, //should be TraitItem
     pub generics: ast::Generics,
     pub bounds: Vec<ast::TyParamBound>,
     pub attrs: Vec<ast::Attribute>,
@@ -190,7 +190,7 @@ pub struct Impl {
     pub generics: ast::Generics,
     pub trait_: Option<ast::TraitRef>,
     pub for_: P<ast::Ty>,
-    pub items: Vec<ast::ImplItem>,
+    pub items: Vec<P<ast::ImplItem>>,
     pub attrs: Vec<ast::Attribute>,
     pub whence: Span,
     pub vis: ast::Visibility,
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 550ce3bb8c8..fafcc056ded 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1081,14 +1081,14 @@ pub struct TypeMethod {
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub enum TraitItem {
     RequiredMethod(TypeMethod),
-    ProvidedMethod(P<Method>),
-    TypeTraitItem(P<AssociatedType>),
+    ProvidedMethod(Method),
+    TypeTraitItem(AssociatedType),
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
 pub enum ImplItem {
-    MethodImplItem(P<Method>),
-    TypeImplItem(P<Typedef>),
+    MethodImplItem(Method),
+    TypeImplItem(Typedef),
 }
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@@ -1659,7 +1659,7 @@ pub enum Item_ {
     ItemTrait(Unsafety,
               Generics,
               TyParamBounds,
-              Vec<TraitItem>),
+              Vec<P<TraitItem>>),
 
     // Default trait implementations
     // `impl Trait for ..`
@@ -1669,7 +1669,7 @@ pub enum Item_ {
              Generics,
              Option<TraitRef>, // (optional) trait this impl implements
              P<Ty>, // self
-             Vec<ImplItem>),
+             Vec<P<ImplItem>>),
     /// A macro invocation (which includes macro definition)
     ItemMac(Mac),
 }
diff --git a/src/libsyntax/ast_map/blocks.rs b/src/libsyntax/ast_map/blocks.rs
index 1a537c7a5b8..8d605ea50cd 100644
--- a/src/libsyntax/ast_map/blocks.rs
+++ b/src/libsyntax/ast_map/blocks.rs
@@ -206,12 +206,12 @@ impl<'a> FnLikeNode<'a> {
                 _ => panic!("item FnLikeNode that is not fn-like"),
             },
             ast_map::NodeTraitItem(t) => match *t {
-                ast::ProvidedMethod(ref m) => method(&**m),
+                ast::ProvidedMethod(ref m) => method(m),
                 _ => panic!("trait method FnLikeNode that is not fn-like"),
             },
             ast_map::NodeImplItem(ii) => {
                 match *ii {
-                    ast::MethodImplItem(ref m) => method(&**m),
+                    ast::MethodImplItem(ref m) => method(m),
                     ast::TypeImplItem(_) => {
                         panic!("impl method FnLikeNode that is not fn-like")
                     }
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs
index b96d735d92d..4db6f9bc3c5 100644
--- a/src/libsyntax/ast_map/mod.rs
+++ b/src/libsyntax/ast_map/mod.rs
@@ -14,12 +14,11 @@ use self::MapEntry::*;
 
 use abi;
 use ast::*;
-use ast_util;
+use ast_util::{self, PostExpansionMethod};
 use codemap::{DUMMY_SP, Span, Spanned};
 use fold::Folder;
 use parse::token;
 use print::pprust;
-use ptr::P;
 use visit::{self, Visitor};
 
 use arena::TypedArena;
@@ -741,14 +740,11 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
         match i.node {
             ItemImpl(_, _, _, _, _, ref impl_items) => {
                 for impl_item in impl_items {
-                    match *impl_item {
-                        MethodImplItem(ref m) => {
-                            self.insert(m.id, NodeImplItem(impl_item));
-                        }
-                        TypeImplItem(ref t) => {
-                            self.insert(t.id, NodeImplItem(impl_item));
-                        }
-                    }
+                    let id = match **impl_item {
+                        MethodImplItem(ref m) => m.id,
+                        TypeImplItem(ref t) => t.id,
+                    };
+                    self.insert(id, NodeImplItem(impl_item));
                 }
             }
             ItemEnum(ref enum_definition, _) => {
@@ -778,17 +774,12 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> {
                 }
 
                 for tm in trait_items {
-                    match *tm {
-                        RequiredMethod(ref m) => {
-                            self.insert(m.id, NodeTraitItem(tm));
-                        }
-                        ProvidedMethod(ref m) => {
-                            self.insert(m.id, NodeTraitItem(tm));
-                        }
-                        TypeTraitItem(ref typ) => {
-                            self.insert(typ.ty_param.id, NodeTraitItem(tm));
-                        }
-                    }
+                    let id = match **tm {
+                        RequiredMethod(ref m) => m.id,
+                        ProvidedMethod(ref m) => m.id,
+                        TypeTraitItem(ref typ) => typ.ty_param.id,
+                    };
+                    self.insert(id, NodeTraitItem(tm));
                 }
             }
             _ => {}
@@ -933,7 +924,7 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
             TypeTraitItem(at) => {
                 IITraitItem(
                     fld.fold_ops.new_def_id(d),
-                    TypeTraitItem(P(fld.fold_associated_type((*at).clone()))))
+                    TypeTraitItem(fld.fold_associated_type(at)))
             }
         },
         IIImplItem(d, m) => match m {
@@ -944,7 +935,7 @@ pub fn map_decoded_item<'ast, F: FoldOps>(map: &Map<'ast>,
             }
             TypeImplItem(t) => {
                 IIImplItem(fld.fold_ops.new_def_id(d),
-                           TypeImplItem(P(fld.fold_typedef((*t).clone()))))
+                           TypeImplItem(fld.fold_typedef(t)))
             }
         },
         IIForeign(i) => IIForeign(fld.fold_foreign_item(i))
@@ -1064,7 +1055,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
                     }
                 }
                 TypeImplItem(ref t) => {
-                    format!("typedef {} in {}{}",
+                    format!("assoc type {} in {}{}",
                             token::get_ident(t.ident),
                             map.path_to_string(id),
                             id_str)
@@ -1073,15 +1064,20 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
         }
         Some(NodeTraitItem(ref tm)) => {
             match **tm {
-                RequiredMethod(_) | ProvidedMethod(_) => {
-                    let m = ast_util::trait_item_to_ty_method(&**tm);
-                    format!("method {} in {}{}",
+                RequiredMethod(ref m) => {
+                    format!("required method {} in {}{}",
                             token::get_ident(m.ident),
                             map.path_to_string(id),
                             id_str)
                 }
+                ProvidedMethod(ref m) => {
+                    format!("provided method {} in {}{}",
+                            token::get_ident(m.pe_ident()),
+                            map.path_to_string(id),
+                            id_str)
+                }
                 TypeTraitItem(ref t) => {
-                    format!("type item {} in {}{}",
+                    format!("assoc type {} in {}{}",
                             token::get_ident(t.ty_param.ident),
                             map.path_to_string(id),
                             id_str)
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 26d7562cdb2..a8804b595d4 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -268,62 +268,6 @@ pub fn impl_pretty_name(trait_ref: &Option<TraitRef>, ty: Option<&Ty>) -> Ident
     token::gensym_ident(&pretty[..])
 }
 
-pub fn trait_method_to_ty_method(method: &Method) -> TypeMethod {
-    match method.node {
-        MethDecl(ident,
-                 ref generics,
-                 abi,
-                 ref explicit_self,
-                 unsafety,
-                 ref decl,
-                 _,
-                 vis) => {
-            TypeMethod {
-                ident: ident,
-                attrs: method.attrs.clone(),
-                unsafety: unsafety,
-                decl: (*decl).clone(),
-                generics: generics.clone(),
-                explicit_self: (*explicit_self).clone(),
-                id: method.id,
-                span: method.span,
-                vis: vis,
-                abi: abi,
-            }
-        },
-        MethMac(_) => panic!("expected non-macro method declaration")
-    }
-}
-
-/// extract a TypeMethod from a TraitItem. if the TraitItem is
-/// a default, pull out the useful fields to make a TypeMethod
-//
-// NB: to be used only after expansion is complete, and macros are gone.
-pub fn trait_item_to_ty_method(method: &TraitItem) -> TypeMethod {
-    match *method {
-        RequiredMethod(ref m) => (*m).clone(),
-        ProvidedMethod(ref m) => trait_method_to_ty_method(&**m),
-        TypeTraitItem(_) => {
-            panic!("trait_method_to_ty_method(): expected method but found \
-                   typedef")
-        }
-    }
-}
-
-pub fn split_trait_methods(trait_methods: &[TraitItem])
-                           -> (Vec<TypeMethod>, Vec<P<Method>> ) {
-    let mut reqd = Vec::new();
-    let mut provd = Vec::new();
-    for trt_method in trait_methods {
-        match *trt_method {
-            RequiredMethod(ref tm) => reqd.push((*tm).clone()),
-            ProvidedMethod(ref m) => provd.push((*m).clone()),
-            TypeTraitItem(_) => {}
-        }
-    };
-    (reqd, provd)
-}
-
 pub fn struct_field_visibility(field: ast::StructField) -> Visibility {
     match field.node.kind {
         ast::NamedField(_, v) | ast::UnnamedField(v) => v
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 8aeafe419da..b999680ff1a 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -86,42 +86,37 @@ impl Annotatable {
         match *self {
             Annotatable::Item(ref i) => &i.attrs,
             Annotatable::TraitItem(ref i) => match *i {
-                ast::TraitItem::RequiredMethod(ref tm) => &tm.attrs,
-                ast::TraitItem::ProvidedMethod(ref m) => &m.attrs,
-                ast::TraitItem::TypeTraitItem(ref at) => &at.attrs,
+                ast::RequiredMethod(ref tm) => &tm.attrs,
+                ast::ProvidedMethod(ref m) => &m.attrs,
+                ast::TypeTraitItem(ref at) => &at.attrs,
             },
             Annotatable::ImplItem(ref i) => match *i {
-                ast::ImplItem::MethodImplItem(ref m) => &m.attrs,
-                ast::ImplItem::TypeImplItem(ref t) => &t.attrs,
+                ast::MethodImplItem(ref m) => &m.attrs,
+                ast::TypeImplItem(ref t) => &t.attrs,
             }
         }
     }
 
     pub fn fold_attrs(self, attrs: Vec<ast::Attribute>) -> Annotatable {
         match self {
-            Annotatable::Item(i) => Annotatable::Item(P(ast::Item {
+            Annotatable::Item(i) => Annotatable::Item(i.map(|i| ast::Item {
                 attrs: attrs,
-                ..(*i).clone()
+                ..i
             })),
-            Annotatable::TraitItem(i) => match i {
-                ast::TraitItem::RequiredMethod(tm) => Annotatable::TraitItem(
-                    ast::TraitItem::RequiredMethod(
-                        ast::TypeMethod { attrs: attrs, ..tm })),
-                ast::TraitItem::ProvidedMethod(m) => Annotatable::TraitItem(
-                    ast::TraitItem::ProvidedMethod(P(
-                        ast::Method { attrs: attrs, ..(*m).clone() }))),
-                ast::TraitItem::TypeTraitItem(at) => Annotatable::TraitItem(
-                    ast::TraitItem::TypeTraitItem(P(
-                        ast::AssociatedType { attrs: attrs, ..(*at).clone() }))),
-            },
-            Annotatable::ImplItem(i) => match i {
-                ast::ImplItem::MethodImplItem(m) => Annotatable::ImplItem(
-                    ast::ImplItem::MethodImplItem(P(
-                        ast::Method { attrs: attrs, ..(*m).clone() }))),
-                ast::ImplItem::TypeImplItem(t) => Annotatable::ImplItem(
-                    ast::ImplItem::TypeImplItem(P(
-                        ast::Typedef { attrs: attrs, ..(*t).clone() }))),
-            }
+            Annotatable::TraitItem(i) => Annotatable::TraitItem(match i {
+                ast::RequiredMethod(tm) =>
+                    ast::RequiredMethod(ast::TypeMethod { attrs: attrs, ..tm }),
+                ast::ProvidedMethod(m) =>
+                    ast::ProvidedMethod(ast::Method { attrs: attrs, ..m }),
+                ast::TypeTraitItem(at) =>
+                    ast::TypeTraitItem(ast::AssociatedType { attrs: attrs, ..at }),
+            }),
+            Annotatable::ImplItem(i) => Annotatable::ImplItem(match i {
+                ast::MethodImplItem(m) =>
+                    ast::MethodImplItem(ast::Method { attrs: attrs, ..m }),
+                ast::TypeImplItem(t) =>
+                    ast::TypeImplItem(ast::Typedef { attrs: attrs, ..t }),
+            })
         }
     }
 
@@ -249,7 +244,7 @@ pub trait MacResult {
     }
 
     /// Create zero or more methods.
-    fn make_methods(self: Box<Self>) -> Option<SmallVector<P<ast::Method>>> {
+    fn make_methods(self: Box<Self>) -> Option<SmallVector<ast::Method>> {
         None
     }
 
@@ -295,7 +290,7 @@ make_MacEager! {
     expr: P<ast::Expr>,
     pat: P<ast::Pat>,
     items: SmallVector<P<ast::Item>>,
-    methods: SmallVector<P<ast::Method>>,
+    methods: SmallVector<ast::Method>,
     stmt: P<ast::Stmt>,
 }
 
@@ -308,7 +303,7 @@ impl MacResult for MacEager {
         self.items
     }
 
-    fn make_methods(self: Box<Self>) -> Option<SmallVector<P<ast::Method>>> {
+    fn make_methods(self: Box<Self>) -> Option<SmallVector<ast::Method>> {
         self.methods
     }
 
@@ -397,7 +392,7 @@ impl MacResult for DummyResult {
             Some(SmallVector::zero())
         }
     }
-    fn make_methods(self: Box<DummyResult>) -> Option<SmallVector<P<ast::Method>>> {
+    fn make_methods(self: Box<DummyResult>) -> Option<SmallVector<ast::Method>> {
         if self.expr_only {
             None
         } else {
diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs
index 9cd965a8138..0573289150c 100644
--- a/src/libsyntax/ext/deriving/generic/mod.rs
+++ b/src/libsyntax/ext/deriving/generic/mod.rs
@@ -386,12 +386,12 @@ impl<'a> TraitDef<'a> {
                            cx: &mut ExtCtxt,
                            type_ident: Ident,
                            generics: &Generics,
-                           methods: Vec<P<ast::Method>>) -> P<ast::Item> {
+                           methods: Vec<ast::Method>) -> P<ast::Item> {
         let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
 
         // Transform associated types from `deriving::ty::Ty` into `ast::Typedef`
         let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| {
-            P(ast::Typedef {
+            ast::Typedef {
                 id: ast::DUMMY_NODE_ID,
                 span: self.span,
                 ident: ident,
@@ -402,7 +402,7 @@ impl<'a> TraitDef<'a> {
                     type_ident,
                     generics
                 ),
-            })
+            }
         });
 
         let Generics { mut lifetimes, ty_params, mut where_clause } =
@@ -517,7 +517,7 @@ impl<'a> TraitDef<'a> {
                                      associated_types.map(|type_| {
                                          ast::TypeImplItem(type_)
                                      })
-                                 ).collect()))
+                                 ).map(P).collect()))
     }
 
     fn expand_struct_def(&self,
@@ -702,7 +702,7 @@ impl<'a> MethodDef<'a> {
                      abi: Abi,
                      explicit_self: ast::ExplicitSelf,
                      arg_types: Vec<(Ident, P<ast::Ty>)> ,
-                     body: P<Expr>) -> P<ast::Method> {
+                     body: P<Expr>) -> ast::Method {
         // create the generics that aren't for Self
         let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics);
 
@@ -725,7 +725,7 @@ impl<'a> MethodDef<'a> {
         let body_block = cx.block_expr(body);
 
         // Create the method.
-        P(ast::Method {
+        ast::Method {
             attrs: self.attributes.clone(),
             id: ast::DUMMY_NODE_ID,
             span: trait_.span,
@@ -737,7 +737,7 @@ impl<'a> MethodDef<'a> {
                                 fn_decl,
                                 body_block,
                                 ast::Inherited)
-        })
+        }
     }
 
     /// ```
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 98c7aefcd8a..96859b94f1d 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -1185,7 +1185,7 @@ fn expand_annotatable(a: Annotatable,
             }
             ast::TraitItem::TypeTraitItem(t) => {
                 SmallVector::one(Annotatable::TraitItem(
-                    ast::TraitItem::TypeTraitItem(P(fld.fold_associated_type((*t).clone())))))
+                    ast::TraitItem::TypeTraitItem(fld.fold_associated_type(t))))
             }
         },
         Annotatable::ImplItem(it) => match it {
@@ -1195,7 +1195,7 @@ fn expand_annotatable(a: Annotatable,
             }
             ast::ImplItem::TypeImplItem(t) => {
                 SmallVector::one(Annotatable::ImplItem(
-                    ast::ImplItem::TypeImplItem(P(fld.fold_typedef((*t).clone())))))
+                    ast::ImplItem::TypeImplItem(fld.fold_typedef(t))))
             }
         }
     };
@@ -1293,8 +1293,8 @@ fn expand_item_multi_modifier(mut it: Annotatable,
 }
 
 // expand a method
-fn expand_method(m: P<ast::Method>, fld: &mut MacroExpander) -> SmallVector<P<ast::Method>> {
-    m.and_then(|m| match m.node {
+fn expand_method(m: ast::Method, fld: &mut MacroExpander) -> SmallVector<ast::Method> {
+    match m.node {
         ast::MethDecl(ident,
                       generics,
                       abi,
@@ -1306,7 +1306,7 @@ fn expand_method(m: P<ast::Method>, fld: &mut MacroExpander) -> SmallVector<P<as
             let id = fld.new_id(m.id);
             let (rewritten_fn_decl, rewritten_body)
                 = expand_and_rename_fn_decl_and_block(decl, body, fld);
-            SmallVector::one(P(ast::Method {
+            SmallVector::one(ast::Method {
                     attrs: fold::fold_attrs(m.attrs, fld),
                     id: id,
                     span: fld.new_span(m.span),
@@ -1318,7 +1318,7 @@ fn expand_method(m: P<ast::Method>, fld: &mut MacroExpander) -> SmallVector<P<as
                                         rewritten_fn_decl,
                                         rewritten_body,
                                         vis)
-                }))
+                })
         },
         ast::MethMac(mac) => {
             let maybe_new_methods =
@@ -1339,7 +1339,7 @@ fn expand_method(m: P<ast::Method>, fld: &mut MacroExpander) -> SmallVector<P<as
                 None => SmallVector::zero()
             }
         }
-    })
+    }
 }
 
 /// Given a fn_decl and a block and a MacroExpander, expand the fn_decl, then use the
@@ -1418,7 +1418,7 @@ impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
         expand_impl_item(i, self)
     }
 
-    fn fold_method(&mut self, method: P<ast::Method>) -> SmallVector<P<ast::Method>> {
+    fn fold_method(&mut self, method: ast::Method) -> SmallVector<ast::Method> {
         expand_method(method, self)
     }
 
@@ -1565,7 +1565,7 @@ fn mark_item(expr: P<ast::Item>, m: Mrk) -> P<ast::Item> {
 }
 
 // apply a given mark to the given item. Used following the expansion of a macro.
-fn mark_method(expr: P<ast::Method>, m: Mrk) -> P<ast::Method> {
+fn mark_method(expr: ast::Method, m: Mrk) -> ast::Method {
     Marker{mark:m}.fold_method(expr)
         .expect_one("marking an item didn't return exactly one method")
 }
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 644c6cd7e28..dcdfad4632d 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -82,7 +82,7 @@ impl<'a> MacResult for ParserAnyMacro<'a> {
         Some(ret)
     }
 
-    fn make_methods(self: Box<ParserAnyMacro<'a>>) -> Option<SmallVector<P<ast::Method>>> {
+    fn make_methods(self: Box<ParserAnyMacro<'a>>) -> Option<SmallVector<ast::Method>> {
         let mut ret = SmallVector::zero();
         loop {
             let mut parser = self.parser.borrow_mut();
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 959e3bdb314..5109a19fdb6 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -98,11 +98,11 @@ pub trait Folder : Sized {
         noop_fold_item_underscore(i, self)
     }
 
-    fn fold_trait_item(&mut self, i: TraitItem) -> SmallVector<TraitItem> {
+    fn fold_trait_item(&mut self, i: P<TraitItem>) -> SmallVector<P<TraitItem>> {
         noop_fold_trait_item(i, self)
     }
 
-    fn fold_impl_item(&mut self, i: ImplItem) -> SmallVector<ImplItem> {
+    fn fold_impl_item(&mut self, i: P<ImplItem>) -> SmallVector<P<ImplItem>> {
         noop_fold_impl_item(i, self)
     }
 
@@ -114,7 +114,7 @@ pub trait Folder : Sized {
         noop_fold_type_method(m, self)
     }
 
-    fn fold_method(&mut self, m: P<Method>) -> SmallVector<P<Method>> {
+    fn fold_method(&mut self, m: Method) -> SmallVector<Method> {
         noop_fold_method(m, self)
     }
 
@@ -1018,34 +1018,30 @@ pub fn noop_fold_item_underscore<T: Folder>(i: Item_, folder: &mut T) -> Item_ {
     }
 }
 
-pub fn noop_fold_trait_item<T: Folder>(i: TraitItem, folder: &mut T) -> SmallVector<TraitItem> {
-    match i {
-        RequiredMethod(m) => {
-                SmallVector::one(RequiredMethod(
-                        folder.fold_type_method(m)))
-        }
+pub fn noop_fold_trait_item<T: Folder>(i: P<TraitItem>, folder: &mut T)
+                                       -> SmallVector<P<TraitItem>> {
+    i.map(|i| SmallVector::one(P(match i {
+        RequiredMethod(m) => RequiredMethod(folder.fold_type_method(m)),
         ProvidedMethod(method) => {
-            folder.fold_method(method).into_iter()
-                .map(|m| ProvidedMethod(m)).collect()
+            return folder.fold_method(method).into_iter()
+                         .map(|m| P(ProvidedMethod(m))).collect();
         }
         TypeTraitItem(at) => {
-            SmallVector::one(TypeTraitItem(P(
-                        folder.fold_associated_type(
-                            (*at).clone()))))
+            TypeTraitItem(folder.fold_associated_type(at))
         }
-    }
+    })))
 }
 
-pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T) -> SmallVector<ImplItem> {
-    match i {
-        MethodImplItem(ref x) => {
-            folder.fold_method((*x).clone()).into_iter().map(|m| MethodImplItem(m)).collect()
+pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T)
+                                      -> SmallVector<P<ImplItem>> {
+    i.and_then(|i| match i {
+        MethodImplItem(x) => {
+            folder.fold_method(x).into_iter().map(|m| P(MethodImplItem(m))).collect()
         }
-        TypeImplItem(ref t) => {
-            SmallVector::one(TypeImplItem(
-                    P(folder.fold_typedef((**t).clone()))))
+        TypeImplItem(t) => {
+            SmallVector::one(TypeImplItem(folder.fold_typedef(t)))
         }
-    }
+    })
 }
 
 pub fn noop_fold_type_method<T: Folder>(m: TypeMethod, fld: &mut T) -> TypeMethod {
@@ -1173,8 +1169,9 @@ pub fn noop_fold_foreign_item<T: Folder>(ni: P<ForeignItem>, folder: &mut T) ->
 
 // Default fold over a method.
 // Invariant: produces exactly one method.
-pub fn noop_fold_method<T: Folder>(m: P<Method>, folder: &mut T) -> SmallVector<P<Method>> {
-    SmallVector::one(m.map(|Method {id, attrs, node, span}| Method {
+pub fn noop_fold_method<T: Folder>(Method {id, attrs, node, span}: Method, folder: &mut T)
+                                   -> SmallVector<Method> {
+    SmallVector::one(Method {
         id: folder.new_id(id),
         attrs: fold_attrs(attrs, folder),
         node: match node {
@@ -1198,7 +1195,7 @@ pub fn noop_fold_method<T: Folder>(m: P<Method>, folder: &mut T) -> SmallVector<
             MethMac(mac) => MethMac(folder.fold_mac(mac)),
         },
         span: folder.new_span(span)
-    }))
+    })
 }
 
 pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 28d757e9be9..63c0f4e1cfa 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1307,7 +1307,7 @@ impl<'a> Parser<'a> {
     }
 
     /// Parse the items in a trait declaration
-    pub fn parse_trait_items(&mut self) -> Vec<TraitItem> {
+    pub fn parse_trait_items(&mut self) -> Vec<P<TraitItem>> {
         self.parse_unspanned_seq(
             &token::OpenDelim(token::Brace),
             &token::CloseDelim(token::Brace),
@@ -1316,7 +1316,7 @@ impl<'a> Parser<'a> {
             let attrs = p.parse_outer_attributes();
 
             if p.eat_keyword(keywords::Type) {
-                TypeTraitItem(P(p.parse_associated_type(attrs)))
+                P(TypeTraitItem(p.parse_associated_type(attrs)))
             } else {
                 let lo = p.span.lo;
 
@@ -1346,7 +1346,7 @@ impl<'a> Parser<'a> {
                   token::Semi => {
                     p.bump();
                     debug!("parse_trait_methods(): parsing required method");
-                    RequiredMethod(TypeMethod {
+                    P(RequiredMethod(TypeMethod {
                         ident: ident,
                         attrs: attrs,
                         unsafety: style,
@@ -1357,7 +1357,7 @@ impl<'a> Parser<'a> {
                         id: ast::DUMMY_NODE_ID,
                         span: mk_sp(lo, hi),
                         vis: vis,
-                    })
+                    }))
                   }
                   token::OpenDelim(token::Brace) => {
                     debug!("parse_trait_methods(): parsing provided method");
@@ -1365,7 +1365,7 @@ impl<'a> Parser<'a> {
                         p.parse_inner_attrs_and_block();
                     let mut attrs = attrs;
                     attrs.push_all(&inner_attrs[..]);
-                    ProvidedMethod(P(ast::Method {
+                    P(ProvidedMethod(ast::Method {
                         attrs: attrs,
                         id: ast::DUMMY_NODE_ID,
                         span: mk_sp(lo, hi),
@@ -4692,7 +4692,7 @@ impl<'a> Parser<'a> {
     }
 
     /// Parse a method in a trait impl
-    pub fn parse_method_with_outer_attributes(&mut self) -> P<Method> {
+    pub fn parse_method_with_outer_attributes(&mut self) -> Method {
         let attrs = self.parse_outer_attributes();
         let visa = self.parse_visibility();
         self.parse_method(attrs, visa)
@@ -4713,7 +4713,7 @@ impl<'a> Parser<'a> {
     pub fn parse_method(&mut self,
                         attrs: Vec<Attribute>,
                         visa: Visibility)
-                        -> P<Method> {
+                        -> Method {
         let lo = self.span.lo;
 
         // code copied from parse_macro_use_or_failure... abstraction!
@@ -4772,12 +4772,12 @@ impl<'a> Parser<'a> {
                  body_span.hi, new_attrs)
             }
         };
-        P(ast::Method {
+        ast::Method {
             attrs: new_attrs,
             id: ast::DUMMY_NODE_ID,
             span: mk_sp(lo, hi),
             node: method_,
-        })
+        }
     }
 
     /// Parse trait Foo { ... }
@@ -4808,7 +4808,7 @@ impl<'a> Parser<'a> {
         (ident, ItemTrait(unsafety, tps, bounds, meths), None)
     }
 
-    fn parse_impl_items(&mut self) -> (Vec<ImplItem>, Vec<Attribute>) {
+    fn parse_impl_items(&mut self) -> (Vec<P<ImplItem>>, Vec<Attribute>) {
         let mut impl_items = Vec::new();
         self.expect(&token::OpenDelim(token::Brace));
         let (inner_attrs, mut method_attrs) =
@@ -4821,13 +4821,13 @@ impl<'a> Parser<'a> {
 
             let vis = self.parse_visibility();
             if self.eat_keyword(keywords::Type) {
-                impl_items.push(TypeImplItem(P(self.parse_typedef(
+                impl_items.push(P(TypeImplItem(self.parse_typedef(
                             method_attrs,
                             vis))))
             } else {
-                impl_items.push(MethodImplItem(self.parse_method(
+                impl_items.push(P(MethodImplItem(self.parse_method(
                             method_attrs,
-                            vis)));
+                            vis))));
             }
             method_attrs = vec![];
         }
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 883c2295a36..863c000dd40 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -12,8 +12,7 @@ pub use self::AnnNode::*;
 
 use abi;
 use ast;
-use ast::{MethodImplItem, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
-use ast::{RequiredMethod, ProvidedMethod, TypeImplItem, TypeTraitItem};
+use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
 use ast_util;
 use attr;
 use owned_slice::OwnedSlice;
@@ -977,12 +976,12 @@ impl<'a> State<'a> {
                 try!(self.bopen());
                 try!(self.print_inner_attributes(&item.attrs));
                 for impl_item in impl_items {
-                    match *impl_item {
+                    match **impl_item {
                         ast::MethodImplItem(ref meth) => {
-                            try!(self.print_method(&**meth));
+                            try!(self.print_method(meth));
                         }
                         ast::TypeImplItem(ref typ) => {
-                            try!(self.print_typedef(&**typ));
+                            try!(self.print_typedef(typ));
                         }
                     }
                 }
@@ -1258,16 +1257,16 @@ impl<'a> State<'a> {
     pub fn print_trait_method(&mut self,
                               m: &ast::TraitItem) -> io::Result<()> {
         match *m {
-            RequiredMethod(ref ty_m) => self.print_ty_method(ty_m),
-            ProvidedMethod(ref m) => self.print_method(&**m),
-            TypeTraitItem(ref t) => self.print_associated_type(&**t),
+            ast::RequiredMethod(ref ty_m) => self.print_ty_method(ty_m),
+            ast::ProvidedMethod(ref m) => self.print_method(m),
+            ast::TypeTraitItem(ref t) => self.print_associated_type(t),
         }
     }
 
     pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> io::Result<()> {
         match *ii {
-            MethodImplItem(ref m) => self.print_method(&**m),
-            TypeImplItem(ref td) => self.print_typedef(&**td),
+            ast::MethodImplItem(ref m) => self.print_method(m),
+            ast::TypeImplItem(ref td) => self.print_typedef(td),
         }
     }
 
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 33d8d56b4b1..4222bd58a07 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -144,7 +144,7 @@ pub fn walk_inlined_item<'v,V>(visitor: &mut V, item: &'v InlinedItem)
         IIForeign(ref i) => visitor.visit_foreign_item(&**i),
         IITraitItem(_, ref ti) => visitor.visit_trait_item(ti),
         IIImplItem(_, MethodImplItem(ref m)) => {
-            walk_method_helper(visitor, &**m)
+            walk_method_helper(visitor, m)
         }
         IIImplItem(_, TypeImplItem(ref typedef)) => {
             visitor.visit_ident(typedef.span, typedef.ident);
@@ -294,9 +294,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
             }
             visitor.visit_ty(&**typ);
             for impl_item in impl_items {
-                match *impl_item {
+                match **impl_item {
                     MethodImplItem(ref method) => {
-                        walk_method_helper(visitor, &**method)
+                        walk_method_helper(visitor, method)
                     }
                     TypeImplItem(ref typedef) => {
                         visitor.visit_ident(typedef.span, typedef.ident);
@@ -678,7 +678,7 @@ pub fn walk_ty_method<'v, V: Visitor<'v>>(visitor: &mut V, method_type: &'v Type
 pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_method: &'v TraitItem) {
     match *trait_method {
         RequiredMethod(ref method_type) => visitor.visit_ty_method(method_type),
-        ProvidedMethod(ref method) => walk_method_helper(visitor, &**method),
+        ProvidedMethod(ref method) => walk_method_helper(visitor, method),
         TypeTraitItem(ref associated_type) => {
             walk_ty_param(visitor, &associated_type.ty_param);
         }