about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-01 07:01:48 -0800
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-01 07:01:48 -0800
commit85fecd0ba77066e604cec9d3866b76edc626b5d3 (patch)
treea375b9e61af4c5e105b58271c9381fdaf58d31b0 /src/libsyntax
parentd2c4b6492dbccc1bb60f163ac583467bc63abce6 (diff)
parenta660bb362ce5a39014fb274367e6361d4deb8a7d (diff)
downloadrust-85fecd0ba77066e604cec9d3866b76edc626b5d3.tar.gz
rust-85fecd0ba77066e604cec9d3866b76edc626b5d3.zip
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs2
-rw-r--r--src/libsyntax/ast_map.rs1
-rw-r--r--src/libsyntax/ast_util.rs2
-rw-r--r--src/libsyntax/ext/auto_encode.rs9
-rw-r--r--src/libsyntax/ext/base.rs5
-rw-r--r--src/libsyntax/ext/concat_idents.rs3
-rw-r--r--src/libsyntax/ext/deriving.rs2
-rw-r--r--src/libsyntax/ext/env.rs7
-rw-r--r--src/libsyntax/ext/expand.rs13
-rw-r--r--src/libsyntax/ext/fmt.rs1
-rw-r--r--src/libsyntax/ext/log_syntax.rs6
-rw-r--r--src/libsyntax/ext/pipes/ast_builder.rs2
-rw-r--r--src/libsyntax/ext/pipes/parse_proto.rs2
-rw-r--r--src/libsyntax/ext/pipes/pipec.rs3
-rw-r--r--src/libsyntax/ext/quote.rs8
-rw-r--r--src/libsyntax/ext/source_util.rs2
-rw-r--r--src/libsyntax/ext/tt/macro_parser.rs2
-rw-r--r--src/libsyntax/fold.rs239
-rw-r--r--src/libsyntax/parse/attr.rs1
-rw-r--r--src/libsyntax/parse/lexer.rs8
-rw-r--r--src/libsyntax/parse/mod.rs4
-rw-r--r--src/libsyntax/parse/prec.rs1
-rw-r--r--src/libsyntax/print/pprust.rs7
-rw-r--r--src/libsyntax/visit.rs1
24 files changed, 188 insertions, 143 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 46ecd96bef1..1053473a3a5 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -162,7 +162,7 @@ pub struct Generics {
     ty_params: OptVec<TyParam>
 }
 
-impl Generics {
+pub impl Generics {
     fn is_empty(&self) -> bool {
         self.lifetimes.len() + self.ty_params.len() == 0
     }
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs
index 88c0363917f..0627e063d97 100644
--- a/src/libsyntax/ast_map.rs
+++ b/src/libsyntax/ast_map.rs
@@ -16,6 +16,7 @@ use ast_util::{inlined_item_utils, path_to_ident, stmt_id};
 use ast_util;
 use attr;
 use codemap;
+use codemap::spanned;
 use diagnostic::span_handler;
 use parse::token::ident_interner;
 use print::pprust;
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index cede82d03dc..7e0cd2640b2 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -13,7 +13,7 @@ use core::prelude::*;
 use ast::*;
 use ast;
 use ast_util;
-use codemap::{span, BytePos, dummy_sp};
+use codemap::{span, BytePos, dummy_sp, spanned};
 use parse::token;
 use visit;
 use opt_vec;
diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs
index 973b2ae2066..8cebe3cd187 100644
--- a/src/libsyntax/ext/auto_encode.rs
+++ b/src/libsyntax/ext/auto_encode.rs
@@ -93,6 +93,7 @@ use core::prelude::*;
 use ast;
 use ast_util;
 use attr;
+use codemap;
 use codemap::span;
 use ext::base::*;
 use parse;
@@ -1310,7 +1311,7 @@ mod test {
     }
 
 
-    fn to_call_log (val: Encodable<TestEncoder>) -> ~[call] {
+    fn to_call_log<E:Encodable<TestEncoder>>(val: E) -> ~[call] {
         let mut te = TestEncoder {call_log: @mut ~[]};
         val.encode(&te);
         copy *te.call_log
@@ -1323,8 +1324,7 @@ mod test {
     }
 
     #[test] fn encode_enum_test () {
-        check_equal (to_call_log(Book(34,44)
-                                 as Encodable::<TestEncoder>),
+        check_equal (to_call_log(Book(34,44)),
                      ~[CallToEmitEnum (~"Written"),
                        CallToEmitEnumVariant (~"Book",0,2),
                        CallToEmitEnumVariantArg (0),
@@ -1339,8 +1339,7 @@ mod test {
     pub struct HasPos { pos : BPos }
 
     #[test] fn encode_newtype_test () {
-        check_equal (to_call_log (HasPos {pos:BPos(48)}
-                                 as Encodable::<TestEncoder>),
+        check_equal (to_call_log (HasPos {pos:BPos(48)}),
                     ~[CallToEmitStruct(~"HasPos",1),
                       CallToEmitField(~"pos",0),
                       CallToEmitUint(48)]);
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index f5a7bbddf99..7d3c7cafa95 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -82,7 +82,7 @@ pub enum SyntaxExtension {
     IdentTT(SyntaxExpanderTTItem),
 }
 
-type SyntaxEnv = @mut MapChain<Name, Transformer>;
+pub type SyntaxEnv = @mut MapChain<Name, Transformer>;
 
 // Name : the domain of SyntaxEnvs
 // want to change these to uints....
@@ -98,7 +98,7 @@ type Name = @~str;
 // toward a more uniform syntax syntax (sorry) where blocks are just
 // another kind of transformer.
 
-enum Transformer {
+pub enum Transformer {
     // this identifier maps to a syntax extension or macro
     SE(SyntaxExtension),
     // should blocks occurring here limit macro scopes?
@@ -494,6 +494,7 @@ mod test {
     use super::*;
     use super::MapChain;
     use util::testing::check_equal;
+    use core::hashmap::linear::LinearMap;
 
     #[test] fn testenv () {
         let mut a = LinearMap::new();
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index d4104c3a14a..4f53bf62efb 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -10,8 +10,11 @@
 
 use core::prelude::*;
 
+use ast;
+use codemap::span;
 use ext::base::*;
 use ext::base;
+use parse::token;
 
 pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
     -> base::MacResult {
diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs
index fc603cdee98..50047d2ce41 100644
--- a/src/libsyntax/ext/deriving.rs
+++ b/src/libsyntax/ext/deriving.rs
@@ -38,7 +38,7 @@ enum Junction {
     Disjunction,
 }
 
-impl Junction {
+pub impl Junction {
     fn to_binop(self) -> binop {
         match self {
             Conjunction => and,
diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs
index 030e819ca3f..91a9de9c051 100644
--- a/src/libsyntax/ext/env.rs
+++ b/src/libsyntax/ext/env.rs
@@ -15,13 +15,14 @@
  * interface.
  */
 
+use prelude::*;
+
+use ast;
+use codemap::span;
 use ext::base::*;
 use ext::base;
 use ext::build::mk_uniq_str;
 
-use core::option;
-use core::os;
-
 pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
     -> base::MacResult {
 
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs
index 105b65c35c9..e3408a47c9a 100644
--- a/src/libsyntax/ext/expand.rs
+++ b/src/libsyntax/ext/expand.rs
@@ -10,13 +10,16 @@
 
 use core::prelude::*;
 
+use ast::{blk_, attribute_, attr_outer, meta_word};
 use ast::{crate, expr_, expr_mac, mac_invoc_tt};
 use ast::{tt_delim, tt_tok, item_mac, stmt_, stmt_mac, stmt_expr, stmt_semi};
 use ast;
 use attr;
-use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan};
+use codemap;
+use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned};
 use ext::base::*;
 use fold::*;
+use parse;
 use parse::{parser, parse_item_from_source_str, new_parser_from_tts};
 
 use core::option;
@@ -184,7 +187,7 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
 }
 
 // does this attribute list contain "macro_escape" ?
-fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{
+pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool{
     let mut accum = false;
     do attrs.each |attr| {
         let mname = attr::get_attr_name(attr);
@@ -490,7 +493,13 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
 #[cfg(test)]
 mod test {
     use super::*;
+    use ast;
+    use ast::{attribute_, attr_outer, meta_word};
+    use codemap;
+    use codemap::spanned;
+    use parse;
     use util::testing::check_equal;
+    use core::option::{None, Some};
 
     // make sure that fail! is present
     #[test] fn fail_exists_test () {
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs
index 2169e8f6f2f..35b11962524 100644
--- a/src/libsyntax/ext/fmt.rs
+++ b/src/libsyntax/ext/fmt.rs
@@ -22,6 +22,7 @@ use ast;
 use codemap::span;
 use ext::base::*;
 use ext::base;
+use ext::build;
 use ext::build::*;
 use private::extfmt::ct::*;
 
diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs
index a59e43b1c1a..368520acd2d 100644
--- a/src/libsyntax/ext/log_syntax.rs
+++ b/src/libsyntax/ext/log_syntax.rs
@@ -8,15 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use prelude::*;
+use core::io::WriterUtil;
+
 use ast;
 use codemap;
 use ext::base::*;
 use ext::base;
 use print;
 
-use core::io::WriterUtil;
-use core::option;
-
 pub fn expand_syntax_ext(cx: ext_ctxt,
                          sp: codemap::span,
                          tt: &[ast::token_tree])
diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs
index 973a4f0a4f0..40d0e2c5db2 100644
--- a/src/libsyntax/ext/pipes/ast_builder.rs
+++ b/src/libsyntax/ext/pipes/ast_builder.rs
@@ -20,7 +20,7 @@ use ast;
 use ast_util::{ident_to_path};
 use ast_util;
 use attr;
-use codemap::{span, respan, dummy_sp};
+use codemap::{span, respan, dummy_sp, spanned};
 use codemap;
 use ext::base::{ext_ctxt, mk_ctxt};
 use ext::quote::rt::*;
diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs
index bdcdf61fc58..a5ca24c6737 100644
--- a/src/libsyntax/ext/pipes/parse_proto.rs
+++ b/src/libsyntax/ext/pipes/parse_proto.rs
@@ -10,7 +10,9 @@
 
 // Parsing pipes protocols from token trees.
 
+use ast_util;
 use ext::pipes::pipec::*;
+use ext::pipes::proto::*;
 use parse::common::SeqSep;
 use parse::parser;
 use parse::token;
diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs
index 7b0f6c1529c..968a0e5f77e 100644
--- a/src/libsyntax/ext/pipes/pipec.rs
+++ b/src/libsyntax/ext/pipes/pipec.rs
@@ -10,8 +10,9 @@
 
 // A protocol compiler for Rust.
 
+use ast;
 use ast::ident;
-use codemap::dummy_sp;
+use codemap::{dummy_sp, spanned};
 use ext::base::ext_ctxt;
 use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
 use ext::pipes::ast_builder::{path_global};
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index e09d7555005..4349ffaea43 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -34,10 +34,12 @@ use core::str;
 
 pub mod rt {
     use ast;
+    use codemap;
     use ext::base::ext_ctxt;
     use parse;
     use print::pprust;
 
+    use core::prelude::*;
     use core::str;
 
     pub use ast::*;
@@ -49,7 +51,7 @@ pub mod rt {
     use print::pprust;
     use print::pprust::{item_to_str, ty_to_str};
 
-    trait ToTokens {
+    pub trait ToTokens {
         pub fn to_tokens(&self, _cx: ext_ctxt) -> ~[token_tree];
     }
 
@@ -73,7 +75,7 @@ pub mod rt {
 
     */
 
-    trait ToSource {
+    pub trait ToSource {
         // Takes a thing and generates a string containing rust code for it.
         pub fn to_source(&self, cx: ext_ctxt) -> ~str;
     }
@@ -164,7 +166,7 @@ pub mod rt {
         }
     }
 
-    trait ExtParseUtils {
+    pub trait ExtParseUtils {
         fn parse_item(s: ~str) -> @ast::item;
         fn parse_expr(s: ~str) -> @ast::expr;
         fn parse_stmt(s: ~str) -> @ast::stmt;
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index f9eb2d7e0af..296305bb62e 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -8,12 +8,14 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use ast;
 use codemap;
 use codemap::{FileMap, Loc, Pos, ExpandedFrom, span};
 use codemap::{CallInfo, NameAndSpan};
 use ext::base::*;
 use ext::base;
 use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str};
+use parse;
 use print::pprust;
 
 use core::io;
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs
index 419c051ea97..fae9e1651d3 100644
--- a/src/libsyntax/ext/tt/macro_parser.rs
+++ b/src/libsyntax/ext/tt/macro_parser.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 // Earley-like parser for macros.
+use ast;
 use ast::{matcher, match_tok, match_seq, match_nonterminal, ident};
 use codemap::{BytePos, mk_sp};
 use codemap;
@@ -23,6 +24,7 @@ use core::dvec::DVec;
 use core::dvec;
 use core::io;
 use core::option;
+use core::option::{Option, Some, None};
 use core::str;
 use core::uint;
 use core::vec;
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 8e1d0d7f3e4..f820669ab1c 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -12,35 +12,36 @@ use core::prelude::*;
 
 use ast::*;
 use ast;
-use codemap::span;
+use codemap::{span, spanned};
+use opt_vec::OptVec;
 
 use core::option;
 use core::vec;
 
 pub trait ast_fold {
-    fn fold_crate(&crate) -> crate;
-    fn fold_view_item(@view_item) -> @view_item;
-    fn fold_foreign_item(@foreign_item) -> @foreign_item;
-    fn fold_item(@item) -> Option<@item>;
-    fn fold_struct_field(@struct_field) -> @struct_field;
-    fn fold_item_underscore(&item_) -> item_;
-    fn fold_method(@method) -> @method;
-    fn fold_block(&blk) -> blk;
-    fn fold_stmt(&stmt) -> @stmt;
-    fn fold_arm(&arm) -> arm;
-    fn fold_pat(@pat) -> @pat;
-    fn fold_decl(@decl) -> @decl;
-    fn fold_expr(@expr) -> @expr;
-    fn fold_ty(@Ty) -> @Ty;
-    fn fold_mod(&_mod) -> _mod;
-    fn fold_foreign_mod(&foreign_mod) -> foreign_mod;
-    fn fold_variant(&variant) -> variant;
-    fn fold_ident(ident) -> ident;
-    fn fold_path(@path) -> @path;
-    fn fold_local(@local) -> @local;
-    fn map_exprs(fn@(@expr) -> @expr, &[@expr]) -> ~[@expr];
-    fn new_id(node_id) -> node_id;
-    fn new_span(span) -> span;
+    fn fold_crate(@self, &crate) -> crate;
+    fn fold_view_item(@self, @view_item) -> @view_item;
+    fn fold_foreign_item(@self, @foreign_item) -> @foreign_item;
+    fn fold_item(@self, @item) -> Option<@item>;
+    fn fold_struct_field(@self, @struct_field) -> @struct_field;
+    fn fold_item_underscore(@self, &item_) -> item_;
+    fn fold_method(@self, @method) -> @method;
+    fn fold_block(@self, &blk) -> blk;
+    fn fold_stmt(@self, &stmt) -> @stmt;
+    fn fold_arm(@self, &arm) -> arm;
+    fn fold_pat(@self, @pat) -> @pat;
+    fn fold_decl(@self, @decl) -> @decl;
+    fn fold_expr(@self, @expr) -> @expr;
+    fn fold_ty(@self, @Ty) -> @Ty;
+    fn fold_mod(@self, &_mod) -> _mod;
+    fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod;
+    fn fold_variant(@self, &variant) -> variant;
+    fn fold_ident(@self, ident) -> ident;
+    fn fold_path(@self, @path) -> @path;
+    fn fold_local(@self, @local) -> @local;
+    fn map_exprs(@self, fn@(@expr) -> @expr, &[@expr]) -> ~[@expr];
+    fn new_id(@self, node_id) -> node_id;
+    fn new_span(@self, span) -> span;
 }
 
 // We may eventually want to be able to fold over type parameters, too
@@ -77,7 +78,7 @@ pub type ast_fold_fns = @AstFoldFns;
 /* some little folds that probably aren't useful to have in ast_fold itself*/
 
 //used in noop_fold_item and noop_fold_crate and noop_fold_crate_directive
-fn fold_meta_item_(mi: @meta_item, fld: ast_fold) -> @meta_item {
+fn fold_meta_item_(mi: @meta_item, fld: @ast_fold) -> @meta_item {
     @spanned {
         node:
             match mi.node {
@@ -96,7 +97,7 @@ fn fold_meta_item_(mi: @meta_item, fld: ast_fold) -> @meta_item {
         span: fld.new_span(mi.span) }
 }
 //used in noop_fold_item and noop_fold_crate
-fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute {
+fn fold_attribute_(at: attribute, fld: @ast_fold) -> attribute {
     spanned {
         node: ast::attribute_ {
             style: at.node.style,
@@ -107,7 +108,7 @@ fn fold_attribute_(at: attribute, fld: ast_fold) -> attribute {
     }
 }
 //used in noop_fold_foreign_item and noop_fold_fn_decl
-fn fold_arg_(a: arg, fld: ast_fold) -> arg {
+fn fold_arg_(a: arg, fld: @ast_fold) -> arg {
     ast::arg {
         mode: a.mode,
         is_mutbl: a.is_mutbl,
@@ -117,14 +118,14 @@ fn fold_arg_(a: arg, fld: ast_fold) -> arg {
     }
 }
 //used in noop_fold_expr, and possibly elsewhere in the future
-fn fold_mac_(m: mac, fld: ast_fold) -> mac {
+fn fold_mac_(m: mac, fld: @ast_fold) -> mac {
     spanned {
         node: match m.node { mac_invoc_tt(*) => copy m.node },
         span: fld.new_span(m.span),
     }
 }
 
-pub fn fold_fn_decl(decl: &ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
+pub fn fold_fn_decl(decl: &ast::fn_decl, fld: @ast_fold) -> ast::fn_decl {
     ast::fn_decl {
         inputs: decl.inputs.map(|x| fold_arg_(*x, fld)),
         output: fld.fold_ty(decl.output),
@@ -132,41 +133,43 @@ pub fn fold_fn_decl(decl: &ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
     }
 }
 
-fn fold_ty_param_bound(tpb: &TyParamBound, fld: ast_fold) -> TyParamBound {
+fn fold_ty_param_bound(tpb: &TyParamBound, fld: @ast_fold) -> TyParamBound {
     match *tpb {
         TraitTyParamBound(ty) => TraitTyParamBound(fld.fold_ty(ty)),
         RegionTyParamBound => RegionTyParamBound
     }
 }
 
-pub fn fold_ty_param(tp: TyParam, fld: ast_fold) -> TyParam {
+pub fn fold_ty_param(tp: TyParam,
+                     fld: @ast_fold) -> TyParam {
     TyParam {ident: tp.ident,
              id: fld.new_id(tp.id),
              bounds: @tp.bounds.map(|x| fold_ty_param_bound(x, fld))}
 }
 
 pub fn fold_ty_params(tps: &OptVec<TyParam>,
-                      fld: ast_fold) -> OptVec<TyParam> {
+                      fld: @ast_fold) -> OptVec<TyParam> {
     tps.map(|tp| fold_ty_param(*tp, fld))
 }
 
-pub fn fold_lifetime(l: &Lifetime, fld: ast_fold) -> Lifetime {
+pub fn fold_lifetime(l: &Lifetime,
+                     fld: @ast_fold) -> Lifetime {
     Lifetime {id: fld.new_id(l.id),
               span: fld.new_span(l.span),
               ident: l.ident}
 }
 
 pub fn fold_lifetimes(lts: &OptVec<Lifetime>,
-                      fld: ast_fold) -> OptVec<Lifetime> {
+                      fld: @ast_fold) -> OptVec<Lifetime> {
     lts.map(|l| fold_lifetime(l, fld))
 }
 
-pub fn fold_generics(generics: &Generics, fld: ast_fold) -> Generics {
+pub fn fold_generics(generics: &Generics, fld: @ast_fold) -> Generics {
     Generics {ty_params: fold_ty_params(&generics.ty_params, fld),
               lifetimes: fold_lifetimes(&generics.lifetimes, fld)}
 }
 
-pub fn noop_fold_crate(c: &crate_, fld: ast_fold) -> crate_ {
+pub fn noop_fold_crate(c: &crate_, fld: @ast_fold) -> crate_ {
     let fold_meta_item = |x| fold_meta_item_(x, fld);
     let fold_attribute = |x| fold_attribute_(x, fld);
 
@@ -177,12 +180,12 @@ pub fn noop_fold_crate(c: &crate_, fld: ast_fold) -> crate_ {
     }
 }
 
-fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
+fn noop_fold_view_item(vi: view_item_, _fld: @ast_fold) -> view_item_ {
     return /* FIXME (#2543) */ copy vi;
 }
 
 
-fn noop_fold_foreign_item(ni: @foreign_item, fld: ast_fold)
+fn noop_fold_foreign_item(ni: @foreign_item, fld: @ast_fold)
     -> @foreign_item {
     let fold_arg = |x| fold_arg_(x, fld);
     let fold_attribute = |x| fold_attribute_(x, fld);
@@ -212,7 +215,7 @@ fn noop_fold_foreign_item(ni: @foreign_item, fld: ast_fold)
     }
 }
 
-pub fn noop_fold_item(i: @item, fld: ast_fold) -> Option<@item> {
+pub fn noop_fold_item(i: @item, fld: @ast_fold) -> Option<@item> {
     let fold_attribute = |x| fold_attribute_(x, fld);
 
     Some(@ast::item { ident: fld.fold_ident(i.ident),
@@ -223,7 +226,7 @@ pub fn noop_fold_item(i: @item, fld: ast_fold) -> Option<@item> {
                       span: fld.new_span(i.span) })
 }
 
-fn noop_fold_struct_field(sf: @struct_field, fld: ast_fold)
+fn noop_fold_struct_field(sf: @struct_field, fld: @ast_fold)
                        -> @struct_field {
     @spanned { node: ast::struct_field_ { kind: copy sf.node.kind,
                                           id: sf.node.id,
@@ -231,7 +234,7 @@ fn noop_fold_struct_field(sf: @struct_field, fld: ast_fold)
                span: sf.span }
 }
 
-pub fn noop_fold_item_underscore(i: &item_, fld: ast_fold) -> item_ {
+pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
     match *i {
         item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)),
         item_fn(ref decl, purity, ref generics, ref body) => {
@@ -295,7 +298,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: ast_fold) -> item_ {
     }
 }
 
-fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
+fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold)
                 -> @ast::struct_def {
     let dtor = do option::map(&struct_def.dtor) |dtor| {
         let dtor_body = fld.fold_block(&dtor.node.body);
@@ -316,14 +319,14 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
     }
 }
 
-fn fold_trait_ref(p: @trait_ref, fld: ast_fold) -> @trait_ref {
+fn fold_trait_ref(p: @trait_ref, fld: @ast_fold) -> @trait_ref {
     @ast::trait_ref {
         path: fld.fold_path(p.path),
         ref_id: fld.new_id(p.ref_id),
     }
 }
 
-fn fold_struct_field(f: @struct_field, fld: ast_fold) -> @struct_field {
+fn fold_struct_field(f: @struct_field, fld: @ast_fold) -> @struct_field {
     @spanned {
         node: ast::struct_field_ {
             kind: copy f.node.kind,
@@ -334,7 +337,7 @@ fn fold_struct_field(f: @struct_field, fld: ast_fold) -> @struct_field {
     }
 }
 
-fn noop_fold_method(m: @method, fld: ast_fold) -> @method {
+fn noop_fold_method(m: @method, fld: @ast_fold) -> @method {
     @ast::method {
         ident: fld.fold_ident(m.ident),
         attrs: /* FIXME (#2543) */ copy m.attrs,
@@ -351,7 +354,7 @@ fn noop_fold_method(m: @method, fld: ast_fold) -> @method {
 }
 
 
-pub fn noop_fold_block(b: &blk_, fld: ast_fold) -> blk_ {
+pub fn noop_fold_block(b: &blk_, fld: @ast_fold) -> blk_ {
     ast::blk_ {
         view_items: b.view_items.map(|x| fld.fold_view_item(*x)),
         stmts: b.stmts.map(|x| fld.fold_stmt(*x)),
@@ -361,7 +364,7 @@ pub fn noop_fold_block(b: &blk_, fld: ast_fold) -> blk_ {
     }
 }
 
-fn noop_fold_stmt(s: &stmt_, fld: ast_fold) -> stmt_ {
+fn noop_fold_stmt(s: &stmt_, fld: @ast_fold) -> stmt_ {
     let fold_mac = |x| fold_mac_(x, fld);
     match *s {
         stmt_decl(d, nid) => stmt_decl(fld.fold_decl(d), fld.new_id(nid)),
@@ -371,7 +374,7 @@ fn noop_fold_stmt(s: &stmt_, fld: ast_fold) -> stmt_ {
     }
 }
 
-fn noop_fold_arm(a: &arm, fld: ast_fold) -> arm {
+fn noop_fold_arm(a: &arm, fld: @ast_fold) -> arm {
     arm {
         pats: a.pats.map(|x| fld.fold_pat(*x)),
         guard: a.guard.map(|x| fld.fold_expr(*x)),
@@ -379,7 +382,7 @@ fn noop_fold_arm(a: &arm, fld: ast_fold) -> arm {
     }
 }
 
-pub fn noop_fold_pat(p: &pat_, fld: ast_fold) -> pat_ {
+pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
     match *p {
         pat_wild => pat_wild,
         pat_ident(binding_mode, pth, ref sub) => {
@@ -431,7 +434,7 @@ pub fn noop_fold_pat(p: &pat_, fld: ast_fold) -> pat_ {
     }
 }
 
-fn noop_fold_decl(d: &decl_, fld: ast_fold) -> decl_ {
+fn noop_fold_decl(d: &decl_, fld: @ast_fold) -> decl_ {
     match *d {
         decl_local(ref ls) => decl_local(ls.map(|x| fld.fold_local(*x))),
         decl_item(it) => {
@@ -446,13 +449,13 @@ fn noop_fold_decl(d: &decl_, fld: ast_fold) -> decl_ {
 pub fn wrap<T>(f: fn@(&T, ast_fold) -> T)
     -> fn@(&T, span, ast_fold) -> (T, span)
 {
-    fn@(x: &T, s: span, fld: ast_fold) -> (T, span) {
+    fn@(x: &T, s: span, fld: @ast_fold) -> (T, span) {
         (f(x, fld), s)
     }
 }
 
-pub fn noop_fold_expr(e: &expr_, fld: ast_fold) -> expr_ {
-    fn fold_field_(field: field, fld: ast_fold) -> field {
+pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
+    fn fold_field_(field: field, fld: @ast_fold) -> field {
         spanned {
             node: ast::field_ {
                 mutbl: field.node.mutbl,
@@ -594,15 +597,15 @@ pub fn noop_fold_expr(e: &expr_, fld: ast_fold) -> expr_ {
     }
 }
 
-pub fn noop_fold_ty(t: &ty_, fld: ast_fold) -> ty_ {
+pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
     let fold_mac = |x| fold_mac_(x, fld);
-    fn fold_mt(mt: &mt, fld: ast_fold) -> mt {
+    fn fold_mt(mt: &mt, fld: @ast_fold) -> mt {
         mt {
             ty: fld.fold_ty(mt.ty),
             mutbl: mt.mutbl,
         }
     }
-    fn fold_field(f: ty_field, fld: ast_fold) -> ty_field {
+    fn fold_field(f: ty_field, fld: @ast_fold) -> ty_field {
         spanned {
             node: ast::ty_field_ {
                 ident: fld.fold_ident(f.node.ident),
@@ -648,14 +651,14 @@ pub fn noop_fold_ty(t: &ty_, fld: ast_fold) -> ty_ {
 }
 
 // ...nor do modules
-pub fn noop_fold_mod(m: &_mod, fld: ast_fold) -> _mod {
+pub fn noop_fold_mod(m: &_mod, fld: @ast_fold) -> _mod {
     ast::_mod {
         view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
         items: vec::filter_mapped(m.items, |x| fld.fold_item(*x)),
     }
 }
 
-fn noop_fold_foreign_mod(nm: &foreign_mod, fld: ast_fold) -> foreign_mod {
+fn noop_fold_foreign_mod(nm: &foreign_mod, fld: @ast_fold) -> foreign_mod {
     ast::foreign_mod {
         sort: nm.sort,
         abi: nm.abi,
@@ -664,8 +667,8 @@ fn noop_fold_foreign_mod(nm: &foreign_mod, fld: ast_fold) -> foreign_mod {
     }
 }
 
-fn noop_fold_variant(v: &variant_, fld: ast_fold) -> variant_ {
-    fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg {
+fn noop_fold_variant(v: &variant_, fld: @ast_fold) -> variant_ {
+    fn fold_variant_arg_(va: variant_arg, fld: @ast_fold) -> variant_arg {
         ast::variant_arg { ty: fld.fold_ty(va.ty), id: fld.new_id(va.id) }
     }
     let fold_variant_arg = |x| fold_variant_arg_(x, fld);
@@ -730,19 +733,21 @@ fn noop_fold_variant(v: &variant_, fld: ast_fold) -> variant_ {
     }
 }
 
-fn noop_fold_ident(i: ident, _fld: ast_fold) -> ident {
+fn noop_fold_ident(i: ident, _fld: @ast_fold) -> ident {
     /* FIXME (#2543) */ copy i
 }
 
-fn noop_fold_path(p: @path, fld: ast_fold) -> path {
-    ast::path { span: fld.new_span(p.span),
-                global: p.global,
-                idents: p.idents.map(|x| fld.fold_ident(*x)),
-                rp: p.rp,
-                types: p.types.map(|x| fld.fold_ty(*x)) }
+fn noop_fold_path(p: @path, fld: @ast_fold) -> path {
+    ast::path {
+        span: fld.new_span(p.span),
+        global: p.global,
+        idents: p.idents.map(|x| fld.fold_ident(*x)),
+        rp: p.rp,
+        types: p.types.map(|x| fld.fold_ty(*x)),
+    }
 }
 
-fn noop_fold_local(l: &local_, fld: ast_fold) -> local_ {
+fn noop_fold_local(l: &local_, fld: @ast_fold) -> local_ {
     local_ {
         is_mutbl: l.is_mutbl,
         ty: fld.fold_ty(l.ty),
@@ -786,73 +791,73 @@ pub fn default_ast_fold() -> ast_fold_fns {
         fold_local: wrap(noop_fold_local),
         map_exprs: noop_map_exprs,
         new_id: noop_id,
-        new_span: noop_span
+        new_span: noop_span,
     }
 }
 
-impl ast_fold for ast_fold_fns {
+impl ast_fold for AstFoldFns {
     /* naturally, a macro to write these would be nice */
-    fn fold_crate(c: &crate) -> crate {
-        let (n, s) = (self.fold_crate)(&c.node, c.span, self as ast_fold);
+    fn fold_crate(@self, c: &crate) -> crate {
+        let (n, s) = (self.fold_crate)(&c.node, c.span, self as @ast_fold);
         spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_view_item(x: @view_item) ->
+    fn fold_view_item(@self, x: @view_item) ->
        @view_item {
         @ast::view_item {
-            node: (self.fold_view_item)(x.node, self as ast_fold),
+            node: (self.fold_view_item)(x.node, self as @ast_fold),
             attrs: vec::map(x.attrs, |a|
-                  fold_attribute_(*a, self as ast_fold)),
+                  fold_attribute_(*a, self as @ast_fold)),
             vis: x.vis,
             span: (self.new_span)(x.span),
         }
     }
-    fn fold_foreign_item(x: @foreign_item) -> @foreign_item {
-        (self.fold_foreign_item)(x, self as ast_fold)
+    fn fold_foreign_item(@self, x: @foreign_item) -> @foreign_item {
+        (self.fold_foreign_item)(x, self as @ast_fold)
     }
-    fn fold_item(i: @item) -> Option<@item> {
-        (self.fold_item)(i, self as ast_fold)
+    fn fold_item(@self, i: @item) -> Option<@item> {
+        (self.fold_item)(i, self as @ast_fold)
     }
-    fn fold_struct_field(sf: @struct_field) -> @struct_field {
+    fn fold_struct_field(@self, sf: @struct_field) -> @struct_field {
         @spanned {
             node: ast::struct_field_ {
                 kind: copy sf.node.kind,
                 id: sf.node.id,
-                ty: (self as ast_fold).fold_ty(sf.node.ty),
+                ty: (self as @ast_fold).fold_ty(sf.node.ty),
             },
             span: (self.new_span)(sf.span),
         }
     }
-    fn fold_item_underscore(i: &item_) -> item_ {
-        (self.fold_item_underscore)(i, self as ast_fold)
+    fn fold_item_underscore(@self, i: &item_) -> item_ {
+        (self.fold_item_underscore)(i, self as @ast_fold)
     }
-    fn fold_method(x: @method) -> @method {
-        (self.fold_method)(x, self as ast_fold)
+    fn fold_method(@self, x: @method) -> @method {
+        (self.fold_method)(x, self as @ast_fold)
     }
-    fn fold_block(x: &blk) -> blk {
-        let (n, s) = (self.fold_block)(&x.node, x.span, self as ast_fold);
+    fn fold_block(@self, x: &blk) -> blk {
+        let (n, s) = (self.fold_block)(&x.node, x.span, self as @ast_fold);
         spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_stmt(x: &stmt) -> @stmt {
-        let (n, s) = (self.fold_stmt)(&x.node, x.span, self as ast_fold);
+    fn fold_stmt(@self, x: &stmt) -> @stmt {
+        let (n, s) = (self.fold_stmt)(&x.node, x.span, self as @ast_fold);
         @spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_arm(x: &arm) -> arm {
-        (self.fold_arm)(x, self as ast_fold)
+    fn fold_arm(@self, x: &arm) -> arm {
+        (self.fold_arm)(x, self as @ast_fold)
     }
-    fn fold_pat(x: @pat) -> @pat {
-        let (n, s) =  (self.fold_pat)(&x.node, x.span, self as ast_fold);
+    fn fold_pat(@self, x: @pat) -> @pat {
+        let (n, s) =  (self.fold_pat)(&x.node, x.span, self as @ast_fold);
         @pat {
             id: (self.new_id)(x.id),
             node: n,
             span: (self.new_span)(s),
         }
     }
-    fn fold_decl(x: @decl) -> @decl {
-        let (n, s) = (self.fold_decl)(&x.node, x.span, self as ast_fold);
+    fn fold_decl(@self, x: @decl) -> @decl {
+        let (n, s) = (self.fold_decl)(&x.node, x.span, self as @ast_fold);
         @spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_expr(x: @expr) -> @expr {
-        let (n, s) = (self.fold_expr)(&x.node, x.span, self as ast_fold);
+    fn fold_expr(@self, x: @expr) -> @expr {
+        let (n, s) = (self.fold_expr)(&x.node, x.span, self as @ast_fold);
         @expr {
             id: (self.new_id)(x.id),
             callee_id: (self.new_id)(x.callee_id),
@@ -860,41 +865,45 @@ impl ast_fold for ast_fold_fns {
             span: (self.new_span)(s),
         }
     }
-    fn fold_ty(x: @Ty) -> @Ty {
-        let (n, s) = (self.fold_ty)(&x.node, x.span, self as ast_fold);
+    fn fold_ty(@self, x: @Ty) -> @Ty {
+        let (n, s) = (self.fold_ty)(&x.node, x.span, self as @ast_fold);
         @Ty {
             id: (self.new_id)(x.id),
             node: n,
             span: (self.new_span)(s),
         }
     }
-    fn fold_mod(x: &_mod) -> _mod {
-        (self.fold_mod)(x, self as ast_fold)
+    fn fold_mod(@self, x: &_mod) -> _mod {
+        (self.fold_mod)(x, self as @ast_fold)
     }
-    fn fold_foreign_mod(x: &foreign_mod) -> foreign_mod {
-        (self.fold_foreign_mod)(x, self as ast_fold)
+    fn fold_foreign_mod(@self, x: &foreign_mod) -> foreign_mod {
+        (self.fold_foreign_mod)(x, self as @ast_fold)
     }
-    fn fold_variant(x: &variant) -> variant {
-        let (n, s) = (self.fold_variant)(&x.node, x.span, self as ast_fold);
+    fn fold_variant(@self, x: &variant) -> variant {
+        let (n, s) = (self.fold_variant)(&x.node, x.span, self as @ast_fold);
         spanned { node: n, span: (self.new_span)(s) }
     }
-    fn fold_ident(x: ident) -> ident {
-        (self.fold_ident)(x, self as ast_fold)
+    fn fold_ident(@self, x: ident) -> ident {
+        (self.fold_ident)(x, self as @ast_fold)
     }
-    fn fold_path(x: @path) -> @path {
-        @(self.fold_path)(x, self as ast_fold)
+    fn fold_path(@self, x: @path) -> @path {
+        @(self.fold_path)(x, self as @ast_fold)
     }
-    fn fold_local(x: @local) -> @local {
-        let (n, s) = (self.fold_local)(&x.node, x.span, self as ast_fold);
+    fn fold_local(@self, x: @local) -> @local {
+        let (n, s) = (self.fold_local)(&x.node, x.span, self as @ast_fold);
         @spanned { node: n, span: (self.new_span)(s) }
     }
-    fn map_exprs(f: fn@(@expr) -> @expr, e: &[@expr]) -> ~[@expr] {
+    fn map_exprs(
+        @self,
+        f: fn@(@expr) -> @expr,
+        e: &[@expr]
+    ) -> ~[@expr] {
         (self.map_exprs)(f, e)
     }
-    fn new_id(node_id: ast::node_id) -> node_id {
+    fn new_id(@self, node_id: ast::node_id) -> node_id {
         (self.new_id)(node_id)
     }
-    fn new_span(span: span) -> span {
+    fn new_span(@self, span: span) -> span {
         (self.new_span)(span)
     }
 }
@@ -906,7 +915,7 @@ pub impl ast_fold {
 }
 
 pub fn make_fold(afp: ast_fold_fns) -> ast_fold {
-    afp as ast_fold
+    afp as @ast_fold
 }
 
 //
diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs
index a52a9f3ba5e..28f84613740 100644
--- a/src/libsyntax/parse/attr.rs
+++ b/src/libsyntax/parse/attr.rs
@@ -15,6 +15,7 @@ use codemap::spanned;
 use codemap::BytePos;
 use parse::common::*; //resolve bug?
 use parse::token;
+use parse::parser::Parser;
 
 use core::either::{Either, Left, Right};
 
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index 2a40b700c11..ed71fa411c6 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -773,10 +773,14 @@ fn consume_whitespace(rdr: @mut StringReader) {
 
 #[cfg(test)]
 pub mod test {
-
     use super::*;
-    use util::interner;
+
+    use ast;
+    use codemap::{BytePos, CodeMap, span};
+    use core::option::None;
     use diagnostic;
+    use parse::token;
+    use util::interner;
     use util::testing::{check_equal, check_equal_ptr};
 
     // represents a testing reader (incl. both reader and interner)
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index 816e4137126..887f064018f 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -299,6 +299,8 @@ mod test {
     use super::*;
     use std::serialize::Encodable;
     use std;
+    use core::io;
+    use core::option::None;
     use core::str;
     use util::testing::*;
 
@@ -314,7 +316,7 @@ mod test {
             @~"fn foo (x : int) { x; }",
             ~[],
             new_parse_sess(None));
-        check_equal(to_json_str(tts as Encodable::<std::json::Encoder>),
+        check_equal(to_json_str(@tts as Encodable::<std::json::Encoder>),
                     ~"[[\"tt_tok\",[,[\"IDENT\",[\"fn\",false]]]],\
                       [\"tt_tok\",[,[\"IDENT\",[\"foo\",false]]]],\
                       [\"tt_delim\",[[[\"tt_tok\",[,[\"LPAREN\",[]]]],\
diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs
index fff222876aa..e2a89d2a28c 100644
--- a/src/libsyntax/parse/prec.rs
+++ b/src/libsyntax/parse/prec.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use ast;
 use ast::*;
 use parse::token::*;
 use parse::token::Token;
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 208ef6fa845..f08b042ad6a 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -2300,11 +2300,14 @@ pub fn print_onceness(s: @ps, o: ast::Onceness) {
 
 #[cfg(test)]
 pub mod test {
+    use super::*;
+
     use ast;
     use ast_util;
+    use codemap;
+    use core::cmp::Eq;
+    use core::option::None;
     use parse;
-    use super::*;
-    //use util;
     use util::testing::check_equal;
 
     fn string_check<T:Eq> (given : &T, expected: &T) {
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index eac16eac9b6..5919271664e 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -16,6 +16,7 @@ use ast_util;
 use codemap::span;
 use parse;
 use opt_vec;
+use opt_vec::OptVec;
 
 use core::option;
 use core::vec;