Skip to content

Commit 9ff65b5

Browse files
committed
librustc: De-@mut TestCtxt::path
1 parent a5d9762 commit 9ff65b5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/librustc/front/test.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use driver::session;
1515
use front::config;
1616

17+
use std::cell::RefCell;
1718
use std::vec;
1819
use syntax::ast_util::*;
1920
use syntax::attr::AttrMetaMethods;
@@ -38,7 +39,7 @@ struct Test {
3839

3940
struct TestCtxt {
4041
sess: session::Session,
41-
path: ~[ast::Ident],
42+
path: RefCell<~[ast::Ident]>,
4243
ext_cx: @ExtCtxt,
4344
testfns: ~[Test],
4445
is_extra: bool,
@@ -78,9 +79,12 @@ impl fold::ast_fold for TestHarnessGenerator {
7879
}
7980

8081
fn fold_item(&self, i: @ast::item) -> SmallVector<@ast::item> {
81-
self.cx.path.push(i.ident);
82+
{
83+
let mut path = self.cx.path.borrow_mut();
84+
path.get().push(i.ident);
85+
}
8286
debug!("current path: {}",
83-
ast_util::path_name_i(self.cx.path.clone()));
87+
ast_util::path_name_i(self.cx.path.get()));
8488

8589
if is_test_fn(self.cx, i) || is_bench_fn(i) {
8690
match i.node {
@@ -95,7 +99,7 @@ impl fold::ast_fold for TestHarnessGenerator {
9599
debug!("this is a test function");
96100
let test = Test {
97101
span: i.span,
98-
path: self.cx.path.clone(),
102+
path: self.cx.path.get(),
99103
bench: is_bench_fn(i),
100104
ignore: is_ignored(self.cx, i),
101105
should_fail: should_fail(i)
@@ -108,7 +112,10 @@ impl fold::ast_fold for TestHarnessGenerator {
108112
}
109113

110114
let res = fold::noop_fold_item(i, self);
111-
self.cx.path.pop();
115+
{
116+
let mut path = self.cx.path.borrow_mut();
117+
path.get().pop();
118+
}
112119
res
113120
}
114121

@@ -147,7 +154,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate)
147154
let cx: @mut TestCtxt = @mut TestCtxt {
148155
sess: sess,
149156
ext_cx: ExtCtxt::new(sess.parse_sess, sess.opts.cfg.clone()),
150-
path: ~[],
157+
path: RefCell::new(~[]),
151158
testfns: ~[],
152159
is_extra: is_extra(&crate),
153160
config: crate.config.clone(),

0 commit comments

Comments
 (0)