Skip to content

Commit f3682b5

Browse files
committed
syntax: Fix fallout of removing get()
1 parent cd510b3 commit f3682b5

File tree

12 files changed

+159
-209
lines changed

12 files changed

+159
-209
lines changed

src/libsyntax/ast_map.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl PathElem {
4040
impl fmt::Show for PathElem {
4141
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4242
let slot = token::get_name(self.name());
43-
write!(f.buf, "{}", slot.get())
43+
write!(f.buf, "{}", slot)
4444
}
4545
}
4646

@@ -190,8 +190,8 @@ pub struct Map {
190190
impl Map {
191191
fn find_entry(&self, id: NodeId) -> Option<MapEntry> {
192192
let map = self.map.borrow();
193-
if map.get().len() > id as uint {
194-
Some(*map.get().get(id as uint))
193+
if map.len() > id as uint {
194+
Some(*map.get(id as uint))
195195
} else {
196196
None
197197
}
@@ -395,8 +395,7 @@ pub struct Ctx<'a, F> {
395395

396396
impl<'a, F> Ctx<'a, F> {
397397
fn insert(&self, id: NodeId, entry: MapEntry) {
398-
let mut map = self.map.map.borrow_mut();
399-
map.get().grow_set(id as uint, &NotPresent, entry);
398+
(*self.map.map.borrow_mut()).grow_set(id as uint, &NotPresent, entry);
400399
}
401400
}
402401

@@ -540,15 +539,15 @@ pub fn map_crate<F: FoldOps>(krate: Crate, fold_ops: F) -> (Crate, Map) {
540539
let map = map.map.borrow();
541540
// This only makes sense for ordered stores; note the
542541
// enumerate to count the number of entries.
543-
let (entries_less_1, _) = map.get().iter().filter(|&x| {
542+
let (entries_less_1, _) = (*map).iter().filter(|&x| {
544543
match *x {
545544
NotPresent => false,
546545
_ => true
547546
}
548547
}).enumerate().last().expect("AST map was empty after folding?");
549548

550549
let entries = entries_less_1 + 1;
551-
let vector_length = map.get().len();
550+
let vector_length = (*map).len();
552551
debug!("The AST map has {} entries with a maximum of {}: occupancy {:.1}%",
553552
entries, vector_length, (entries as f64 / vector_length as f64) * 100.);
554553
}

src/libsyntax/codemap.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ impl FileMap {
228228
pub fn next_line(&self, pos: BytePos) {
229229
// the new charpos must be > the last one (or it's the first one).
230230
let mut lines = self.lines.borrow_mut();;
231-
let line_len = lines.get().len();
232-
assert!(line_len == 0 || (*lines.get().get(line_len - 1) < pos))
233-
lines.get().push(pos);
231+
let line_len = lines.len();
232+
assert!(line_len == 0 || (*lines.get(line_len - 1) < pos))
233+
lines.push(pos);
234234
}
235235

236236
// get a line from the list of pre-computed line-beginnings
237237
pub fn get_line(&self, line: int) -> ~str {
238238
let mut lines = self.lines.borrow_mut();
239-
let begin: BytePos = *lines.get().get(line as uint) - self.start_pos;
239+
let begin: BytePos = *lines.get(line as uint) - self.start_pos;
240240
let begin = begin.to_uint();
241241
let slice = self.src.slice_from(begin);
242242
match slice.find('\n') {
@@ -251,7 +251,7 @@ impl FileMap {
251251
pos: pos,
252252
bytes: bytes,
253253
};
254-
self.multibyte_chars.borrow_mut().get().push(mbc);
254+
self.multibyte_chars.borrow_mut().push(mbc);
255255
}
256256

257257
pub fn is_real_file(&self) -> bool {
@@ -272,9 +272,9 @@ impl CodeMap {
272272

273273
pub fn new_filemap(&self, filename: FileName, src: ~str) -> Rc<FileMap> {
274274
let mut files = self.files.borrow_mut();
275-
let start_pos = match files.get().last() {
275+
let start_pos = match files.last() {
276276
None => 0,
277-
Some(last) => last.deref().start_pos.to_uint() + last.deref().src.len(),
277+
Some(last) => last.start_pos.to_uint() + last.src.len(),
278278
};
279279

280280
// Remove utf-8 BOM if any.
@@ -302,14 +302,14 @@ impl CodeMap {
302302
multibyte_chars: RefCell::new(Vec::new()),
303303
});
304304

305-
files.get().push(filemap.clone());
305+
files.push(filemap.clone());
306306

307307
filemap
308308
}
309309

310310
pub fn mk_substr_filename(&self, sp: Span) -> ~str {
311311
let pos = self.lookup_char_pos(sp.lo);
312-
format!("<{}:{}:{}>", pos.file.deref().name, pos.line, pos.col.to_uint() + 1)
312+
format!("<{}:{}:{}>", pos.file.name, pos.line, pos.col.to_uint() + 1)
313313
}
314314

315315
/// Lookup source information about a BytePos
@@ -320,15 +320,15 @@ impl CodeMap {
320320
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
321321
let loc = self.lookup_char_pos(pos);
322322
LocWithOpt {
323-
filename: loc.file.deref().name.to_str(),
323+
filename: loc.file.name.to_str(),
324324
line: loc.line,
325325
col: loc.col,
326326
file: Some(loc.file)
327327
}
328328
}
329329

330330
pub fn span_to_str(&self, sp: Span) -> ~str {
331-
if self.files.borrow().get().len() == 0 && sp == DUMMY_SP {
331+
if self.files.borrow().len() == 0 && sp == DUMMY_SP {
332332
return ~"no-location";
333333
}
334334

@@ -339,7 +339,7 @@ impl CodeMap {
339339
}
340340

341341
pub fn span_to_filename(&self, sp: Span) -> FileName {
342-
self.lookup_char_pos(sp.lo).file.deref().name.to_str()
342+
self.lookup_char_pos(sp.lo).file.name.to_str()
343343
}
344344

345345
pub fn span_to_lines(&self, sp: Span) -> FileLines {
@@ -360,16 +360,16 @@ impl CodeMap {
360360
// it's testing isn't true for all spans in the AST, so to allow the
361361
// caller to not have to fail (and it can't catch it since the CodeMap
362362
// isn't sendable), return None
363-
if begin.fm.deref().start_pos != end.fm.deref().start_pos {
363+
if begin.fm.start_pos != end.fm.start_pos {
364364
None
365365
} else {
366-
Some(begin.fm.deref().src.slice( begin.pos.to_uint(), end.pos.to_uint()).to_owned())
366+
Some(begin.fm.src.slice( begin.pos.to_uint(), end.pos.to_uint()).to_owned())
367367
}
368368
}
369369

370370
pub fn get_filemap(&self, filename: &str) -> Rc<FileMap> {
371-
for fm in self.files.borrow().get().iter() {
372-
if filename == fm.deref().name {
371+
for fm in self.files.borrow().iter() {
372+
if filename == fm.name {
373373
return fm.clone();
374374
}
375375
}
@@ -378,13 +378,13 @@ impl CodeMap {
378378

379379
fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
380380
let files = self.files.borrow();
381-
let files = files.get();
381+
let files = files;
382382
let len = files.len();
383383
let mut a = 0u;
384384
let mut b = len;
385385
while b - a > 1u {
386386
let m = (a + b) / 2u;
387-
if files.get(m).deref().start_pos > pos {
387+
if files.get(m).start_pos > pos {
388388
b = m;
389389
} else {
390390
a = m;
@@ -394,8 +394,8 @@ impl CodeMap {
394394
// filemap, but are not the filemaps we want (because they are length 0, they cannot
395395
// contain what we are looking for). So, rewind until we find a useful filemap.
396396
loop {
397-
let lines = files.get(a).deref().lines.borrow();
398-
let lines = lines.get();
397+
let lines = files.get(a).lines.borrow();
398+
let lines = lines;
399399
if lines.len() > 0 {
400400
break;
401401
}
@@ -415,14 +415,14 @@ impl CodeMap {
415415
let idx = self.lookup_filemap_idx(pos);
416416

417417
let files = self.files.borrow();
418-
let f = files.get().get(idx).clone();
418+
let f = files.get(idx).clone();
419419
let mut a = 0u;
420420
{
421-
let mut lines = f.deref().lines.borrow_mut();
422-
let mut b = lines.get().len();
421+
let mut lines = f.lines.borrow_mut();
422+
let mut b = lines.len();
423423
while b - a > 1u {
424424
let m = (a + b) / 2u;
425-
if *lines.get().get(m) > pos { b = m; } else { a = m; }
425+
if *lines.get(m) > pos { b = m; } else { a = m; }
426426
}
427427
}
428428
FileMapAndLine {fm: f, line: a}
@@ -432,7 +432,7 @@ impl CodeMap {
432432
let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
433433
let line = a + 1u; // Line numbers start at 1
434434
let chpos = self.bytepos_to_file_charpos(pos);
435-
let linebpos = *f.deref().lines.borrow().get().get(a);
435+
let linebpos = *f.lines.borrow().get(a);
436436
let linechpos = self.bytepos_to_file_charpos(linebpos);
437437
debug!("codemap: byte pos {:?} is on the line at byte pos {:?}",
438438
pos, linebpos);
@@ -449,8 +449,8 @@ impl CodeMap {
449449

450450
fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {
451451
let idx = self.lookup_filemap_idx(bpos);
452-
let fm = self.files.borrow().get().get(idx).clone();
453-
let offset = bpos - fm.deref().start_pos;
452+
let fm = self.files.borrow().get(idx).clone();
453+
let offset = bpos - fm.start_pos;
454454
FileMapAndBytePos {fm: fm, pos: offset}
455455
}
456456

@@ -459,12 +459,12 @@ impl CodeMap {
459459
debug!("codemap: converting {:?} to char pos", bpos);
460460
let idx = self.lookup_filemap_idx(bpos);
461461
let files = self.files.borrow();
462-
let map = files.get().get(idx);
462+
let map = files.get(idx);
463463

464464
// The number of extra bytes due to multibyte chars in the FileMap
465465
let mut total_extra_bytes = 0;
466466

467-
for mbc in map.deref().multibyte_chars.borrow().get().iter() {
467+
for mbc in map.multibyte_chars.borrow().iter() {
468468
debug!("codemap: {:?}-byte char at {:?}", mbc.bytes, mbc.pos);
469469
if mbc.pos < bpos {
470470
// every character is at least one byte, so we only
@@ -478,8 +478,8 @@ impl CodeMap {
478478
}
479479
}
480480

481-
assert!(map.deref().start_pos.to_uint() + total_extra_bytes <= bpos.to_uint());
482-
CharPos(bpos.to_uint() - map.deref().start_pos.to_uint() - total_extra_bytes)
481+
assert!(map.start_pos.to_uint() + total_extra_bytes <= bpos.to_uint());
482+
CharPos(bpos.to_uint() - map.start_pos.to_uint() - total_extra_bytes)
483483
}
484484
}
485485

src/libsyntax/diagnostic.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ pub struct Handler {
8484
8585
impl Handler {
8686
pub fn fatal(&self, msg: &str) -> ! {
87-
self.emit.borrow_mut().get().emit(None, msg, Fatal);
87+
self.emit.borrow_mut().emit(None, msg, Fatal);
8888
fail!(FatalError);
8989
}
9090
pub fn err(&self, msg: &str) {
91-
self.emit.borrow_mut().get().emit(None, msg, Error);
91+
self.emit.borrow_mut().emit(None, msg, Error);
9292
self.bump_err_count();
9393
}
9494
pub fn bump_err_count(&self) {
@@ -113,13 +113,13 @@ impl Handler {
113113
self.fatal(s);
114114
}
115115
pub fn warn(&self, msg: &str) {
116-
self.emit.borrow_mut().get().emit(None, msg, Warning);
116+
self.emit.borrow_mut().emit(None, msg, Warning);
117117
}
118118
pub fn note(&self, msg: &str) {
119-
self.emit.borrow_mut().get().emit(None, msg, Note);
119+
self.emit.borrow_mut().emit(None, msg, Note);
120120
}
121121
pub fn bug(&self, msg: &str) -> ! {
122-
self.emit.borrow_mut().get().emit(None, msg, Bug);
122+
self.emit.borrow_mut().emit(None, msg, Bug);
123123
fail!(ExplicitBug);
124124
}
125125
pub fn unimpl(&self, msg: &str) -> ! {
@@ -129,11 +129,11 @@ impl Handler {
129129
cmsp: Option<(&codemap::CodeMap, Span)>,
130130
msg: &str,
131131
lvl: Level) {
132-
self.emit.borrow_mut().get().emit(cmsp, msg, lvl);
132+
self.emit.borrow_mut().emit(cmsp, msg, lvl);
133133
}
134134
pub fn custom_emit(&self, cm: &codemap::CodeMap,
135135
sp: Span, msg: &str, lvl: Level) {
136-
self.emit.borrow_mut().get().custom_emit(cm, sp, msg, lvl);
136+
self.emit.borrow_mut().custom_emit(cm, sp, msg, lvl);
137137
}
138138
}
139139
@@ -301,7 +301,7 @@ fn highlight_lines(err: &mut EmitterWriter,
301301
sp: Span,
302302
lvl: Level,
303303
lines: codemap::FileLines) -> io::IoResult<()> {
304-
let fm = lines.file.deref();
304+
let fm = &*lines.file;
305305

306306
let mut elided = false;
307307
let mut display_lines = lines.lines.as_slice();
@@ -374,7 +374,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter,
374374
sp: Span,
375375
lvl: Level,
376376
lines: codemap::FileLines) -> io::IoResult<()> {
377-
let fm = lines.file.deref();
377+
let fm = &*lines.file;
378378

379379
let lines = lines.lines.as_slice();
380380
if lines.len() > MAX_LINES {

src/libsyntax/ext/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
628628
vec!(
629629
self.expr_str(span, msg),
630630
self.expr_str(span,
631-
token::intern_and_get_ident(loc.file.deref().name)),
631+
token::intern_and_get_ident(loc.file.name)),
632632
self.expr_uint(span, loc.line)))
633633
}
634634

0 commit comments

Comments
 (0)