Skip to content

Commit d5e35e3

Browse files
committed
Convert CodeMap and FileMap to use &self instead of @self
1 parent bcccf33 commit d5e35e3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/libsyntax/codemap.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ pub impl FileMap {
205205
start_pos);
206206
}
207207

208-
fn next_line(@self, +pos: FilePos) {
208+
fn next_line(&self, +pos: FilePos) {
209209
self.lines.push(pos);
210210
}
211211

212-
pub fn get_line(@self, line: int) -> ~str unsafe {
212+
pub fn get_line(&self, line: int) -> ~str unsafe {
213213
let begin: BytePos = self.lines[line].byte - self.start_pos.byte;
214214
let begin = begin.to_uint();
215215
let end = match str::find_char_from(*self.src, '\n', begin) {
@@ -232,7 +232,7 @@ pub impl CodeMap {
232232
}
233233
}
234234

235-
pub fn add_filemap(@self, filemap: @FileMap) {
235+
pub fn add_filemap(&self, filemap: @FileMap) {
236236
let expected_byte_pos = if self.files.len() == 0 {
237237
0
238238
} else {
@@ -248,23 +248,23 @@ pub impl CodeMap {
248248
self.files.push(filemap);
249249
}
250250

251-
pub fn mk_substr_filename(@self, sp: span) -> ~str {
251+
pub fn mk_substr_filename(&self, sp: span) -> ~str {
252252
let pos = self.lookup_char_pos(sp.lo);
253253
return fmt!("<%s:%u:%u>", pos.file.name,
254254
pos.line, pos.col.to_uint());
255255
}
256256
257-
pub fn lookup_char_pos(@self, +pos: CharPos) -> Loc<CharPos> {
257+
pub fn lookup_char_pos(&self, +pos: CharPos) -> Loc<CharPos> {
258258
pure fn lookup(pos: FilePos) -> uint { return pos.ch.to_uint(); }
259259
return self.lookup_pos(pos, lookup);
260260
}
261261
262-
pub fn lookup_byte_pos(@self, +pos: BytePos) -> Loc<BytePos> {
262+
pub fn lookup_byte_pos(&self, +pos: BytePos) -> Loc<BytePos> {
263263
pure fn lookup(pos: FilePos) -> uint { return pos.byte.to_uint(); }
264264
return self.lookup_pos(pos, lookup);
265265
}
266266
267-
pub fn lookup_char_pos_adj(@self, +pos: CharPos)
267+
pub fn lookup_char_pos_adj(&self, +pos: CharPos)
268268
-> {filename: ~str, line: uint, col: CharPos, file: Option<@FileMap>}
269269
{
270270
let loc = self.lookup_char_pos(pos);
@@ -288,7 +288,7 @@ pub impl CodeMap {
288288
}
289289
}
290290
291-
pub fn adjust_span(@self, sp: span) -> span {
291+
pub fn adjust_span(&self, sp: span) -> span {
292292
pure fn lookup(pos: FilePos) -> uint { return pos.ch.to_uint(); }
293293
let line = self.lookup_line(sp.lo, lookup);
294294
match (line.fm.substr) {
@@ -304,19 +304,19 @@ pub impl CodeMap {
304304
}
305305
}
306306
307-
pub fn span_to_str(@self, sp: span) -> ~str {
307+
pub fn span_to_str(&self, sp: span) -> ~str {
308308
let lo = self.lookup_char_pos_adj(sp.lo);
309309
let hi = self.lookup_char_pos_adj(sp.hi);
310310
return fmt!("%s:%u:%u: %u:%u", lo.filename,
311311
lo.line, lo.col.to_uint(), hi.line, hi.col.to_uint())
312312
}
313313

314-
pub fn span_to_filename(@self, sp: span) -> FileName {
314+
pub fn span_to_filename(&self, sp: span) -> FileName {
315315
let lo = self.lookup_char_pos(sp.lo);
316316
return /* FIXME (#2543) */ copy lo.file.name;
317317
}
318318

319-
pub fn span_to_lines(@self, sp: span) -> @FileLines {
319+
pub fn span_to_lines(&self, sp: span) -> @FileLines {
320320
let lo = self.lookup_char_pos(sp.lo);
321321
let hi = self.lookup_char_pos(sp.hi);
322322
let mut lines = ~[];
@@ -326,7 +326,7 @@ pub impl CodeMap {
326326
return @FileLines {file: lo.file, lines: lines};
327327
}
328328

329-
fn lookup_byte_offset(@self, +chpos: CharPos)
329+
fn lookup_byte_offset(&self, +chpos: CharPos)
330330
-> {fm: @FileMap, pos: BytePos} {
331331
pure fn lookup(pos: FilePos) -> uint { return pos.ch.to_uint(); }
332332
let {fm, line} = self.lookup_line(chpos, lookup);
@@ -338,15 +338,15 @@ pub impl CodeMap {
338338
{fm: fm, pos: line_offset + BytePos(col_offset)}
339339
}
340340

341-
pub fn span_to_snippet(@self, sp: span) -> ~str {
341+
pub fn span_to_snippet(&self, sp: span) -> ~str {
342342
let begin = self.lookup_byte_offset(sp.lo);
343343
let end = self.lookup_byte_offset(sp.hi);
344344
assert begin.fm.start_pos == end.fm.start_pos;
345345
return str::slice(*begin.fm.src,
346346
begin.pos.to_uint(), end.pos.to_uint());
347347
}
348348

349-
pub fn get_filemap(@self, filename: ~str) -> @FileMap {
349+
pub fn get_filemap(&self, filename: ~str) -> @FileMap {
350350
for self.files.each |fm| { if fm.name == filename { return *fm; } }
351351
//XXjdm the following triggers a mismatched type bug
352352
// (or expected function, found _|_)
@@ -356,7 +356,7 @@ pub impl CodeMap {
356356
}
357357

358358
priv impl CodeMap {
359-
fn lookup_line<A: Pos>(@self, pos: A, lookup: LookupFn)
359+
fn lookup_line<A: Pos>(&self, pos: A, lookup: LookupFn)
360360
-> {fm: @FileMap, line: uint}
361361
{
362362
let len = self.files.len();
@@ -384,7 +384,7 @@ priv impl CodeMap {
384384
return {fm: f, line: a};
385385
}
386386

387-
fn lookup_pos<A: Pos Num>(@self, pos: A, lookup: LookupFn) -> Loc<A> {
387+
fn lookup_pos<A: Pos Num>(&self, pos: A, lookup: LookupFn) -> Loc<A> {
388388
let {fm: f, line: a} = self.lookup_line(pos, lookup);
389389
return Loc {
390390
file: f,
@@ -393,7 +393,7 @@ priv impl CodeMap {
393393
};
394394
}
395395

396-
fn span_to_str_no_adj(@self, sp: span) -> ~str {
396+
fn span_to_str_no_adj(&self, sp: span) -> ~str {
397397
let lo = self.lookup_char_pos(sp.lo);
398398
let hi = self.lookup_char_pos(sp.hi);
399399
return fmt!("%s:%u:%u: %u:%u", lo.file.name,

0 commit comments

Comments
 (0)