diff options
| author | Ben Striegel <ben.striegel@gmail.com> | 2013-01-29 22:34:16 -0500 |
|---|---|---|
| committer | Ben Striegel <ben.striegel@gmail.com> | 2013-01-30 23:19:40 -0500 |
| commit | 743c1c37e87835cbc7e9a5b5daff7ff9f71e9fe6 (patch) | |
| tree | 7e900839bee3dff937e2edd71550cbe9b9e0b45b | |
| parent | 0336a8633f0734ef269c000c5d7432b7a706a1fe (diff) | |
| download | rust-743c1c37e87835cbc7e9a5b5daff7ff9f71e9fe6.tar.gz rust-743c1c37e87835cbc7e9a5b5daff7ff9f71e9fe6.zip | |
RIMOV, round 11
Last bit of mut removal, manually cleaning up outliers
| -rw-r--r-- | doc/rust.md | 15 | ||||
| -rw-r--r-- | doc/tutorial.md | 2 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 8 | ||||
| -rw-r--r-- | src/libfuzzer/cycles.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/regions-infer-invariance-due-to-mutability-2.rs | 4 |
5 files changed, 14 insertions, 17 deletions
diff --git a/doc/rust.md b/doc/rust.md index e31441c7cd2..9982f72ebe7 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1716,15 +1716,12 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr] A [_vector_](#vector-types) _expression_ is written by enclosing zero or more comma-separated expressions of uniform type in square brackets. -The keyword `mut` can be written after the opening bracket to -indicate that the elements of the resulting vector may be mutated. -When no mutability is specified, the vector is immutable. ~~~~ [1, 2, 3, 4]; ["a", "b", "c", "d"]; [0, ..128]; // vector with 128 zeros -[mut 0u8, 0u8, 0u8, 0u8]; +[0u8, 0u8, 0u8, 0u8]; ~~~~ ### Index expressions @@ -1746,7 +1743,7 @@ task in a _failing state_. # do task::spawn_unlinked { ([1, 2, 3, 4])[0]; -([mut 'x', 'y'])[1] = 'z'; +(['x', 'y'])[1] = 'z'; (["a", "b"])[10]; // fails # } @@ -1909,8 +1906,8 @@ No allocation or destruction is entailed. An example of three different swap expressions: ~~~~~~~~ -# let mut x = &[mut 0]; -# let mut a = &[mut 0]; +# let mut x = &[0]; +# let mut a = &[0]; # let i = 0; # let y = {mut z: 0}; # let b = {mut c: 0}; @@ -2005,11 +2002,11 @@ the unary copy operator is typically only used to cause an argument to a functio An example of a copy expression: ~~~~ -fn mutate(vec: ~[mut int]) { +fn mutate(vec: ~[int]) { vec[0] = 10; } -let v = ~[mut 1,2,3]; +let v = ~[1,2,3]; mutate(copy v); // Pass a copy diff --git a/doc/tutorial.md b/doc/tutorial.md index 6ccf13a8d4d..dbafea44409 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1795,7 +1795,7 @@ Generic `type`, `struct`, and `enum` declarations follow the same pattern: type Set<T> = HashMap<T, ()>; struct Stack<T> { - elements: ~[mut T] + elements: ~[T] } enum Option<T> { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 30b3927d6f3..52b62d10a20 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -280,8 +280,12 @@ pub pure fn view<T>(v: &r/[T], start: uint, end: uint) -> &r/[T] { } /// Return a slice that points into another slice. +<<<<<<< HEAD #[inline(always)] pub pure fn mut_view<T>(v: &r/[mut T], start: uint, end: uint) -> &r/[mut T] { +======= +pub pure fn mut_view<T>(v: &mut r/[T], start: uint, end: uint) -> &mut r/[T] { +>>>>>>> RIMOV, round 11 assert (start <= end); assert (end <= len(v)); do as_mut_buf(v) |p, _len| { @@ -2199,12 +2203,8 @@ pub mod bytes { * Copies `count` bytes from `src` to `dst`. The source and destination * may overlap. */ -<<<<<<< HEAD #[inline(always)] - pub fn copy_memory(dst: &[mut u8], src: &[const u8], count: uint) { -======= pub fn copy_memory(dst: &mut [u8], src: &[const u8], count: uint) { ->>>>>>> RIMOV, round 5 // Bound checks are done at vec::raw::copy_memory. unsafe { vec::raw::copy_memory(dst, src, count) } } diff --git a/src/libfuzzer/cycles.rs b/src/libfuzzer/cycles.rs index ee1bfc29429..a64700494c8 100644 --- a/src/libfuzzer/cycles.rs +++ b/src/libfuzzer/cycles.rs @@ -58,7 +58,7 @@ fn empty_pointy() -> @pointy { mut g : fn~()->(){}, mut m : ~[], - mut n : ~[mut], + mut n : ~[], mut o : {x : 0, y : none} } } diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-2.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-2.rs index 523b48f2aff..4b637b0195c 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-2.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-2.rs @@ -9,7 +9,7 @@ // except according to those terms. struct invariant { - f: @[mut &int] + f: @mut [&int] } fn to_same_lifetime(bi: invariant/&r) { @@ -25,4 +25,4 @@ fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static { } fn main() { -} \ No newline at end of file +} |
