diff options
| author | Steven Fackler <sfackler@gmail.com> | 2013-12-27 17:17:36 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2013-12-28 21:16:03 -0700 |
| commit | 0607c138caf991c7dbe4fef57a08958a5e7fb621 (patch) | |
| tree | f27a13d037186d1882cba2d85b39c1a7a26f4b7f | |
| parent | b90989a728210d8199cb66f27818906b4a5ed943 (diff) | |
| download | rust-0607c138caf991c7dbe4fef57a08958a5e7fb621.tar.gz rust-0607c138caf991c7dbe4fef57a08958a5e7fb621.zip | |
Stop using @ExtCtxt
35 files changed, 152 insertions, 153 deletions
diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 47ef4b94058..ed899561bc9 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -40,7 +40,7 @@ struct Test { struct TestCtxt { sess: session::Session, path: RefCell<~[ast::Ident]>, - ext_cx: @ExtCtxt, + ext_cx: ExtCtxt, testfns: RefCell<~[Test]>, is_extra: bool, config: ast::CrateConfig, @@ -163,8 +163,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate) config: crate.config.clone(), }; - let ext_cx = cx.ext_cx; - ext_cx.bt_push(ExpnInfo { + cx.ext_cx.bt_push(ExpnInfo { call_site: dummy_sp(), callee: NameAndSpan { name: @"test", @@ -177,7 +176,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate) cx: cx }; let res = fold.fold_crate(crate); - ext_cx.bt_pop(); + cx.ext_cx.bt_pop(); return res; } @@ -313,7 +312,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item { // The synthesized main function which will call the console test runner // with our list of tests - let mainfn = (quote_item!(cx.ext_cx, + let mainfn = (quote_item!(&cx.ext_cx, pub fn main() { #[main]; extra::test::test_main_static(::std::os::args(), TESTS); @@ -377,7 +376,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item { // The vector of test_descs for this crate let test_descs = mk_test_descs(cx); - (quote_item!(cx.ext_cx, + (quote_item!(&cx.ext_cx, pub static TESTS : &'static [self::extra::test::TestDescAndFn] = $test_descs ; @@ -438,24 +437,24 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr { }; let t_expr = if test.bench { - quote_expr!(cx.ext_cx, self::extra::test::StaticBenchFn($fn_expr) ) + quote_expr!(&cx.ext_cx, self::extra::test::StaticBenchFn($fn_expr) ) } else { - quote_expr!(cx.ext_cx, self::extra::test::StaticTestFn($fn_expr) ) + quote_expr!(&cx.ext_cx, self::extra::test::StaticTestFn($fn_expr) ) }; let ignore_expr = if test.ignore { - quote_expr!(cx.ext_cx, true ) + quote_expr!(&cx.ext_cx, true ) } else { - quote_expr!(cx.ext_cx, false ) + quote_expr!(&cx.ext_cx, false ) }; let fail_expr = if test.should_fail { - quote_expr!(cx.ext_cx, true ) + quote_expr!(&cx.ext_cx, true ) } else { - quote_expr!(cx.ext_cx, false ) + quote_expr!(&cx.ext_cx, false ) }; - let e = quote_expr!(cx.ext_cx, + let e = quote_expr!(&cx.ext_cx, self::extra::test::TestDescAndFn { desc: self::extra::test::TestDesc { name: self::extra::test::StaticTestName($name_expr), diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index eb7dbe4e4a8..b8d01f56e4d 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -75,7 +75,7 @@ struct ListenerFn { struct ReadyCtx { sess: session::Session, - ext_cx: @ExtCtxt, + ext_cx: ExtCtxt, path: ~[ast::Ident], fns: ~[ListenerFn] } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index f4b1c7f1f06..fdde336ffa7 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -37,7 +37,7 @@ fn next_state(s: State) -> Option<State> { } } -pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_asm(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index d5a64a5edba..87d09ea3f8e 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -35,7 +35,7 @@ pub struct MacroDef { ext: SyntaxExtension } -pub type ItemDecorator = extern "Rust" fn(@ExtCtxt, +pub type ItemDecorator = extern "Rust" fn(&ExtCtxt, Span, @ast::MetaItem, ~[@ast::item]) @@ -48,7 +48,7 @@ pub struct SyntaxExpanderTT { pub trait SyntaxExpanderTTTrait { fn expand(&self, - ecx: @ExtCtxt, + ecx: &ExtCtxt, span: Span, token_tree: &[ast::token_tree], context: ast::SyntaxContext) @@ -56,7 +56,7 @@ pub trait SyntaxExpanderTTTrait { } pub type SyntaxExpanderTTFunNoCtxt = - extern "Rust" fn(ecx: @ExtCtxt, + extern "Rust" fn(ecx: &ExtCtxt, span: codemap::Span, token_tree: &[ast::token_tree]) -> MacResult; @@ -67,7 +67,7 @@ enum SyntaxExpanderTTExpander { impl SyntaxExpanderTTTrait for SyntaxExpanderTT { fn expand(&self, - ecx: @ExtCtxt, + ecx: &ExtCtxt, span: Span, token_tree: &[ast::token_tree], _: ast::SyntaxContext) @@ -92,7 +92,7 @@ pub struct SyntaxExpanderTTItem { pub trait SyntaxExpanderTTItemTrait { fn expand(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, sp: Span, ident: ast::Ident, token_tree: ~[ast::token_tree], @@ -102,7 +102,7 @@ pub trait SyntaxExpanderTTItemTrait { impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem { fn expand(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, sp: Span, ident: ast::Ident, token_tree: ~[ast::token_tree], @@ -119,7 +119,7 @@ impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem { } } -pub type SyntaxExpanderTTItemFun = extern "Rust" fn(@ExtCtxt, +pub type SyntaxExpanderTTItemFun = extern "Rust" fn(&ExtCtxt, Span, ast::Ident, ~[ast::token_tree], @@ -127,7 +127,7 @@ pub type SyntaxExpanderTTItemFun = extern "Rust" fn(@ExtCtxt, -> MacResult; pub type SyntaxExpanderTTItemFunNoCtxt = - extern "Rust" fn(@ExtCtxt, Span, ast::Ident, ~[ast::token_tree]) + extern "Rust" fn(&ExtCtxt, Span, ast::Ident, ~[ast::token_tree]) -> MacResult; pub trait AnyMacro { @@ -319,8 +319,8 @@ pub struct ExtCtxt { impl ExtCtxt { pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::CrateConfig) - -> @ExtCtxt { - @ExtCtxt { + -> ExtCtxt { + ExtCtxt { parse_sess: parse_sess, cfg: cfg, backtrace: @mut None, @@ -329,7 +329,7 @@ impl ExtCtxt { } } - pub fn expand_expr(@self, mut e: @ast::Expr) -> @ast::Expr { + pub fn expand_expr(&self, mut e: @ast::Expr) -> @ast::Expr { loop { match e.node { ast::ExprMac(..) => { @@ -417,7 +417,7 @@ impl ExtCtxt { } } -pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::Expr, err_msg: &str) -> (@str, ast::StrStyle) { +pub fn expr_to_str(cx: &ExtCtxt, expr: @ast::Expr, err_msg: &str) -> (@str, ast::StrStyle) { match expr.node { ast::ExprLit(l) => match l.node { ast::lit_str(s, style) => (s, style), @@ -427,14 +427,14 @@ pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::Expr, err_msg: &str) -> (@str, ast: } } -pub fn check_zero_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree], +pub fn check_zero_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree], name: &str) { if tts.len() != 0 { cx.span_fatal(sp, format!("{} takes no arguments", name)); } } -pub fn get_single_str_from_tts(cx: @ExtCtxt, +pub fn get_single_str_from_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree], name: &str) @@ -450,7 +450,7 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt, } } -pub fn get_exprs_from_tts(cx: @ExtCtxt, +pub fn get_exprs_from_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> ~[@ast::Expr] { let p = parse::new_parser_from_tts(cx.parse_sess(), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index aa7e0d0eced..007c06938c6 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -15,7 +15,7 @@ use ast_util; use codemap::{Span, respan, dummy_sp}; use ext::base::ExtCtxt; use ext::quote::rt::*; -use fold; +use fold::ast_fold; use opt_vec; use opt_vec::OptVec; @@ -236,7 +236,7 @@ pub trait AstBuilder { vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item; } -impl AstBuilder for @ExtCtxt { +impl<'a> AstBuilder for &'a ExtCtxt { fn path(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path { self.path_all(span, false, strs, opt_vec::Empty, ~[]) } @@ -903,11 +903,11 @@ impl AstBuilder for @ExtCtxt { } } -struct Duplicator { - cx: @ExtCtxt, +struct Duplicator<'a> { + cx: &'a ExtCtxt, } -impl fold::ast_fold for Duplicator { +impl<'a> ast_fold for Duplicator<'a> { fn new_id(&self, _: NodeId) -> NodeId { ast::DUMMY_NODE_ID } @@ -920,14 +920,14 @@ pub trait Duplicate { // These functions just duplicate AST nodes. // - fn duplicate(&self, cx: @ExtCtxt) -> Self; + fn duplicate(&self, cx: &ExtCtxt) -> Self; } impl Duplicate for @ast::Expr { - fn duplicate(&self, cx: @ExtCtxt) -> @ast::Expr { - let folder = @Duplicator { + fn duplicate(&self, cx: &ExtCtxt) -> @ast::Expr { + let folder = Duplicator { cx: cx, - } as @fold::ast_fold; + }; folder.fold_expr(*self) } } diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs index 933f4b33fe3..1ceb2a1668e 100644 --- a/src/libsyntax/ext/bytes.rs +++ b/src/libsyntax/ext/bytes.rs @@ -18,7 +18,7 @@ use ext::build::AstBuilder; use std::char; -pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { +pub fn expand_syntax_ext(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { // Gather all argument expressions let exprs = get_exprs_from_tts(cx, sp, tts); let mut bytes = ~[]; diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index 89e7994530d..2ca8917ed8f 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -25,7 +25,7 @@ use parse; use parse::token; use parse::attr::parser_attr; -pub fn expand_cfg(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { +pub fn expand_cfg(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned()); let mut cfgs = ~[]; diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index 11e316e3e6b..b6a81a8bea5 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -15,7 +15,7 @@ use codemap; use ext::base; use ext::build::AstBuilder; -pub fn expand_syntax_ext(cx: @base::ExtCtxt, +pub fn expand_syntax_ext(cx: &base::ExtCtxt, sp: codemap::Span, tts: &[ast::token_tree]) -> base::MacResult { let es = base::get_exprs_from_tts(cx, sp, tts); diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 216bc3097ce..6b204a243cb 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -16,7 +16,7 @@ use opt_vec; use parse::token; use parse::token::{str_to_ident}; -pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_syntax_ext(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let mut res_str = ~""; for (i, e) in tts.iter().enumerate() { diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 9285defe69e..c3c57082684 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_clone(cx: @ExtCtxt, +pub fn expand_deriving_clone(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) @@ -42,7 +42,7 @@ pub fn expand_deriving_clone(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -pub fn expand_deriving_deep_clone(cx: @ExtCtxt, +pub fn expand_deriving_deep_clone(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) @@ -74,7 +74,7 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt, fn cs_clone( name: &str, - cx: @ExtCtxt, span: Span, + cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let clone_ident = substr.method_ident; let ctor_ident; diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 74680266cb7..f7b249fc8d8 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -14,17 +14,17 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_eq(cx: @ExtCtxt, +pub fn expand_deriving_eq(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { // structures are equal if all fields are equal, and non equal, if // any fields are not equal or if the enum variants are different - fn cs_eq(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_eq(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) } - fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_ne(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_or(|cx, span, _, _| cx.expr_bool(span, true), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index d48cfbd7dd7..c1e4e1e2b64 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -15,7 +15,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_ord(cx: @ExtCtxt, +pub fn expand_deriving_ord(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { @@ -51,7 +51,7 @@ pub fn expand_deriving_ord(cx: @ExtCtxt, } /// Strict inequality. -fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let op = if less {ast::BiLt} else {ast::BiGt}; cs_fold( false, // need foldr, diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index ab822d14b48..0b4d2659fd1 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -14,11 +14,11 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_totaleq(cx: @ExtCtxt, +pub fn expand_deriving_totaleq(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { - fn cs_equals(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { + fn cs_equals(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { cs_and(|cx, span, _, _| cx.expr_bool(span, false), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 2ace39a3486..3c58bfa01a9 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -16,7 +16,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; use std::cmp::{Ordering, Equal, Less, Greater}; -pub fn expand_deriving_totalord(cx: @ExtCtxt, +pub fn expand_deriving_totalord(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { @@ -44,7 +44,7 @@ pub fn expand_deriving_totalord(cx: @ExtCtxt, } -pub fn ordering_const(cx: @ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { +pub fn ordering_const(cx: &ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { let cnst = match cnst { Less => "Less", Equal => "Equal", @@ -56,7 +56,7 @@ pub fn ordering_const(cx: @ExtCtxt, span: Span, cnst: Ordering) -> ast::Path { cx.ident_of(cnst)]) } -pub fn cs_cmp(cx: @ExtCtxt, span: Span, +pub fn cs_cmp(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let test_id = cx.ident_of("__test"); let equals_path = ordering_const(cx, span, Equal); diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 0aade760b7b..de995af9ae3 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -19,7 +19,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_decodable(cx: @ExtCtxt, +pub fn expand_deriving_decodable(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { @@ -51,7 +51,7 @@ pub fn expand_deriving_decodable(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn decodable_substructure(cx: @ExtCtxt, span: Span, +fn decodable_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let decoder = substr.nonself_args[0]; let recurse = ~[cx.ident_of("extra"), @@ -132,7 +132,7 @@ fn decodable_substructure(cx: @ExtCtxt, span: Span, /// Create a decoder for a single enum variant/struct: /// - `outer_pat_ident` is the name of this enum variant/struct /// - `getarg` should retrieve the `uint`-th field with name `@str`. -fn decode_static_fields(cx: @ExtCtxt, +fn decode_static_fields(cx: &ExtCtxt, outer_span: Span, outer_pat_ident: Ident, fields: &StaticFields, diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index 393d808a025..ba2df120796 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_default(cx: @ExtCtxt, +pub fn expand_deriving_default(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) @@ -41,7 +41,7 @@ pub fn expand_deriving_default(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn default_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let default_ident = ~[ cx.ident_of("std"), cx.ident_of("default"), diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 09210116c37..a6cba59aea5 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -81,7 +81,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_encodable(cx: @ExtCtxt, +pub fn expand_deriving_encodable(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { @@ -113,7 +113,7 @@ pub fn expand_deriving_encodable(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn encodable_substructure(cx: @ExtCtxt, span: Span, +fn encodable_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let encoder = substr.nonself_args[0]; // throw an underscore in front to suppress unused variable warnings diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index b3e2503f8c4..2eb0fe30b4b 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -190,7 +190,7 @@ mod ty; pub struct TraitDef<'a> { /// The extension context - cx: @ExtCtxt, + cx: &'a ExtCtxt, /// The span for the current #[deriving(Foo)] header. span: Span, @@ -300,7 +300,7 @@ Combine the values of all the fields together. The last argument is all the fields of all the structures, see above for details. */ pub type CombineSubstructureFunc<'a> = - 'a |@ExtCtxt, Span, &Substructure| -> @Expr; + 'a |&ExtCtxt, Span, &Substructure| -> @Expr; /** Deal with non-matching enum variants, the arguments are a list @@ -308,7 +308,7 @@ representing each variant: (variant index, ast::variant instance, [variant fields]), and a list of the nonself args of the type */ pub type EnumNonMatchFunc<'a> = - 'a |@ExtCtxt, + 'a |&ExtCtxt, Span, &[(uint, P<ast::variant>, ~[(Span, Option<Ident>, @Expr)])], &[@Expr]| @@ -1076,10 +1076,10 @@ Fold the fields. `use_foldl` controls whether this is done left-to-right (`true`) or right-to-left (`false`). */ pub fn cs_fold(use_foldl: bool, - f: |@ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr, + f: |&ExtCtxt, Span, @Expr, @Expr, &[@Expr]| -> @Expr, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, + cx: &ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { @@ -1115,9 +1115,9 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), ~~~ */ #[inline] -pub fn cs_same_method(f: |@ExtCtxt, Span, ~[@Expr]| -> @Expr, +pub fn cs_same_method(f: |&ExtCtxt, Span, ~[@Expr]| -> @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, + cx: &ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { @@ -1149,10 +1149,10 @@ fields. `use_foldl` controls whether this is done left-to-right */ #[inline] pub fn cs_same_method_fold(use_foldl: bool, - f: |@ExtCtxt, Span, @Expr, @Expr| -> @Expr, + f: |&ExtCtxt, Span, @Expr, @Expr| -> @Expr, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, + cx: &ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { @@ -1179,7 +1179,7 @@ on all the fields. #[inline] pub fn cs_binop(binop: ast::BinOp, base: @Expr, enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, trait_span: Span, + cx: &ExtCtxt, trait_span: Span, substructure: &Substructure) -> @Expr { cs_same_method_fold( true, // foldl is good enough @@ -1197,7 +1197,7 @@ pub fn cs_binop(binop: ast::BinOp, base: @Expr, /// cs_binop with binop == or #[inline] pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, span: Span, + cx: &ExtCtxt, span: Span, substructure: &Substructure) -> @Expr { cs_binop(ast::BiOr, cx.expr_bool(span, false), enum_nonmatch_f, @@ -1207,7 +1207,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc, /// cs_binop with binop == and #[inline] pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc, - cx: @ExtCtxt, span: Span, + cx: &ExtCtxt, span: Span, substructure: &Substructure) -> @Expr { cs_binop(ast::BiAnd, cx.expr_bool(span, true), enum_nonmatch_f, diff --git a/src/libsyntax/ext/deriving/iter_bytes.rs b/src/libsyntax/ext/deriving/iter_bytes.rs index 837b8bd59ec..8b2ad95e45c 100644 --- a/src/libsyntax/ext/deriving/iter_bytes.rs +++ b/src/libsyntax/ext/deriving/iter_bytes.rs @@ -15,7 +15,7 @@ use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_iter_bytes(cx: @ExtCtxt, +pub fn expand_deriving_iter_bytes(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { @@ -45,7 +45,7 @@ pub fn expand_deriving_iter_bytes(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn iter_bytes_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn iter_bytes_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let (lsb0, f)= match substr.nonself_args { [l, f] => (l, f), _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(IterBytes)`") diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index d38f9b4d1b7..1e8b79c8f35 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -46,20 +46,20 @@ pub mod totalord; pub mod generic; -pub type ExpandDerivingStructDefFn<'a> = 'a |@ExtCtxt, +pub type ExpandDerivingStructDefFn<'a> = 'a |&ExtCtxt, Span, x: &struct_def, Ident, y: &Generics| -> @item; -pub type ExpandDerivingEnumDefFn<'a> = 'a |@ExtCtxt, +pub type ExpandDerivingEnumDefFn<'a> = 'a |&ExtCtxt, Span, x: &enum_def, Ident, y: &Generics| -> @item; -pub fn expand_meta_deriving(cx: @ExtCtxt, +pub fn expand_meta_deriving(cx: &ExtCtxt, _span: Span, mitem: @MetaItem, in_items: ~[@item]) diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 73ea627ff54..ba2d85f357a 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -15,7 +15,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_from_primitive(cx: @ExtCtxt, +pub fn expand_deriving_from_primitive(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) -> ~[@item] { @@ -64,7 +64,7 @@ pub fn expand_deriving_from_primitive(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn cs_from(name: &str, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn cs_from(name: &str, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let n = match substr.nonself_args { [n] => n, _ => cx.span_bug(span, "Incorrect number of arguments in `deriving(FromPrimitive)`") diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 91ed60324cf..1491797c808 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -16,7 +16,7 @@ use ext::build::{AstBuilder}; use ext::deriving::generic::*; use opt_vec; -pub fn expand_deriving_rand(cx: @ExtCtxt, +pub fn expand_deriving_rand(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) @@ -50,7 +50,7 @@ pub fn expand_deriving_rand(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn rand_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let rng = match substr.nonself_args { [rng] => ~[ rng ], _ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`") @@ -130,7 +130,7 @@ fn rand_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { _ => cx.bug("Non-static method in `deriving(Rand)`") }; - fn rand_thing(cx: @ExtCtxt, + fn rand_thing(cx: &ExtCtxt, span: Span, ctor_ident: Ident, summary: &StaticFields, diff --git a/src/libsyntax/ext/deriving/to_str.rs b/src/libsyntax/ext/deriving/to_str.rs index fd8c21f4f98..25700f93a33 100644 --- a/src/libsyntax/ext/deriving/to_str.rs +++ b/src/libsyntax/ext/deriving/to_str.rs @@ -15,7 +15,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_to_str(cx: @ExtCtxt, +pub fn expand_deriving_to_str(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) @@ -47,7 +47,7 @@ pub fn expand_deriving_to_str(cx: @ExtCtxt, // doesn't invoke the to_str() method on each field. Hence we mirror // the logic of the repr_to_str() method, but with tweaks to call to_str() // on sub-fields. -fn to_str_substructure(cx: @ExtCtxt, span: Span, +fn to_str_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let to_str = cx.ident_of("to_str"); diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index e606cebc415..10e07520a84 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -58,7 +58,7 @@ impl<'a> Path<'a> { } pub fn to_ty(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, span: Span, self_ty: Ident, self_generics: &Generics) @@ -66,7 +66,7 @@ impl<'a> Path<'a> { cx.ty_path(self.to_path(cx, span, self_ty, self_generics), None) } pub fn to_path(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, span: Span, self_ty: Ident, self_generics: &Generics) @@ -110,14 +110,14 @@ pub fn nil_ty() -> Ty<'static> { Tuple(~[]) } -fn mk_lifetime(cx: @ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifetime> { +fn mk_lifetime(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifetime> { match *lt { Some(ref s) => Some(cx.lifetime(span, cx.ident_of(*s))), None => None } } -fn mk_lifetimes(cx: @ExtCtxt, span: Span, lt: &Option<&str>) -> OptVec<ast::Lifetime> { +fn mk_lifetimes(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> OptVec<ast::Lifetime> { match *lt { Some(ref s) => opt_vec::with(cx.lifetime(span, cx.ident_of(*s))), None => opt_vec::Empty @@ -126,7 +126,7 @@ fn mk_lifetimes(cx: @ExtCtxt, span: Span, lt: &Option<&str>) -> OptVec<ast::Life impl<'a> Ty<'a> { pub fn to_ty(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, span: Span, self_ty: Ident, self_generics: &Generics) @@ -164,7 +164,7 @@ impl<'a> Ty<'a> { } pub fn to_path(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, span: Span, self_ty: Ident, self_generics: &Generics) @@ -189,7 +189,7 @@ impl<'a> Ty<'a> { } -fn mk_ty_param(cx: @ExtCtxt, span: Span, name: &str, bounds: &[Path], +fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, bounds: &[Path], self_ident: Ident, self_generics: &Generics) -> ast::TyParam { let bounds = opt_vec::from( bounds.map(|b| { @@ -219,7 +219,7 @@ impl<'a> LifetimeBounds<'a> { } } pub fn to_generics(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, span: Span, self_ty: Ident, self_generics: &Generics) @@ -239,7 +239,7 @@ impl<'a> LifetimeBounds<'a> { } -pub fn get_explicit_self(cx: @ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) +pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) -> (@Expr, ast::explicit_self) { let self_path = cx.expr_self(span); match *self_ptr { diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index 67f14a8d486..c406dbf0d01 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -14,7 +14,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use ext::deriving::generic::*; -pub fn expand_deriving_zero(cx: @ExtCtxt, +pub fn expand_deriving_zero(cx: &ExtCtxt, span: Span, mitem: @MetaItem, in_items: ~[@item]) @@ -57,7 +57,7 @@ pub fn expand_deriving_zero(cx: @ExtCtxt, trait_def.expand(mitem, in_items) } -fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr { +fn zero_substructure(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr { let zero_ident = ~[ cx.ident_of("std"), cx.ident_of("num"), diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 15630e37ead..b5f5f8c41d0 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -22,7 +22,7 @@ use ext::build::AstBuilder; use std::os; -pub fn expand_option_env(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_option_env(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let var = get_single_str_from_tts(cx, sp, tts, "option_env!"); @@ -33,7 +33,7 @@ pub fn expand_option_env(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) MRExpr(e) } -pub fn expand_env(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_env(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let exprs = get_exprs_from_tts(cx, sp, tts); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 2c2669e914c..9f9c245fe48 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -32,7 +32,7 @@ use util::small_vector::SmallVector; use std::vec; pub fn expand_expr(extsbox: @mut SyntaxEnv, - cx: @ExtCtxt, + cx: &ExtCtxt, e: @ast::Expr, fld: &MacroExpander) -> @ast::Expr { @@ -214,7 +214,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, // NB: there is some redundancy between this and expand_item, below, and // they might benefit from some amount of semantic and language-UI merger. pub fn expand_mod_items(extsbox: @mut SyntaxEnv, - cx: @ExtCtxt, + cx: &ExtCtxt, module_: &ast::_mod, fld: &MacroExpander) -> ast::_mod { @@ -271,7 +271,7 @@ static special_block_name : &'static str = " block"; // When we enter a module, record it, for the sake of `module!` pub fn expand_item(extsbox: @mut SyntaxEnv, - cx: @ExtCtxt, + cx: &ExtCtxt, it: @ast::item, fld: &MacroExpander) -> SmallVector<@ast::item> { @@ -298,7 +298,7 @@ pub fn contains_macro_escape(attrs: &[ast::Attribute]) -> bool { // Support for item-position macro invocations, exactly the same // logic as for expression-position macro invocations. pub fn expand_item_mac(extsbox: @mut SyntaxEnv, - cx: @ExtCtxt, + cx: &ExtCtxt, it: @ast::item, fld: &MacroExpander) -> SmallVector<@ast::item> { @@ -407,7 +407,7 @@ fn insert_macro(exts: SyntaxEnv, name: ast::Name, transformer: @Transformer) { // expand a stmt pub fn expand_stmt(extsbox: @mut SyntaxEnv, - cx: @ExtCtxt, + cx: &ExtCtxt, s: &Stmt, fld: &MacroExpander) -> SmallVector<@Stmt> { @@ -625,7 +625,7 @@ pub fn new_name_finder(idents: ~[ast::Ident]) -> NewNameFinderContext { // expand a block. pushes a new exts_frame, then calls expand_block_elts pub fn expand_block(extsbox: @mut SyntaxEnv, - _: @ExtCtxt, + _: &ExtCtxt, blk: &Block, fld: &MacroExpander) -> P<Block> { @@ -690,7 +690,7 @@ pub fn renames_to_fold(renames: @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold { } as @ast_fold } -pub fn new_span(cx: @ExtCtxt, sp: Span) -> Span { +pub fn new_span(cx: &ExtCtxt, sp: Span) -> Span { /* this discards information in the case of macro-defining macros */ Span { lo: sp.lo, @@ -949,12 +949,12 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess, injector.fold_crate(c) } -pub struct MacroExpander { +pub struct MacroExpander<'a> { extsbox: @mut SyntaxEnv, - cx: @ExtCtxt, + cx: &'a ExtCtxt, } -impl ast_fold for MacroExpander { +impl<'a> ast_fold for MacroExpander<'a> { fn fold_expr(&self, expr: @ast::Expr) -> @ast::Expr { expand_expr(self.extsbox, self.cx, @@ -1005,10 +1005,10 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess, // every method/element of AstFoldFns in fold.rs. let extsbox = syntax_expander_table(); let cx = ExtCtxt::new(parse_sess, cfg.clone()); - let expander = @MacroExpander { + let expander = MacroExpander { extsbox: @mut extsbox, - cx: cx, - } as @ast_fold; + cx: &cx, + }; let ret = expander.fold_crate(c); parse_sess.span_diagnostic.handler().abort_if_errors(); @@ -1159,7 +1159,7 @@ pub fn mtwt_cancel_outer_mark(tts: &[ast::token_tree], ctxt: ast::SyntaxContext) mark_tts(tts,outer_mark) } -fn original_span(cx: @ExtCtxt) -> @codemap::ExpnInfo { +fn original_span(cx: &ExtCtxt) -> @codemap::ExpnInfo { let mut relevant_info = cx.backtrace(); let mut einfo = relevant_info.unwrap(); loop { diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 5e3e4e15d8e..f2eab3f1cbc 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -15,7 +15,7 @@ use codemap::Span; use ext::base; use ext::build::AstBuilder; -pub fn expand_syntax_ext(ecx: @base::ExtCtxt, sp: Span, +pub fn expand_syntax_ext(ecx: &base::ExtCtxt, sp: Span, _tts: &[ast::token_tree]) -> base::MacResult { ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead"); ecx.parse_sess.span_diagnostic.span_note(sp, diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 98ebc24427d..2b51203eca5 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -28,8 +28,8 @@ enum ArgumentType { String, } -struct Context { - ecx: @ExtCtxt, +struct Context<'a> { + ecx: &'a ExtCtxt, fmtsp: Span, // Parsed argument expressions and the types that we've found so far for @@ -50,7 +50,7 @@ struct Context { next_arg: uint, } -impl Context { +impl<'a> Context<'a> { /// Parses the arguments from the given list of tokens, returning None if /// there's a parse error so we can continue parsing other format! expressions. fn parse_args(&mut self, sp: Span, @@ -722,7 +722,7 @@ impl Context { } } -pub fn expand_args(ecx: @ExtCtxt, sp: Span, +pub fn expand_args(ecx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let mut cx = Context { ecx: ecx, diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 2007abcc81c..7dfd487b379 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -15,7 +15,7 @@ use ext::base; use print; use parse::token::{get_ident_interner}; -pub fn expand_syntax_ext(cx: @ExtCtxt, +pub fn expand_syntax_ext(cx: &ExtCtxt, sp: codemap::Span, tt: &[ast::token_tree]) -> base::MacResult { diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 77cb02522a7..f6086734003 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -40,11 +40,11 @@ pub mod rt { pub use codemap::{BytePos, Span, dummy_spanned}; pub trait ToTokens { - fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree]; + fn to_tokens(&self, _cx: &ExtCtxt) -> ~[token_tree]; } impl ToTokens for ~[token_tree] { - fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree] { + fn to_tokens(&self, _cx: &ExtCtxt) -> ~[token_tree] { (*self).clone() } } @@ -56,7 +56,7 @@ pub mod rt { pub fn to_source() -> ~str; // If you can make source, you can definitely make tokens. - pub fn to_tokens(cx: @ExtCtxt) -> ~[token_tree] { + pub fn to_tokens(cx: &ExtCtxt) -> ~[token_tree] { cx.parse_tts(self.to_source()) } } @@ -199,7 +199,7 @@ pub mod rt { macro_rules! impl_to_tokens( ($t:ty) => ( impl ToTokens for $t { - fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] { + fn to_tokens(&self, cx: &ExtCtxt) -> ~[token_tree] { cx.parse_tts(self.to_source()) } } @@ -209,7 +209,7 @@ pub mod rt { macro_rules! impl_to_tokens_self( ($t:ty) => ( impl<'a> ToTokens for $t { - fn to_tokens(&self, cx: @ExtCtxt) -> ~[token_tree] { + fn to_tokens(&self, cx: &ExtCtxt) -> ~[token_tree] { cx.parse_tts(self.to_source()) } } @@ -289,7 +289,7 @@ pub mod rt { } -pub fn expand_quote_tokens(cx: @ExtCtxt, +pub fn expand_quote_tokens(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let (cx_expr, expr) = expand_tts(cx, sp, tts); @@ -297,14 +297,14 @@ pub fn expand_quote_tokens(cx: @ExtCtxt, base::MRExpr(expanded) } -pub fn expand_quote_expr(cx: @ExtCtxt, +pub fn expand_quote_expr(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let expanded = expand_parse_call(cx, sp, "parse_expr", ~[], tts); base::MRExpr(expanded) } -pub fn expand_quote_item(cx: @ExtCtxt, +pub fn expand_quote_item(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let e_attrs = cx.expr_vec_uniq(sp, ~[]); @@ -313,7 +313,7 @@ pub fn expand_quote_item(cx: @ExtCtxt, base::MRExpr(expanded) } -pub fn expand_quote_pat(cx: @ExtCtxt, +pub fn expand_quote_pat(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let e_refutable = cx.expr_lit(sp, ast::lit_bool(true)); @@ -322,7 +322,7 @@ pub fn expand_quote_pat(cx: @ExtCtxt, base::MRExpr(expanded) } -pub fn expand_quote_ty(cx: @ExtCtxt, +pub fn expand_quote_ty(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let e_param_colons = cx.expr_lit(sp, ast::lit_bool(false)); @@ -331,7 +331,7 @@ pub fn expand_quote_ty(cx: @ExtCtxt, base::MRExpr(expanded) } -pub fn expand_quote_stmt(cx: @ExtCtxt, +pub fn expand_quote_stmt(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let e_attrs = cx.expr_vec_uniq(sp, ~[]); @@ -349,7 +349,7 @@ fn id_ext(str: &str) -> ast::Ident { } // Lift an ident to the expr that evaluates to that ident. -fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { +fn mk_ident(cx: &ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { let e_str = cx.expr_str(sp, cx.str_of(ident)); cx.expr_method_call(sp, cx.expr_ident(sp, id_ext("ext_cx")), @@ -357,7 +357,7 @@ fn mk_ident(cx: @ExtCtxt, sp: Span, ident: ast::Ident) -> @ast::Expr { ~[e_str]) } -fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::Expr { +fn mk_binop(cx: &ExtCtxt, sp: Span, bop: token::binop) -> @ast::Expr { let name = match bop { PLUS => "PLUS", MINUS => "MINUS", @@ -373,7 +373,7 @@ fn mk_binop(cx: @ExtCtxt, sp: Span, bop: token::binop) -> @ast::Expr { cx.expr_ident(sp, id_ext(name)) } -fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { +fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { match *tok { BINOP(binop) => { @@ -528,7 +528,7 @@ fn mk_token(cx: @ExtCtxt, sp: Span, tok: &token::Token) -> @ast::Expr { } -fn mk_tt(cx: @ExtCtxt, sp: Span, tt: &ast::token_tree) +fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::token_tree) -> ~[@ast::Stmt] { match *tt { @@ -570,7 +570,7 @@ fn mk_tt(cx: @ExtCtxt, sp: Span, tt: &ast::token_tree) } } -fn mk_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> ~[@ast::Stmt] { let mut ss = ~[]; for tt in tts.iter() { @@ -579,7 +579,7 @@ fn mk_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) ss } -fn expand_tts(cx: @ExtCtxt, +fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> (@ast::Expr, @ast::Expr) { @@ -652,7 +652,7 @@ fn expand_tts(cx: @ExtCtxt, (cx_expr, block) } -fn expand_wrapper(cx: @ExtCtxt, +fn expand_wrapper(cx: &ExtCtxt, sp: Span, cx_expr: @ast::Expr, expr: @ast::Expr) -> @ast::Expr { @@ -667,7 +667,7 @@ fn expand_wrapper(cx: @ExtCtxt, cx.expr_block(cx.block_all(sp, uses, ~[stmt_let_ext_cx], Some(expr))) } -fn expand_parse_call(cx: @ExtCtxt, +fn expand_parse_call(cx: &ExtCtxt, sp: Span, parse_method: &str, arg_exprs: ~[@ast::Expr], diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 2fcf6f1cad0..cf11bdcce64 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -28,7 +28,7 @@ use std::str; // a given file into the current one. /* line!(): expands to the current line number */ -pub fn expand_line(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_line(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "line!"); @@ -39,7 +39,7 @@ pub fn expand_line(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) } /* col!(): expands to the current column number */ -pub fn expand_col(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_col(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "col!"); @@ -51,7 +51,7 @@ pub fn expand_col(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) /* file!(): expands to the current filename */ /* The filemap (`loc.file`) contains a bunch more information we could spit * out if we wanted. */ -pub fn expand_file(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_file(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "file!"); @@ -61,13 +61,13 @@ pub fn expand_file(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) base::MRExpr(cx.expr_str(topmost.call_site, filename)) } -pub fn expand_stringify(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_stringify(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let s = pprust::tts_to_str(tts, get_ident_interner()); base::MRExpr(cx.expr_str(sp, s.to_managed())) } -pub fn expand_mod(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_mod(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { base::check_zero_tts(cx, sp, tts, "module_path!"); base::MRExpr(cx.expr_str(sp, @@ -77,7 +77,7 @@ pub fn expand_mod(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) // include! : parse the given file as an expr // This is generally a bad idea because it's going to behave // unhygienically. -pub fn expand_include(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_include(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include!"); // The file will be added to the code map by the parser @@ -88,7 +88,7 @@ pub fn expand_include(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) } // include_str! : read the given file, insert it as a literal string expr -pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_include_str(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { let file = get_single_str_from_tts(cx, sp, tts, "include_str!"); let file = res_rel_file(cx, sp, &Path::new(file)); @@ -120,7 +120,7 @@ pub fn expand_include_str(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) } } -pub fn expand_include_bin(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) +pub fn expand_include_bin(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult { use std::at_vec; @@ -167,7 +167,7 @@ fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo { // resolve a file-system path to an absolute file-system path (if it // isn't already) -fn res_rel_file(cx: @ExtCtxt, sp: codemap::Span, arg: &Path) -> Path { +fn res_rel_file(cx: &ExtCtxt, sp: codemap::Span, arg: &Path) -> Path { // NB: relative paths are resolved relative to the compilation unit if !arg.is_absolute() { let mut cu = Path::new(cx.codemap().span_to_filename(sp)); diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index 1862d4a88fd..cd172495d70 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -16,7 +16,7 @@ use parse::lexer::{new_tt_reader, reader}; use parse::parser::Parser; use parse::token::keywords; -pub fn expand_trace_macros(cx: @ExtCtxt, +pub fn expand_trace_macros(cx: &ExtCtxt, sp: Span, tt: &[ast::token_tree]) -> base::MacResult { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 8291a76fab6..63517ca2269 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -83,7 +83,7 @@ struct MacroRulesSyntaxExpanderTTFun { impl SyntaxExpanderTTTrait for MacroRulesSyntaxExpanderTTFun { fn expand(&self, - cx: @ExtCtxt, + cx: &ExtCtxt, sp: Span, arg: &[ast::token_tree], _: ast::SyntaxContext) @@ -93,7 +93,7 @@ impl SyntaxExpanderTTTrait for MacroRulesSyntaxExpanderTTFun { } // Given `lhses` and `rhses`, this is the new macro we create -fn generic_extension(cx: @ExtCtxt, +fn generic_extension(cx: &ExtCtxt, sp: Span, name: Ident, arg: &[ast::token_tree], @@ -168,7 +168,7 @@ fn generic_extension(cx: @ExtCtxt, // this procedure performs the expansion of the // macro_rules! macro. It parses the RHS and adds // an extension to the current context. -pub fn add_new_extension(cx: @ExtCtxt, +pub fn add_new_extension(cx: &ExtCtxt, sp: Span, name: Ident, arg: ~[ast::token_tree], diff --git a/src/test/run-pass-fulldeps/quote-tokens.rs b/src/test/run-pass-fulldeps/quote-tokens.rs index 2e426c0413e..dc95faa1986 100644 --- a/src/test/run-pass-fulldeps/quote-tokens.rs +++ b/src/test/run-pass-fulldeps/quote-tokens.rs @@ -16,7 +16,7 @@ extern mod syntax; use syntax::ext::base::ExtCtxt; -fn syntax_extension(cx: @ExtCtxt) { +fn syntax_extension(cx: &ExtCtxt) { let e_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, 1 + 2); let p_toks : ~[syntax::ast::token_tree] = quote_tokens!(cx, (x, 1 .. 4, *)); |
