Skip to content

Commit 6043957

Browse files
committed
libsyntax: De-@mut ps::boxes
1 parent 5eafcc4 commit 6043957

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/libsyntax/ext/expand.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,8 +1306,9 @@ mod test {
13061306
let a3_name = gensym("a3");
13071307
// a context that renames from ("a",empty) to "a2" :
13081308
let ctxt2 = new_rename(ast::Ident::new(a_name),a2_name,EMPTY_CTXT);
1309-
let pending_renames = @mut ~[(ast::Ident::new(a_name),a2_name),
1310-
(ast::Ident{name:a_name,ctxt:ctxt2},a3_name)];
1309+
let pending_renames =
1310+
@RefCell::new(~[(ast::Ident::new(a_name),a2_name),
1311+
(ast::Ident{name:a_name,ctxt:ctxt2},a3_name)]);
13111312
let double_renamed = renames_to_fold(pending_renames).fold_crate(item_ast);
13121313
let mut path_finder = new_path_finder(~[]);
13131314
visit::walk_crate(&mut path_finder, &double_renamed, ());

src/libsyntax/print/pprust.rs

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use print::pp;
2828
use print::pprust;
2929

3030
use std::cast;
31+
use std::cell::RefCell;
3132
use std::char;
3233
use std::str;
3334
use std::io;
@@ -73,17 +74,23 @@ pub struct ps {
7374
comments: Option<~[comments::cmnt]>,
7475
literals: Option<~[comments::lit]>,
7576
cur_cmnt_and_lit: CurrentCommentAndLiteral,
76-
boxes: @mut ~[pp::breaks],
77+
boxes: RefCell<~[pp::breaks]>,
7778
ann: @pp_ann
7879
}
7980

8081
pub fn ibox(s: &mut ps, u: uint) {
81-
s.boxes.push(pp::inconsistent);
82+
{
83+
let mut boxes = s.boxes.borrow_mut();
84+
boxes.get().push(pp::inconsistent);
85+
}
8286
pp::ibox(&mut s.s, u);
8387
}
8488

8589
pub fn end(s: &mut ps) {
86-
s.boxes.pop();
90+
{
91+
let mut boxes = s.boxes.borrow_mut();
92+
boxes.get().pop();
93+
}
8794
pp::end(&mut s.s);
8895
}
8996

@@ -105,7 +112,7 @@ pub fn rust_printer_annotated(writer: ~io::Writer,
105112
cur_cmnt: 0,
106113
cur_lit: 0
107114
},
108-
boxes: @mut ~[],
115+
boxes: RefCell::new(~[]),
109116
ann: ann
110117
};
111118
}
@@ -148,7 +155,7 @@ pub fn print_crate(cm: @CodeMap,
148155
cur_cmnt: 0,
149156
cur_lit: 0
150157
},
151-
boxes: @mut ~[],
158+
boxes: RefCell::new(~[]),
152159
ann: ann
153160
};
154161
print_crate_(&mut s, crate);
@@ -243,13 +250,19 @@ pub fn variant_to_str(var: &ast::variant, intr: @ident_interner) -> ~str {
243250
}
244251

245252
pub fn cbox(s: &mut ps, u: uint) {
246-
s.boxes.push(pp::consistent);
253+
{
254+
let mut boxes = s.boxes.borrow_mut();
255+
boxes.get().push(pp::consistent);
256+
}
247257
pp::cbox(&mut s.s, u);
248258
}
249259

250260
// "raw box"
251261
pub fn rbox(s: &mut ps, u: uint, b: pp::breaks) {
252-
s.boxes.push(b);
262+
{
263+
let mut boxes = s.boxes.borrow_mut();
264+
boxes.get().push(b);
265+
}
253266
pp::rbox(&mut s.s, u, b);
254267
}
255268

@@ -306,10 +319,10 @@ pub fn is_bol(s: &mut ps) -> bool {
306319
}
307320

308321
pub fn in_cbox(s: &mut ps) -> bool {
309-
let boxes = &*s.boxes;
310-
let len = boxes.len();
322+
let boxes = s.boxes.borrow();
323+
let len = boxes.get().len();
311324
if len == 0u { return false; }
312-
return boxes[len - 1u] == pp::consistent;
325+
return boxes.get()[len - 1u] == pp::consistent;
313326
}
314327

315328
pub fn hardbreak_if_not_bol(s: &mut ps) {

0 commit comments

Comments
 (0)