summary refs log tree commit diff
path: root/src/libsyntax/codemap.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-03-16 11:11:31 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-03-18 17:21:16 -0700
commite78f2e2ac577f9c47cd58af52d3bcd496254545d (patch)
treef05564837fe02f676458ea86b705709715c44017 /src/libsyntax/codemap.rs
parentc4db4faefaf13ac814f34c2a6cf105b7684de019 (diff)
downloadrust-e78f2e2ac577f9c47cd58af52d3bcd496254545d.tar.gz
rust-e78f2e2ac577f9c47cd58af52d3bcd496254545d.zip
librustc: Make the compiler ignore purity.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.

There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
Diffstat (limited to 'src/libsyntax/codemap.rs')
-rw-r--r--src/libsyntax/codemap.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs
index 97719a140a6..538f0de8c84 100644
--- a/src/libsyntax/codemap.rs
+++ b/src/libsyntax/codemap.rs
@@ -252,8 +252,8 @@ pub impl FileMap {
     // about what ends a line between this file and parse.rs
     fn next_line(&self, +pos: BytePos) {
         // the new charpos must be > the last one (or it's the first one).
-        fail_unless!((self.lines.len() == 0)
-                || (self.lines[self.lines.len() - 1] < pos));
+        let lines = &mut *self.lines;
+        fail_unless!((lines.len() == 0) || (lines[lines.len() - 1] < pos));
         self.lines.push(pos);
     }
 
@@ -302,11 +302,12 @@ pub impl CodeMap {
         +substr: FileSubstr,
         src: @~str
     ) -> @FileMap {
-        let start_pos = if self.files.len() == 0 {
+        let files = &mut *self.files;
+        let start_pos = if files.len() == 0 {
             0
         } else {
-            let last_start = self.files.last().start_pos.to_uint();
-            let last_len = self.files.last().src.len();
+            let last_start = files.last().start_pos.to_uint();
+            let last_len = files.last().src.len();
             last_start + last_len
         };
 
@@ -364,7 +365,8 @@ pub impl CodeMap {
     }
 
     pub fn span_to_str(&self, sp: span) -> ~str {
-        if self.files.len() == 0 && sp == dummy_sp() {
+        let files = &mut *self.files;
+        if files.len() == 0 && sp == dummy_sp() {
             return ~"no-location";
         }
 
@@ -409,7 +411,8 @@ pub impl CodeMap {
 priv impl CodeMap {
 
     fn lookup_filemap_idx(&self, +pos: BytePos) -> uint {
-        let len = self.files.len();
+        let files = &*self.files;
+        let len = files.len();
         let mut a = 0u;
         let mut b = len;
         while b - a > 1u {
@@ -433,10 +436,11 @@ priv impl CodeMap {
         let idx = self.lookup_filemap_idx(pos);
         let f = self.files[idx];
         let mut a = 0u;
-        let mut b = f.lines.len();
+        let lines = &*f.lines;
+        let mut b = lines.len();
         while b - a > 1u {
             let m = (a + b) / 2u;
-            if f.lines[m] > pos { b = m; } else { a = m; }
+            if lines[m] > pos { b = m; } else { a = m; }
         }
         return FileMapAndLine {fm: f, line: a};
     }