about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-04-08 18:36:57 -0700
committerbors <bors@rust-lang.org>2013-04-08 18:36:57 -0700
commit30dbbe17c9189fed32d0f5f332b4f6ff8f7cc4aa (patch)
tree3a13a4df0a798bdb55dc87e23188f8a975bd4691 /src/libsyntax/parse
parent22f65e9852e71645ab6552106225857bced327a2 (diff)
parent255193cc1af5e07753906ad18bae077b45b5c3f0 (diff)
downloadrust-30dbbe17c9189fed32d0f5f332b4f6ff8f7cc4aa.tar.gz
rust-30dbbe17c9189fed32d0f5f332b4f6ff8f7cc4aa.zip
auto merge of #5787 : alexcrichton/rust/less-mut-fields, r=catamorphism
This removes some of the easier instances of mutable fields where the explicit self can just become `&mut self` along with removing some unsafe blocks which aren't necessary any more now that purity is gone.

Most of #4568 is done, except for [one case](https://github.com/alexcrichton/rust/blob/less-mut-fields/src/libcore/vec.rs#L1754) where it looks like it has to do with it being a `const` vector. Removing the unsafe block yields:

```
/Users/alex/code/rust2/src/libcore/vec.rs:1755:12: 1755:16 error: illegal borrow unless pure: creating immutable alias to const vec content
/Users/alex/code/rust2/src/libcore/vec.rs:1755         for self.each |e| {
                                                           ^~~~
/Users/alex/code/rust2/src/libcore/vec.rs:1757:8: 1757:9 note: impure due to access to impure function
/Users/alex/code/rust2/src/libcore/vec.rs:1757         }
                                                       ^
error: aborting due to previous error
```

I also didn't delve too much into removing mutable fields with `Cell` or `transmute` and friends.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index b6ec15d8641..59e4dddc73b 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -175,12 +175,10 @@ fn byte_offset(rdr: @mut StringReader) -> BytePos {
 }
 
 pub fn get_str_from(rdr: @mut StringReader, start: BytePos) -> ~str {
-    unsafe {
-        // I'm pretty skeptical about this subtraction. What if there's a
-        // multi-byte character before the mark?
-        return str::slice(*rdr.src, start.to_uint() - 1u,
-                          byte_offset(rdr).to_uint() - 1u).to_owned();
-    }
+    // I'm pretty skeptical about this subtraction. What if there's a
+    // multi-byte character before the mark?
+    return str::slice(*rdr.src, start.to_uint() - 1u,
+                      byte_offset(rdr).to_uint() - 1u).to_owned();
 }
 
 // EFFECT: advance the StringReader by one character. If a newline is