Skip to content

Commit dc83034

Browse files
committed
Remove @muts from ExtCtxt
1 parent 8143662 commit dc83034

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

src/librustc/front/test.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn modify_for_testing(sess: session::Session,
6363
}
6464

6565
struct TestHarnessGenerator {
66-
cx: @TestCtxt,
66+
cx: TestCtxt,
6767
}
6868

6969
impl fold::ast_fold for TestHarnessGenerator {
@@ -73,7 +73,7 @@ impl fold::ast_fold for TestHarnessGenerator {
7373
// Add a special __test module to the crate that will contain code
7474
// generated for the test harness
7575
ast::Crate {
76-
module: add_test_module(self.cx, &folded.module),
76+
module: add_test_module(&self.cx, &folded.module),
7777
.. folded
7878
}
7979
}
@@ -86,7 +86,7 @@ impl fold::ast_fold for TestHarnessGenerator {
8686
debug!("current path: {}",
8787
ast_util::path_name_i(self.cx.path.get()));
8888

89-
if is_test_fn(self.cx, i) || is_bench_fn(i) {
89+
if is_test_fn(&self.cx, i) || is_bench_fn(i) {
9090
match i.node {
9191
ast::item_fn(_, purity, _, _, _)
9292
if purity == ast::unsafe_fn => {
@@ -101,7 +101,7 @@ impl fold::ast_fold for TestHarnessGenerator {
101101
span: i.span,
102102
path: self.cx.path.get(),
103103
bench: is_bench_fn(i),
104-
ignore: is_ignored(self.cx, i),
104+
ignore: is_ignored(&self.cx, i),
105105
should_fail: should_fail(i)
106106
};
107107
{
@@ -126,7 +126,7 @@ impl fold::ast_fold for TestHarnessGenerator {
126126
// Remove any #[main] from the AST so it doesn't clash with
127127
// the one we're going to add. Only if compiling an executable.
128128

129-
fn nomain(cx: @TestCtxt, item: @ast::item) -> @ast::item {
129+
fn nomain(cx: &TestCtxt, item: @ast::item) -> @ast::item {
130130
if !cx.sess.building_library.get() {
131131
@ast::item {
132132
attrs: item.attrs.iter().filter_map(|attr| {
@@ -145,7 +145,7 @@ impl fold::ast_fold for TestHarnessGenerator {
145145

146146
let mod_nomain = ast::_mod {
147147
view_items: m.view_items.clone(),
148-
items: m.items.iter().map(|i| nomain(self.cx, *i)).collect(),
148+
items: m.items.iter().map(|i| nomain(&self.cx, *i)).collect(),
149149
};
150150

151151
fold::noop_fold_mod(&mod_nomain, self)
@@ -154,7 +154,7 @@ impl fold::ast_fold for TestHarnessGenerator {
154154

155155
fn generate_test_harness(sess: session::Session, crate: ast::Crate)
156156
-> ast::Crate {
157-
let cx: @TestCtxt = @TestCtxt {
157+
let mut cx: TestCtxt = TestCtxt {
158158
sess: sess,
159159
ext_cx: ExtCtxt::new(sess.parse_sess, sess.opts.cfg.clone()),
160160
path: RefCell::new(~[]),
@@ -176,7 +176,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate)
176176
cx: cx
177177
};
178178
let res = fold.fold_crate(crate);
179-
cx.ext_cx.bt_pop();
179+
fold.cx.ext_cx.bt_pop();
180180
return res;
181181
}
182182

@@ -189,7 +189,7 @@ fn strip_test_functions(crate: ast::Crate) -> ast::Crate {
189189
})
190190
}
191191

192-
fn is_test_fn(cx: @TestCtxt, i: @ast::item) -> bool {
192+
fn is_test_fn(cx: &TestCtxt, i: @ast::item) -> bool {
193193
let has_test_attr = attr::contains_name(i.attrs, "test");
194194

195195
fn has_test_signature(i: @ast::item) -> bool {
@@ -242,7 +242,7 @@ fn is_bench_fn(i: @ast::item) -> bool {
242242
return has_bench_attr && has_test_signature(i);
243243
}
244244

245-
fn is_ignored(cx: @TestCtxt, i: @ast::item) -> bool {
245+
fn is_ignored(cx: &TestCtxt, i: @ast::item) -> bool {
246246
i.attrs.iter().any(|attr| {
247247
// check ignore(cfg(foo, bar))
248248
"ignore" == attr.name() && match attr.meta_item_list() {

src/libsyntax/ext/base.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ pub fn syntax_expander_table() -> SyntaxEnv {
297297
pub struct ExtCtxt {
298298
parse_sess: @mut parse::ParseSess,
299299
cfg: ast::CrateConfig,
300-
backtrace: @mut Option<@ExpnInfo>,
300+
backtrace: Option<@ExpnInfo>,
301301

302302
// These two @mut's should really not be here,
303303
// but the self types for CtxtRepr are all wrong
304304
// and there are bugs in the code for object
305305
// types that make this hard to get right at the
306306
// moment. - nmatsakis
307-
mod_path: @mut ~[ast::Ident],
308-
trace_mac: @mut bool
307+
mod_path: ~[ast::Ident],
308+
trace_mac: bool
309309
}
310310

311311
impl ExtCtxt {
@@ -314,9 +314,9 @@ impl ExtCtxt {
314314
ExtCtxt {
315315
parse_sess: parse_sess,
316316
cfg: cfg,
317-
backtrace: @mut None,
318-
mod_path: @mut ~[],
319-
trace_mac: @mut false
317+
backtrace: None,
318+
mod_path: ~[],
319+
trace_mac: false
320320
}
321321
}
322322

@@ -339,32 +339,32 @@ impl ExtCtxt {
339339
pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
340340
pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
341341
pub fn call_site(&self) -> Span {
342-
match *self.backtrace {
342+
match self.backtrace {
343343
Some(@ExpnInfo {call_site: cs, ..}) => cs,
344344
None => self.bug("missing top span")
345345
}
346346
}
347347
pub fn print_backtrace(&self) { }
348-
pub fn backtrace(&self) -> Option<@ExpnInfo> { *self.backtrace }
349-
pub fn mod_push(&self, i: ast::Ident) { self.mod_path.push(i); }
350-
pub fn mod_pop(&self) { self.mod_path.pop(); }
351-
pub fn mod_path(&self) -> ~[ast::Ident] { (*self.mod_path).clone() }
352-
pub fn bt_push(&self, ei: codemap::ExpnInfo) {
348+
pub fn backtrace(&self) -> Option<@ExpnInfo> { self.backtrace }
349+
pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); }
350+
pub fn mod_pop(&mut self) { self.mod_path.pop(); }
351+
pub fn mod_path(&self) -> ~[ast::Ident] { self.mod_path.clone() }
352+
pub fn bt_push(&mut self, ei: codemap::ExpnInfo) {
353353
match ei {
354354
ExpnInfo {call_site: cs, callee: ref callee} => {
355-
*self.backtrace =
355+
self.backtrace =
356356
Some(@ExpnInfo {
357357
call_site: Span {lo: cs.lo, hi: cs.hi,
358-
expn_info: *self.backtrace},
358+
expn_info: self.backtrace},
359359
callee: *callee});
360360
}
361361
}
362362
}
363-
pub fn bt_pop(&self) {
364-
match *self.backtrace {
363+
pub fn bt_pop(&mut self) {
364+
match self.backtrace {
365365
Some(@ExpnInfo {
366366
call_site: Span {expn_info: prev, ..}, ..}) => {
367-
*self.backtrace = prev
367+
self.backtrace = prev
368368
}
369369
_ => self.bug("tried to pop without a push")
370370
}
@@ -394,10 +394,10 @@ impl ExtCtxt {
394394
self.parse_sess.span_diagnostic.handler().bug(msg);
395395
}
396396
pub fn trace_macros(&self) -> bool {
397-
*self.trace_mac
397+
self.trace_mac
398398
}
399-
pub fn set_trace_macros(&self, x: bool) {
400-
*self.trace_mac = x
399+
pub fn set_trace_macros(&mut self, x: bool) {
400+
self.trace_mac = x
401401
}
402402
pub fn str_of(&self, id: ast::Ident) -> @str {
403403
ident_to_str(&id)

0 commit comments

Comments
 (0)