about summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 5d96cc359c2..4df334a3f2c 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -283,9 +283,9 @@ impl FileMap {
     /// filemap.start_pos + newline_offset_relative_to_the_start_of_filemap.
     pub fn next_line(&self, pos: BytePos) {
         // the new charpos must be > the last one (or it's the first one).
-        let mut lines = self.lines.borrow_mut();;
+        let mut lines = self.lines.borrow_mut();
         let line_len = lines.len();
-        assert!(line_len == 0 || (*lines.get(line_len - 1) < pos))
+        assert!(line_len == 0 || ((*lines)[line_len - 1] < pos))
         lines.push(pos);
     }
 
@@ -293,7 +293,7 @@ impl FileMap {
     ///
     pub fn get_line(&self, line: int) -> String {
         let lines = self.lines.borrow();
-        let begin: BytePos = *lines.get(line as uint) - self.start_pos;
+        let begin: BytePos = (*lines)[line as uint] - self.start_pos;
         let begin = begin.to_uint();
         let slice = self.src.as_slice().slice_from(begin);
         match slice.find('\n') {
@@ -351,7 +351,7 @@ impl CodeMap {
         // overflowing into the next filemap in case the last byte of span is also the last
         // byte of filemap, which leads to incorrect results from CodeMap.span_to_*.
         if src.len() > 0 && !src.as_slice().ends_with("\n") {
-            src.push_char('\n');
+            src.push('\n');
         }
 
         let filemap = Rc::new(FileMap {
@@ -446,7 +446,7 @@ impl CodeMap {
 
     pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos {
         let idx = self.lookup_filemap_idx(bpos);
-        let fm = self.files.borrow().get(idx).clone();
+        let fm = (*self.files.borrow())[idx].clone();
         let offset = bpos - fm.start_pos;
         FileMapAndBytePos {fm: fm, pos: offset}
     }
@@ -455,7 +455,7 @@ impl CodeMap {
     pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos {
         let idx = self.lookup_filemap_idx(bpos);
         let files = self.files.borrow();
-        let map = files.get(idx);
+        let map = &(*files)[idx];
 
         // The number of extra bytes due to multibyte chars in the FileMap
         let mut total_extra_bytes = 0;
@@ -480,34 +480,37 @@ impl CodeMap {
 
     fn lookup_filemap_idx(&self, pos: BytePos) -> uint {
         let files = self.files.borrow();
-        let files = files;
+        let files = &*files;
         let len = files.len();
         let mut a = 0u;
         let mut b = len;
         while b - a > 1u {
             let m = (a + b) / 2u;
-            if files.get(m).start_pos > pos {
+            if files[m].start_pos > pos {
                 b = m;
             } else {
                 a = m;
             }
         }
-        // There can be filemaps with length 0. These have the same start_pos as the previous
-        // filemap, but are not the filemaps we want (because they are length 0, they cannot
-        // contain what we are looking for). So, rewind until we find a useful filemap.
+        // There can be filemaps with length 0. These have the same start_pos as
+        // the previous filemap, but are not the filemaps we want (because they
+        // are length 0, they cannot contain what we are looking for). So,
+        // rewind until we find a useful filemap.
         loop {
-            let lines = files.get(a).lines.borrow();
+            let lines = files[a].lines.borrow();
             let lines = lines;
             if lines.len() > 0 {
                 break;
             }
             if a == 0 {
-                fail!("position {} does not resolve to a source location", pos.to_uint());
+                fail!("position {} does not resolve to a source location",
+                      pos.to_uint());
             }
             a -= 1;
         }
         if a >= len {
-            fail!("position {} does not resolve to a source location", pos.to_uint())
+            fail!("position {} does not resolve to a source location",
+                  pos.to_uint())
         }
 
         return a;
@@ -517,14 +520,14 @@ impl CodeMap {
         let idx = self.lookup_filemap_idx(pos);
 
         let files = self.files.borrow();
-        let f = files.get(idx).clone();
+        let f = (*files)[idx].clone();
         let mut a = 0u;
         {
             let lines = f.lines.borrow();
             let mut b = lines.len();
             while b - a > 1u {
                 let m = (a + b) / 2u;
-                if *lines.get(m) > pos { b = m; } else { a = m; }
+                if (*lines)[m] > pos { b = m; } else { a = m; }
             }
         }
         FileMapAndLine {fm: f, line: a}
@@ -534,7 +537,7 @@ impl CodeMap {
         let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos);
         let line = a + 1u; // Line numbers start at 1
         let chpos = self.bytepos_to_file_charpos(pos);
-        let linebpos = *f.lines.borrow().get(a);
+        let linebpos = (*f.lines.borrow())[a];
         let linechpos = self.bytepos_to_file_charpos(linebpos);
         debug!("byte pos {} is on the line at byte pos {}",
                pos, linebpos);
@@ -704,7 +707,7 @@ mod test {
 
         assert_eq!(file_lines.file.name, "blork.rs".to_string());
         assert_eq!(file_lines.lines.len(), 1);
-        assert_eq!(*file_lines.lines.get(0), 1u);
+        assert_eq!(file_lines.lines[0], 1u);
     }
 
     #[test]