Skip to content

Commit 0607c13

Browse files
committed
Stop using @ExtCtxt
1 parent b90989a commit 0607c13

35 files changed

+152
-153
lines changed

src/librustc/front/test.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct Test {
4040
struct TestCtxt {
4141
sess: session::Session,
4242
path: RefCell<~[ast::Ident]>,
43-
ext_cx: @ExtCtxt,
43+
ext_cx: ExtCtxt,
4444
testfns: RefCell<~[Test]>,
4545
is_extra: bool,
4646
config: ast::CrateConfig,
@@ -163,8 +163,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate)
163163
config: crate.config.clone(),
164164
};
165165

166-
let ext_cx = cx.ext_cx;
167-
ext_cx.bt_push(ExpnInfo {
166+
cx.ext_cx.bt_push(ExpnInfo {
168167
call_site: dummy_sp(),
169168
callee: NameAndSpan {
170169
name: @"test",
@@ -177,7 +176,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate)
177176
cx: cx
178177
};
179178
let res = fold.fold_crate(crate);
180-
ext_cx.bt_pop();
179+
cx.ext_cx.bt_pop();
181180
return res;
182181
}
183182

@@ -313,7 +312,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
313312

314313
// The synthesized main function which will call the console test runner
315314
// with our list of tests
316-
let mainfn = (quote_item!(cx.ext_cx,
315+
let mainfn = (quote_item!(&cx.ext_cx,
317316
pub fn main() {
318317
#[main];
319318
extra::test::test_main_static(::std::os::args(), TESTS);
@@ -377,7 +376,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item {
377376
// The vector of test_descs for this crate
378377
let test_descs = mk_test_descs(cx);
379378

380-
(quote_item!(cx.ext_cx,
379+
(quote_item!(&cx.ext_cx,
381380
pub static TESTS : &'static [self::extra::test::TestDescAndFn] =
382381
$test_descs
383382
;
@@ -438,24 +437,24 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
438437
};
439438

440439
let t_expr = if test.bench {
441-
quote_expr!(cx.ext_cx, self::extra::test::StaticBenchFn($fn_expr) )
440+
quote_expr!(&cx.ext_cx, self::extra::test::StaticBenchFn($fn_expr) )
442441
} else {
443-
quote_expr!(cx.ext_cx, self::extra::test::StaticTestFn($fn_expr) )
442+
quote_expr!(&cx.ext_cx, self::extra::test::StaticTestFn($fn_expr) )
444443
};
445444

446445
let ignore_expr = if test.ignore {
447-
quote_expr!(cx.ext_cx, true )
446+
quote_expr!(&cx.ext_cx, true )
448447
} else {
449-
quote_expr!(cx.ext_cx, false )
448+
quote_expr!(&cx.ext_cx, false )
450449
};
451450

452451
let fail_expr = if test.should_fail {
453-
quote_expr!(cx.ext_cx, true )
452+
quote_expr!(&cx.ext_cx, true )
454453
} else {
455-
quote_expr!(cx.ext_cx, false )
454+
quote_expr!(&cx.ext_cx, false )
456455
};
457456

458-
let e = quote_expr!(cx.ext_cx,
457+
let e = quote_expr!(&cx.ext_cx,
459458
self::extra::test::TestDescAndFn {
460459
desc: self::extra::test::TestDesc {
461460
name: self::extra::test::StaticTestName($name_expr),

src/librustpkg/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct ListenerFn {
7575

7676
struct ReadyCtx {
7777
sess: session::Session,
78-
ext_cx: @ExtCtxt,
78+
ext_cx: ExtCtxt,
7979
path: ~[ast::Ident],
8080
fns: ~[ListenerFn]
8181
}

src/libsyntax/ext/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn next_state(s: State) -> Option<State> {
3737
}
3838
}
3939

40-
pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
40+
pub fn expand_asm(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
4141
-> base::MacResult {
4242
let p = parse::new_parser_from_tts(cx.parse_sess(),
4343
cx.cfg(),

src/libsyntax/ext/base.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct MacroDef {
3535
ext: SyntaxExtension
3636
}
3737

38-
pub type ItemDecorator = extern "Rust" fn(@ExtCtxt,
38+
pub type ItemDecorator = extern "Rust" fn(&ExtCtxt,
3939
Span,
4040
@ast::MetaItem,
4141
~[@ast::item])
@@ -48,15 +48,15 @@ pub struct SyntaxExpanderTT {
4848

4949
pub trait SyntaxExpanderTTTrait {
5050
fn expand(&self,
51-
ecx: @ExtCtxt,
51+
ecx: &ExtCtxt,
5252
span: Span,
5353
token_tree: &[ast::token_tree],
5454
context: ast::SyntaxContext)
5555
-> MacResult;
5656
}
5757

5858
pub type SyntaxExpanderTTFunNoCtxt =
59-
extern "Rust" fn(ecx: @ExtCtxt,
59+
extern "Rust" fn(ecx: &ExtCtxt,
6060
span: codemap::Span,
6161
token_tree: &[ast::token_tree])
6262
-> MacResult;
@@ -67,7 +67,7 @@ enum SyntaxExpanderTTExpander {
6767

6868
impl SyntaxExpanderTTTrait for SyntaxExpanderTT {
6969
fn expand(&self,
70-
ecx: @ExtCtxt,
70+
ecx: &ExtCtxt,
7171
span: Span,
7272
token_tree: &[ast::token_tree],
7373
_: ast::SyntaxContext)
@@ -92,7 +92,7 @@ pub struct SyntaxExpanderTTItem {
9292

9393
pub trait SyntaxExpanderTTItemTrait {
9494
fn expand(&self,
95-
cx: @ExtCtxt,
95+
cx: &ExtCtxt,
9696
sp: Span,
9797
ident: ast::Ident,
9898
token_tree: ~[ast::token_tree],
@@ -102,7 +102,7 @@ pub trait SyntaxExpanderTTItemTrait {
102102

103103
impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem {
104104
fn expand(&self,
105-
cx: @ExtCtxt,
105+
cx: &ExtCtxt,
106106
sp: Span,
107107
ident: ast::Ident,
108108
token_tree: ~[ast::token_tree],
@@ -119,15 +119,15 @@ impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem {
119119
}
120120
}
121121

122-
pub type SyntaxExpanderTTItemFun = extern "Rust" fn(@ExtCtxt,
122+
pub type SyntaxExpanderTTItemFun = extern "Rust" fn(&ExtCtxt,
123123
Span,
124124
ast::Ident,
125125
~[ast::token_tree],
126126
ast::SyntaxContext)
127127
-> MacResult;
128128

129129
pub type SyntaxExpanderTTItemFunNoCtxt =
130-
extern "Rust" fn(@ExtCtxt, Span, ast::Ident, ~[ast::token_tree])
130+
extern "Rust" fn(&ExtCtxt, Span, ast::Ident, ~[ast::token_tree])
131131
-> MacResult;
132132

133133
pub trait AnyMacro {
@@ -319,8 +319,8 @@ pub struct ExtCtxt {
319319

320320
impl ExtCtxt {
321321
pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::CrateConfig)
322-
-> @ExtCtxt {
323-
@ExtCtxt {
322+
-> ExtCtxt {
323+
ExtCtxt {
324324
parse_sess: parse_sess,
325325
cfg: cfg,
326326
backtrace: @mut None,
@@ -329,7 +329,7 @@ impl ExtCtxt {
329329
}
330330
}
331331

332-
pub fn expand_expr(@self, mut e: @ast::Expr) -> @ast::Expr {
332+
pub fn expand_expr(&self, mut e: @ast::Expr) -> @ast::Expr {
333333
loop {
334334
match e.node {
335335
ast::ExprMac(..) => {
@@ -417,7 +417,7 @@ impl ExtCtxt {
417417
}
418418
}
419419

420-
pub fn expr_to_str(cx: @ExtCtxt, expr: @ast::Expr, err_msg: &str) -> (@str, ast::StrStyle) {
420+
pub fn expr_to_str(cx: &ExtCtxt, expr: @ast::Expr, err_msg: &str) -> (@str, ast::StrStyle) {
421421
match expr.node {
422422
ast::ExprLit(l) => match l.node {
423423
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:
427427
}
428428
}
429429

430-
pub fn check_zero_tts(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree],
430+
pub fn check_zero_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree],
431431
name: &str) {
432432
if tts.len() != 0 {
433433
cx.span_fatal(sp, format!("{} takes no arguments", name));
434434
}
435435
}
436436

437-
pub fn get_single_str_from_tts(cx: @ExtCtxt,
437+
pub fn get_single_str_from_tts(cx: &ExtCtxt,
438438
sp: Span,
439439
tts: &[ast::token_tree],
440440
name: &str)
@@ -450,7 +450,7 @@ pub fn get_single_str_from_tts(cx: @ExtCtxt,
450450
}
451451
}
452452

453-
pub fn get_exprs_from_tts(cx: @ExtCtxt,
453+
pub fn get_exprs_from_tts(cx: &ExtCtxt,
454454
sp: Span,
455455
tts: &[ast::token_tree]) -> ~[@ast::Expr] {
456456
let p = parse::new_parser_from_tts(cx.parse_sess(),

src/libsyntax/ext/build.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ast_util;
1515
use codemap::{Span, respan, dummy_sp};
1616
use ext::base::ExtCtxt;
1717
use ext::quote::rt::*;
18-
use fold;
18+
use fold::ast_fold;
1919
use opt_vec;
2020
use opt_vec::OptVec;
2121

@@ -236,7 +236,7 @@ pub trait AstBuilder {
236236
vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item;
237237
}
238238

239-
impl AstBuilder for @ExtCtxt {
239+
impl<'a> AstBuilder for &'a ExtCtxt {
240240
fn path(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path {
241241
self.path_all(span, false, strs, opt_vec::Empty, ~[])
242242
}
@@ -903,11 +903,11 @@ impl AstBuilder for @ExtCtxt {
903903
}
904904
}
905905

906-
struct Duplicator {
907-
cx: @ExtCtxt,
906+
struct Duplicator<'a> {
907+
cx: &'a ExtCtxt,
908908
}
909909

910-
impl fold::ast_fold for Duplicator {
910+
impl<'a> ast_fold for Duplicator<'a> {
911911
fn new_id(&self, _: NodeId) -> NodeId {
912912
ast::DUMMY_NODE_ID
913913
}
@@ -920,14 +920,14 @@ pub trait Duplicate {
920920
// These functions just duplicate AST nodes.
921921
//
922922

923-
fn duplicate(&self, cx: @ExtCtxt) -> Self;
923+
fn duplicate(&self, cx: &ExtCtxt) -> Self;
924924
}
925925

926926
impl Duplicate for @ast::Expr {
927-
fn duplicate(&self, cx: @ExtCtxt) -> @ast::Expr {
928-
let folder = @Duplicator {
927+
fn duplicate(&self, cx: &ExtCtxt) -> @ast::Expr {
928+
let folder = Duplicator {
929929
cx: cx,
930-
} as @fold::ast_fold;
930+
};
931931
folder.fold_expr(*self)
932932
}
933933
}

src/libsyntax/ext/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use ext::build::AstBuilder;
1818

1919
use std::char;
2020

21-
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult {
21+
pub fn expand_syntax_ext(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult {
2222
// Gather all argument expressions
2323
let exprs = get_exprs_from_tts(cx, sp, tts);
2424
let mut bytes = ~[];

src/libsyntax/ext/cfg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use parse;
2525
use parse::token;
2626
use parse::attr::parser_attr;
2727

28-
pub fn expand_cfg(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult {
28+
pub fn expand_cfg(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree]) -> base::MacResult {
2929
let p = parse::new_parser_from_tts(cx.parse_sess(), cx.cfg(), tts.to_owned());
3030

3131
let mut cfgs = ~[];

src/libsyntax/ext/concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use codemap;
1515
use ext::base;
1616
use ext::build::AstBuilder;
1717

18-
pub fn expand_syntax_ext(cx: @base::ExtCtxt,
18+
pub fn expand_syntax_ext(cx: &base::ExtCtxt,
1919
sp: codemap::Span,
2020
tts: &[ast::token_tree]) -> base::MacResult {
2121
let es = base::get_exprs_from_tts(cx, sp, tts);

src/libsyntax/ext/concat_idents.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use opt_vec;
1616
use parse::token;
1717
use parse::token::{str_to_ident};
1818

19-
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
19+
pub fn expand_syntax_ext(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
2020
-> base::MacResult {
2121
let mut res_str = ~"";
2222
for (i, e) in tts.iter().enumerate() {

src/libsyntax/ext/deriving/clone.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
1616

17-
pub fn expand_deriving_clone(cx: @ExtCtxt,
17+
pub fn expand_deriving_clone(cx: &ExtCtxt,
1818
span: Span,
1919
mitem: @MetaItem,
2020
in_items: ~[@item])
@@ -42,7 +42,7 @@ pub fn expand_deriving_clone(cx: @ExtCtxt,
4242
trait_def.expand(mitem, in_items)
4343
}
4444

45-
pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
45+
pub fn expand_deriving_deep_clone(cx: &ExtCtxt,
4646
span: Span,
4747
mitem: @MetaItem,
4848
in_items: ~[@item])
@@ -74,7 +74,7 @@ pub fn expand_deriving_deep_clone(cx: @ExtCtxt,
7474

7575
fn cs_clone(
7676
name: &str,
77-
cx: @ExtCtxt, span: Span,
77+
cx: &ExtCtxt, span: Span,
7878
substr: &Substructure) -> @Expr {
7979
let clone_ident = substr.method_ident;
8080
let ctor_ident;

src/libsyntax/ext/deriving/cmp/eq.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
1616

17-
pub fn expand_deriving_eq(cx: @ExtCtxt,
17+
pub fn expand_deriving_eq(cx: &ExtCtxt,
1818
span: Span,
1919
mitem: @MetaItem,
2020
in_items: ~[@item]) -> ~[@item] {
2121
// structures are equal if all fields are equal, and non equal, if
2222
// any fields are not equal or if the enum variants are different
23-
fn cs_eq(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
23+
fn cs_eq(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
2424
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
2525
cx, span, substr)
2626
}
27-
fn cs_ne(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
27+
fn cs_ne(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
2828
cs_or(|cx, span, _, _| cx.expr_bool(span, true),
2929
cx, span, substr)
3030
}

src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ext::base::ExtCtxt;
1515
use ext::build::AstBuilder;
1616
use ext::deriving::generic::*;
1717

18-
pub fn expand_deriving_ord(cx: @ExtCtxt,
18+
pub fn expand_deriving_ord(cx: &ExtCtxt,
1919
span: Span,
2020
mitem: @MetaItem,
2121
in_items: ~[@item]) -> ~[@item] {
@@ -51,7 +51,7 @@ pub fn expand_deriving_ord(cx: @ExtCtxt,
5151
}
5252

5353
/// Strict inequality.
54-
fn cs_op(less: bool, equal: bool, cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
54+
fn cs_op(less: bool, equal: bool, cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
5555
let op = if less {ast::BiLt} else {ast::BiGt};
5656
cs_fold(
5757
false, // need foldr,

src/libsyntax/ext/deriving/cmp/totaleq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ use ext::base::ExtCtxt;
1414
use ext::build::AstBuilder;
1515
use ext::deriving::generic::*;
1616

17-
pub fn expand_deriving_totaleq(cx: @ExtCtxt,
17+
pub fn expand_deriving_totaleq(cx: &ExtCtxt,
1818
span: Span,
1919
mitem: @MetaItem,
2020
in_items: ~[@item]) -> ~[@item] {
21-
fn cs_equals(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
21+
fn cs_equals(cx: &ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
2222
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
2323
cx, span, substr)
2424
}

0 commit comments

Comments
 (0)