Skip to content

Commit b0e3cb5

Browse files
committed
Remove a RefCell from pprust::State.
1 parent f65638e commit b0e3cb5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use print::pp::{Breaks, Consistent, Inconsistent, eof};
2626
use print::pp;
2727

2828
use std::cast;
29-
use std::cell::RefCell;
3029
use std::char;
3130
use std::str;
3231
use std::io;
@@ -61,7 +60,7 @@ pub struct State<'a> {
6160
comments: Option<Vec<comments::Comment> >,
6261
literals: Option<Vec<comments::Literal> >,
6362
cur_cmnt_and_lit: CurrentCommentAndLiteral,
64-
boxes: RefCell<Vec<pp::Breaks> >,
63+
boxes: Vec<pp::Breaks>,
6564
ann: &'a PpAnn
6665
}
6766

@@ -82,7 +81,7 @@ pub fn rust_printer_annotated<'a>(writer: ~io::Writer,
8281
cur_cmnt: 0,
8382
cur_lit: 0
8483
},
85-
boxes: RefCell::new(Vec::new()),
84+
boxes: Vec::new(),
8685
ann: ann
8786
}
8887
}
@@ -124,7 +123,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
124123
cur_cmnt: 0,
125124
cur_lit: 0
126125
},
127-
boxes: RefCell::new(Vec::new()),
126+
boxes: Vec::new(),
128127
ann: ann
129128
};
130129
try!(s.print_mod(&krate.module, krate.attrs.as_slice()));
@@ -238,23 +237,23 @@ pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> ~str {
238237

239238
impl<'a> State<'a> {
240239
pub fn ibox(&mut self, u: uint) -> IoResult<()> {
241-
self.boxes.borrow_mut().push(pp::Inconsistent);
240+
self.boxes.push(pp::Inconsistent);
242241
pp::ibox(&mut self.s, u)
243242
}
244243

245244
pub fn end(&mut self) -> IoResult<()> {
246-
self.boxes.borrow_mut().pop().unwrap();
245+
self.boxes.pop().unwrap();
247246
pp::end(&mut self.s)
248247
}
249248

250249
pub fn cbox(&mut self, u: uint) -> IoResult<()> {
251-
self.boxes.borrow_mut().push(pp::Consistent);
250+
self.boxes.push(pp::Consistent);
252251
pp::cbox(&mut self.s, u)
253252
}
254253

255254
// "raw box"
256255
pub fn rbox(&mut self, u: uint, b: pp::Breaks) -> IoResult<()> {
257-
self.boxes.borrow_mut().push(b);
256+
self.boxes.push(b);
258257
pp::rbox(&mut self.s, u, b)
259258
}
260259

@@ -321,8 +320,8 @@ impl<'a> State<'a> {
321320
self.s.last_token().is_eof() || self.s.last_token().is_hardbreak_tok()
322321
}
323322

324-
pub fn in_cbox(&mut self) -> bool {
325-
match self.boxes.borrow().last() {
323+
pub fn in_cbox(&self) -> bool {
324+
match self.boxes.last() {
326325
Some(&last_box) => last_box == pp::Consistent,
327326
None => false
328327
}

0 commit comments

Comments
 (0)