diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 764935d5305..6193e5e8fa1 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -63,7 +63,7 @@ pub fn modify_for_testing(sess: session::Session, } struct TestHarnessGenerator { - cx: @TestCtxt, + cx: TestCtxt, } impl fold::ast_fold for TestHarnessGenerator { @@ -73,7 +73,7 @@ impl fold::ast_fold for TestHarnessGenerator { // Add a special __test module to the crate that will contain code // generated for the test harness ast::Crate { - module: add_test_module(self.cx, &folded.module), + module: add_test_module(&self.cx, &folded.module), .. folded } } @@ -86,7 +86,7 @@ impl fold::ast_fold for TestHarnessGenerator { debug!("current path: {}", ast_util::path_name_i(self.cx.path.get())); - if is_test_fn(self.cx, i) || is_bench_fn(i) { + if is_test_fn(&self.cx, i) || is_bench_fn(i) { match i.node { ast::item_fn(_, purity, _, _, _) if purity == ast::unsafe_fn => { @@ -101,7 +101,7 @@ impl fold::ast_fold for TestHarnessGenerator { span: i.span, path: self.cx.path.get(), bench: is_bench_fn(i), - ignore: is_ignored(self.cx, i), + ignore: is_ignored(&self.cx, i), should_fail: should_fail(i) }; { @@ -126,7 +126,7 @@ impl fold::ast_fold for TestHarnessGenerator { // Remove any #[main] from the AST so it doesn't clash with // the one we're going to add. Only if compiling an executable. - fn nomain(cx: @TestCtxt, item: @ast::item) -> @ast::item { + fn nomain(cx: &TestCtxt, item: @ast::item) -> @ast::item { if !cx.sess.building_library.get() { @ast::item { attrs: item.attrs.iter().filter_map(|attr| { @@ -145,7 +145,7 @@ impl fold::ast_fold for TestHarnessGenerator { let mod_nomain = ast::_mod { view_items: m.view_items.clone(), - items: m.items.iter().map(|i| nomain(self.cx, *i)).collect(), + items: m.items.iter().map(|i| nomain(&self.cx, *i)).collect(), }; fold::noop_fold_mod(&mod_nomain, self) @@ -154,7 +154,7 @@ impl fold::ast_fold for TestHarnessGenerator { fn generate_test_harness(sess: session::Session, crate: ast::Crate) -> ast::Crate { - let cx: @TestCtxt = @TestCtxt { + let mut cx: TestCtxt = TestCtxt { sess: sess, ext_cx: ExtCtxt::new(sess.parse_sess, sess.opts.cfg.clone()), path: RefCell::new(~[]), @@ -176,7 +176,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate) cx: cx }; let res = fold.fold_crate(crate); - cx.ext_cx.bt_pop(); + fold.cx.ext_cx.bt_pop(); return res; } @@ -189,7 +189,7 @@ fn strip_test_functions(crate: ast::Crate) -> ast::Crate { }) } -fn is_test_fn(cx: @TestCtxt, i: @ast::item) -> bool { +fn is_test_fn(cx: &TestCtxt, i: @ast::item) -> bool { let has_test_attr = attr::contains_name(i.attrs, "test"); fn has_test_signature(i: @ast::item) -> bool { @@ -242,7 +242,7 @@ fn is_bench_fn(i: @ast::item) -> bool { return has_bench_attr && has_test_signature(i); } -fn is_ignored(cx: @TestCtxt, i: @ast::item) -> bool { +fn is_ignored(cx: &TestCtxt, i: @ast::item) -> bool { i.attrs.iter().any(|attr| { // check ignore(cfg(foo, bar)) "ignore" == attr.name() && match attr.meta_item_list() { diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b5f8329a0b2..ccbc533fbcc 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -297,15 +297,15 @@ pub fn syntax_expander_table() -> SyntaxEnv { pub struct ExtCtxt { parse_sess: @mut parse::ParseSess, cfg: ast::CrateConfig, - backtrace: @mut Option<@ExpnInfo>, + backtrace: Option<@ExpnInfo>, // These two @mut's should really not be here, // but the self types for CtxtRepr are all wrong // and there are bugs in the code for object // types that make this hard to get right at the // moment. - nmatsakis - mod_path: @mut ~[ast::Ident], - trace_mac: @mut bool + mod_path: ~[ast::Ident], + trace_mac: bool } impl ExtCtxt { @@ -314,9 +314,9 @@ impl ExtCtxt { ExtCtxt { parse_sess: parse_sess, cfg: cfg, - backtrace: @mut None, - mod_path: @mut ~[], - trace_mac: @mut false + backtrace: None, + mod_path: ~[], + trace_mac: false } } @@ -339,32 +339,32 @@ impl ExtCtxt { pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess } pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() } pub fn call_site(&self) -> Span { - match *self.backtrace { + match self.backtrace { Some(@ExpnInfo {call_site: cs, ..}) => cs, None => self.bug("missing top span") } } pub fn print_backtrace(&self) { } - pub fn backtrace(&self) -> Option<@ExpnInfo> { *self.backtrace } - pub fn mod_push(&self, i: ast::Ident) { self.mod_path.push(i); } - pub fn mod_pop(&self) { self.mod_path.pop(); } - pub fn mod_path(&self) -> ~[ast::Ident] { (*self.mod_path).clone() } - pub fn bt_push(&self, ei: codemap::ExpnInfo) { + pub fn backtrace(&self) -> Option<@ExpnInfo> { self.backtrace } + pub fn mod_push(&mut self, i: ast::Ident) { self.mod_path.push(i); } + pub fn mod_pop(&mut self) { self.mod_path.pop(); } + pub fn mod_path(&self) -> ~[ast::Ident] { self.mod_path.clone() } + pub fn bt_push(&mut self, ei: codemap::ExpnInfo) { match ei { ExpnInfo {call_site: cs, callee: ref callee} => { - *self.backtrace = + self.backtrace = Some(@ExpnInfo { call_site: Span {lo: cs.lo, hi: cs.hi, - expn_info: *self.backtrace}, + expn_info: self.backtrace}, callee: *callee}); } } } - pub fn bt_pop(&self) { - match *self.backtrace { + pub fn bt_pop(&mut self) { + match self.backtrace { Some(@ExpnInfo { call_site: Span {expn_info: prev, ..}, ..}) => { - *self.backtrace = prev + self.backtrace = prev } _ => self.bug("tried to pop without a push") } @@ -394,10 +394,10 @@ impl ExtCtxt { self.parse_sess.span_diagnostic.handler().bug(msg); } pub fn trace_macros(&self) -> bool { - *self.trace_mac + self.trace_mac } - pub fn set_trace_macros(&self, x: bool) { - *self.trace_mac = x + pub fn set_trace_macros(&mut self, x: bool) { + self.trace_mac = x } pub fn str_of(&self, id: ast::Ident) -> @str { ident_to_str(&id)