Skip to content

Commit 8143662

Browse files
committed
Start passing around &mut ExtCtxt
1 parent 3965ddd commit 8143662

File tree

16 files changed

+49
-48
lines changed

16 files changed

+49
-48
lines changed

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: &mut 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: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ pub struct SyntaxExpanderTT {
4545

4646
pub trait SyntaxExpanderTTTrait {
4747
fn expand(&self,
48-
ecx: &ExtCtxt,
48+
ecx: &mut ExtCtxt,
4949
span: Span,
5050
token_tree: &[ast::token_tree],
5151
context: ast::SyntaxContext)
5252
-> MacResult;
5353
}
5454

5555
pub type SyntaxExpanderTTFunNoCtxt =
56-
fn(ecx: &ExtCtxt, span: codemap::Span, token_tree: &[ast::token_tree])
56+
fn(ecx: &mut ExtCtxt, span: codemap::Span, token_tree: &[ast::token_tree])
5757
-> MacResult;
5858

5959
enum SyntaxExpanderTTExpander {
@@ -62,7 +62,7 @@ enum SyntaxExpanderTTExpander {
6262

6363
impl SyntaxExpanderTTTrait for SyntaxExpanderTT {
6464
fn expand(&self,
65-
ecx: &ExtCtxt,
65+
ecx: &mut ExtCtxt,
6666
span: Span,
6767
token_tree: &[ast::token_tree],
6868
_: ast::SyntaxContext)
@@ -87,7 +87,7 @@ pub struct SyntaxExpanderTTItem {
8787

8888
pub trait SyntaxExpanderTTItemTrait {
8989
fn expand(&self,
90-
cx: &ExtCtxt,
90+
cx: &mut ExtCtxt,
9191
sp: Span,
9292
ident: ast::Ident,
9393
token_tree: ~[ast::token_tree],
@@ -97,7 +97,7 @@ pub trait SyntaxExpanderTTItemTrait {
9797

9898
impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem {
9999
fn expand(&self,
100-
cx: &ExtCtxt,
100+
cx: &mut ExtCtxt,
101101
sp: Span,
102102
ident: ast::Ident,
103103
token_tree: ~[ast::token_tree],
@@ -115,11 +115,11 @@ impl SyntaxExpanderTTItemTrait for SyntaxExpanderTTItem {
115115
}
116116

117117
pub type SyntaxExpanderTTItemFun =
118-
fn(&ExtCtxt, Span, ast::Ident, ~[ast::token_tree], ast::SyntaxContext)
118+
fn(&mut ExtCtxt, Span, ast::Ident, ~[ast::token_tree], ast::SyntaxContext)
119119
-> MacResult;
120120

121121
pub type SyntaxExpanderTTItemFunNoCtxt =
122-
fn(&ExtCtxt, Span, ast::Ident, ~[ast::token_tree]) -> MacResult;
122+
fn(&mut ExtCtxt, Span, ast::Ident, ~[ast::token_tree]) -> MacResult;
123123

124124
pub trait AnyMacro {
125125
fn make_expr(&self) -> @ast::Expr;
@@ -320,7 +320,7 @@ impl ExtCtxt {
320320
}
321321
}
322322

323-
pub fn expand_expr(&self, mut e: @ast::Expr) -> @ast::Expr {
323+
pub fn expand_expr(&mut self, mut e: @ast::Expr) -> @ast::Expr {
324324
loop {
325325
match e.node {
326326
ast::ExprMac(..) => {

src/libsyntax/ext/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub trait AstBuilder {
236236
vis: ast::visibility, path: ~[ast::Ident]) -> ast::view_item;
237237
}
238238

239-
impl<'a> AstBuilder for &'a ExtCtxt {
239+
impl AstBuilder for ExtCtxt {
240240
fn path(&self, span: Span, strs: ~[ast::Ident]) -> ast::Path {
241241
self.path_all(span, false, strs, opt_vec::Empty, ~[])
242242
}
@@ -686,12 +686,12 @@ impl<'a> AstBuilder for &'a ExtCtxt {
686686
}
687687
fn lambda0(&self, _span: Span, blk: P<ast::Block>) -> @ast::Expr {
688688
let blk_e = self.expr(blk.span, ast::ExprBlock(blk));
689-
quote_expr!(*self, || $blk_e )
689+
quote_expr!(self, || $blk_e )
690690
}
691691

692692
fn lambda1(&self, _span: Span, blk: P<ast::Block>, ident: ast::Ident) -> @ast::Expr {
693693
let blk_e = self.expr(blk.span, ast::ExprBlock(blk));
694-
quote_expr!(*self, |$ident| $blk_e )
694+
quote_expr!(self, |$ident| $blk_e )
695695
}
696696

697697
fn lambda_expr(&self, span: Span, ids: ~[ast::Ident], expr: @ast::Expr) -> @ast::Expr {

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: &mut 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: &mut 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: &mut 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: &mut 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/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use ext::build::AstBuilder;
2222

2323
use std::os;
2424

25-
pub fn expand_option_env(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
25+
pub fn expand_option_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
2626
-> base::MacResult {
2727
let var = get_single_str_from_tts(cx, sp, tts, "option_env!");
2828

@@ -33,7 +33,7 @@ pub fn expand_option_env(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
3333
MRExpr(e)
3434
}
3535

36-
pub fn expand_env(cx: &ExtCtxt, sp: Span, tts: &[ast::token_tree])
36+
pub fn expand_env(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
3737
-> base::MacResult {
3838
let exprs = get_exprs_from_tts(cx, sp, tts);
3939

src/libsyntax/ext/expand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
932932

933933
pub struct MacroExpander<'a> {
934934
extsbox: @mut SyntaxEnv,
935-
cx: &'a ExtCtxt,
935+
cx: &'a mut ExtCtxt,
936936
}
937937

938938
impl<'a> ast_fold for MacroExpander<'a> {
@@ -970,10 +970,10 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess,
970970
// exts table through the fold, but that would require updating
971971
// every method/element of AstFoldFns in fold.rs.
972972
let extsbox = syntax_expander_table();
973-
let cx = ExtCtxt::new(parse_sess, cfg.clone());
973+
let mut cx = ExtCtxt::new(parse_sess, cfg.clone());
974974
let mut expander = MacroExpander {
975975
extsbox: @mut extsbox,
976-
cx: &cx,
976+
cx: &mut cx,
977977
};
978978

979979
let ret = expander.fold_crate(c);

src/libsyntax/ext/fmt.rs

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

18-
pub fn expand_syntax_ext(ecx: &base::ExtCtxt, sp: Span,
18+
pub fn expand_syntax_ext(ecx: &mut base::ExtCtxt, sp: Span,
1919
_tts: &[ast::token_tree]) -> base::MacResult {
2020
ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead");
2121
ecx.parse_sess.span_diagnostic.span_note(sp,

0 commit comments

Comments
 (0)