Skip to content

Commit 456884b

Browse files
sfackleralexcrichton
authored andcommitted
Remove useless RefCells
1 parent 2e24ef3 commit 456884b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/librustc/front/test.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use driver::session::Session;
1717
use front::config;
1818

19-
use std::cell::RefCell;
2019
use std::gc::{Gc, GC};
2120
use std::slice;
2221
use std::vec;
@@ -46,9 +45,9 @@ struct Test {
4645

4746
struct TestCtxt<'a> {
4847
sess: &'a Session,
49-
path: RefCell<Vec<ast::Ident>>,
48+
path: Vec<ast::Ident>,
5049
ext_cx: ExtCtxt<'a>,
51-
testfns: RefCell<Vec<Test> >,
50+
testfns: Vec<Test>,
5251
is_test_crate: bool,
5352
config: ast::CrateConfig,
5453
}
@@ -86,9 +85,9 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
8685
}
8786

8887
fn fold_item(&mut self, i: Gc<ast::Item>) -> SmallVector<Gc<ast::Item>> {
89-
self.cx.path.borrow_mut().push(i.ident);
88+
self.cx.path.push(i.ident);
9089
debug!("current path: {}",
91-
ast_util::path_name_i(self.cx.path.borrow().as_slice()));
90+
ast_util::path_name_i(self.cx.path.as_slice()));
9291

9392
if is_test_fn(&self.cx, i) || is_bench_fn(&self.cx, i) {
9493
match i.node {
@@ -102,20 +101,20 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
102101
debug!("this is a test function");
103102
let test = Test {
104103
span: i.span,
105-
path: self.cx.path.borrow().clone(),
104+
path: self.cx.path.clone(),
106105
bench: is_bench_fn(&self.cx, i),
107106
ignore: is_ignored(&self.cx, i),
108107
should_fail: should_fail(i)
109108
};
110-
self.cx.testfns.borrow_mut().push(test);
109+
self.cx.testfns.push(test);
111110
// debug!("have {} test/bench functions",
112111
// cx.testfns.len());
113112
}
114113
}
115114
}
116115

117116
let res = fold::noop_fold_item(&*i, self);
118-
self.cx.path.borrow_mut().pop();
117+
self.cx.path.pop();
119118
res
120119
}
121120

@@ -155,8 +154,8 @@ fn generate_test_harness(sess: &Session, krate: ast::Crate)
155154
deriving_hash_type_parameter: false,
156155
crate_name: "test".to_string(),
157156
}),
158-
path: RefCell::new(Vec::new()),
159-
testfns: RefCell::new(Vec::new()),
157+
path: Vec::new(),
158+
testfns: Vec::new(),
160159
is_test_crate: is_test_crate(&krate),
161160
config: krate.config.clone(),
162161
};
@@ -399,13 +398,13 @@ fn is_test_crate(krate: &ast::Crate) -> bool {
399398
}
400399

401400
fn mk_test_descs(cx: &TestCtxt) -> Gc<ast::Expr> {
402-
debug!("building test vector from {} tests", cx.testfns.borrow().len());
401+
debug!("building test vector from {} tests", cx.testfns.len());
403402

404403
box(GC) ast::Expr {
405404
id: ast::DUMMY_NODE_ID,
406405
node: ast::ExprVstore(box(GC) ast::Expr {
407406
id: ast::DUMMY_NODE_ID,
408-
node: ast::ExprVec(cx.testfns.borrow().iter().map(|test| {
407+
node: ast::ExprVec(cx.testfns.iter().map(|test| {
409408
mk_test_desc_and_fn_rec(cx, test)
410409
}).collect()),
411410
span: DUMMY_SP,

0 commit comments

Comments
 (0)