libsyntax: De-@mut FileMap::multibyte_chars

This commit is contained in:
Patrick Walton 2013-12-30 16:26:07 -08:00
parent 27cc3d203b
commit 39f39ed40b
2 changed files with 7 additions and 5 deletions

View file

@ -223,7 +223,7 @@ pub struct FileMap {
/// Locations of lines beginnings in the source code /// Locations of lines beginnings in the source code
lines: RefCell<~[BytePos]>, lines: RefCell<~[BytePos]>,
/// Locations of multi-byte characters in the source code /// Locations of multi-byte characters in the source code
multibyte_chars: @mut ~[MultiByteChar], multibyte_chars: RefCell<~[MultiByteChar]>,
} }
impl FileMap { impl FileMap {
@ -258,7 +258,8 @@ impl FileMap {
pos: pos, pos: pos,
bytes: bytes, bytes: bytes,
}; };
self.multibyte_chars.push(mbc); let mut multibyte_chars = self.multibyte_chars.borrow_mut();
multibyte_chars.get().push(mbc);
} }
pub fn is_real_file(&self) -> bool { pub fn is_real_file(&self) -> bool {
@ -300,7 +301,7 @@ impl CodeMap {
name: filename, substr: substr, src: src, name: filename, substr: substr, src: src,
start_pos: Pos::from_uint(start_pos), start_pos: Pos::from_uint(start_pos),
lines: RefCell::new(~[]), lines: RefCell::new(~[]),
multibyte_chars: @mut ~[], multibyte_chars: RefCell::new(~[]),
}; };
files.push(filemap); files.push(filemap);
@ -471,7 +472,8 @@ impl CodeMap {
// The number of extra bytes due to multibyte chars in the FileMap // The number of extra bytes due to multibyte chars in the FileMap
let mut total_extra_bytes = 0; let mut total_extra_bytes = 0;
for mbc in map.multibyte_chars.iter() { let multibyte_chars = map.multibyte_chars.borrow();
for mbc in multibyte_chars.get().iter() {
debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos); debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos);
if mbc.pos < bpos { if mbc.pos < bpos {
total_extra_bytes += mbc.bytes; total_extra_bytes += mbc.bytes;

View file

@ -115,7 +115,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
src: s, src: s,
start_pos: codemap::BytePos(0), start_pos: codemap::BytePos(0),
lines: RefCell::new(~[]), lines: RefCell::new(~[]),
multibyte_chars: @mut ~[], multibyte_chars: RefCell::new(~[]),
}); });
base::MRExpr(cx.expr_str(sp, s)) base::MRExpr(cx.expr_str(sp, s))
} }