Skip to content

Commit 39f39ed

Browse files
committed
libsyntax: De-@mut FileMap::multibyte_chars
1 parent 27cc3d2 commit 39f39ed

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/libsyntax/codemap.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ pub struct FileMap {
223223
/// Locations of lines beginnings in the source code
224224
lines: RefCell<~[BytePos]>,
225225
/// Locations of multi-byte characters in the source code
226-
multibyte_chars: @mut ~[MultiByteChar],
226+
multibyte_chars: RefCell<~[MultiByteChar]>,
227227
}
228228

229229
impl FileMap {
@@ -258,7 +258,8 @@ impl FileMap {
258258
pos: pos,
259259
bytes: bytes,
260260
};
261-
self.multibyte_chars.push(mbc);
261+
let mut multibyte_chars = self.multibyte_chars.borrow_mut();
262+
multibyte_chars.get().push(mbc);
262263
}
263264

264265
pub fn is_real_file(&self) -> bool {
@@ -300,7 +301,7 @@ impl CodeMap {
300301
name: filename, substr: substr, src: src,
301302
start_pos: Pos::from_uint(start_pos),
302303
lines: RefCell::new(~[]),
303-
multibyte_chars: @mut ~[],
304+
multibyte_chars: RefCell::new(~[]),
304305
};
305306

306307
files.push(filemap);
@@ -471,7 +472,8 @@ impl CodeMap {
471472
// The number of extra bytes due to multibyte chars in the FileMap
472473
let mut total_extra_bytes = 0;
473474

474-
for mbc in map.multibyte_chars.iter() {
475+
let multibyte_chars = map.multibyte_chars.borrow();
476+
for mbc in multibyte_chars.get().iter() {
475477
debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos);
476478
if mbc.pos < bpos {
477479
total_extra_bytes += mbc.bytes;

src/libsyntax/ext/source_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::token_tree])
115115
src: s,
116116
start_pos: codemap::BytePos(0),
117117
lines: RefCell::new(~[]),
118-
multibyte_chars: @mut ~[],
118+
multibyte_chars: RefCell::new(~[]),
119119
});
120120
base::MRExpr(cx.expr_str(sp, s))
121121
}

0 commit comments

Comments
 (0)