Skip to content

Commit e08a805

Browse files
committed
Merge remote-tracking branch 'bstrie/rimov' into incoming
Conflicts: src/libsyntax/parse/parser.rs src/test/bench/graph500-bfs.rs src/test/bench/sudoku.rs src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs src/test/run-pass/empty-mutable-vec.rs src/test/run-pass/foreach-nested.rs src/test/run-pass/swap-2.rs
2 parents 27e1ac5 + aa9c28e commit e08a805

36 files changed

+161
-166
lines changed

doc/rust.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,15 +1719,12 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
17191719

17201720
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
17211721
more comma-separated expressions of uniform type in square brackets.
1722-
The keyword `mut` can be written after the opening bracket to
1723-
indicate that the elements of the resulting vector may be mutated.
1724-
When no mutability is specified, the vector is immutable.
17251722

17261723
~~~~
17271724
[1, 2, 3, 4];
17281725
["a", "b", "c", "d"];
17291726
[0, ..128]; // vector with 128 zeros
1730-
[mut 0u8, 0u8, 0u8, 0u8];
1727+
[0u8, 0u8, 0u8, 0u8];
17311728
~~~~
17321729

17331730
### Index expressions
@@ -1749,7 +1746,6 @@ task in a _failing state_.
17491746
# do task::spawn_unlinked {
17501747
17511748
([1, 2, 3, 4])[0];
1752-
([mut 'x', 'y'])[1] = 'z';
17531749
(["a", "b"])[10]; // fails
17541750
17551751
# }
@@ -1912,8 +1908,8 @@ No allocation or destruction is entailed.
19121908
An example of three different swap expressions:
19131909

19141910
~~~~~~~~
1915-
# let mut x = &[mut 0];
1916-
# let mut a = &[mut 0];
1911+
# let mut x = &mut [0];
1912+
# let mut a = &mut [0];
19171913
# let i = 0;
19181914
# let y = {mut z: 0};
19191915
# let b = {mut c: 0};
@@ -2008,11 +2004,11 @@ the unary copy operator is typically only used to cause an argument to a functio
20082004
An example of a copy expression:
20092005

20102006
~~~~
2011-
fn mutate(vec: ~[mut int]) {
2007+
fn mutate(mut vec: ~[int]) {
20122008
vec[0] = 10;
20132009
}
20142010
2015-
let v = ~[mut 1,2,3];
2011+
let v = ~[1,2,3];
20162012
20172013
mutate(copy v); // Pass a copy
20182014

doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ Generic `type`, `struct`, and `enum` declarations follow the same pattern:
17951795
type Set<T> = HashMap<T, ()>;
17961796
17971797
struct Stack<T> {
1798-
elements: ~[mut T]
1798+
elements: ~[T]
17991799
}
18001800
18011801
enum Option<T> {

src/libfuzzer/cycles.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type pointy = {
4343
mut g : fn~()->(),
4444

4545
mut m : ~[maybe_pointy],
46-
mut n : ~[mut maybe_pointy],
46+
mut n : ~[maybe_pointy],
4747
mut o : {x : int, y : maybe_pointy}
4848
};
4949
// To add: objects; traits; anything type-parameterized?
@@ -58,7 +58,7 @@ fn empty_pointy() -> @pointy {
5858
mut g : fn~()->(){},
5959

6060
mut m : ~[],
61-
mut n : ~[mut],
61+
mut n : ~[],
6262
mut o : {x : 0, y : none}
6363
}
6464
}
@@ -68,7 +68,7 @@ fn nop<T>(_x: T) { }
6868

6969
fn test_cycles(r : rand::rng, k: uint, n: uint)
7070
{
71-
let v : ~[mut @pointy] = ~[mut];
71+
let mut v : ~[@pointy] = ~[];
7272

7373
// Create a graph with no edges
7474
range(0u, vlen) {|_i|

src/libfuzzer/rand_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn choice<T: copy>(r : rand::rng, v : ~[T]) -> T {
2525
fn unlikely(r : rand::rng, n : uint) -> bool { under(r, n) == 0u }
2626

2727
// shuffle a vec in place
28-
fn shuffle<T>(r : rand::rng, &v : ~[mut T]) {
28+
fn shuffle<T>(r : rand::rng, &v : ~[T]) {
2929
let i = vec::len(v);
3030
while i >= 2u {
3131
// Loop invariant: elements with index >= i have been locked in place.
@@ -86,7 +86,7 @@ fn main()
8686
log(error, choice(r, ~[10, 20, 30]));
8787
log(error, if unlikely(r, 5u) { "unlikely" } else { "likely" });
8888

89-
let a = ~[mut 1, 2, 3];
89+
let mut a = ~[1, 2, 3];
9090
shuffle(r, a);
9191
log(error, a);
9292

src/librustdoc/markdown_writer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn readclose(fd: libc::c_int) -> ~str {
156156
let file = os::fdopen(fd);
157157
let reader = io::FILE_reader(file, false);
158158
let buf = io::with_bytes_writer(|writer| {
159-
let mut bytes = [mut 0, ..4096];
159+
let mut bytes = [0, ..4096];
160160
while !reader.eof() {
161161
let nread = reader.read(bytes, bytes.len());
162162
writer.write(bytes.view(0, nread));

src/libstd/bitv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ impl SmallBitv {
106106

107107
struct BigBitv {
108108
// only mut b/c of clone and lack of other constructor
109-
mut storage: ~[mut uint]
109+
mut storage: ~[uint]
110110
}
111111

112-
fn BigBitv(storage: ~[mut uint]) -> BigBitv {
112+
fn BigBitv(storage: ~[uint]) -> BigBitv {
113113
BigBitv {storage: move storage}
114114
}
115115

@@ -233,7 +233,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv {
233233
let nelems = nbits/uint_bits +
234234
if nbits % uint_bits == 0 {0} else {1};
235235
let elem = if init {!0} else {0};
236-
let s = cast_to_mut(from_elem(nelems, elem));
236+
let s = from_elem(nelems, elem);
237237
Big(~BigBitv(move s))
238238
};
239239
Bitv {rep: move rep, nbits: nbits}
@@ -518,7 +518,7 @@ impl Bitv: Clone {
518518
Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})}
519519
}
520520
Big(ref b) => {
521-
let st = cast_to_mut(from_elem(self.nbits / uint_bits + 1, 0));
521+
let mut st = from_elem(self.nbits / uint_bits + 1, 0);
522522
let len = st.len();
523523
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
524524
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: move st})}

src/libstd/io_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub impl BufReader {
4343
}
4444

4545
impl BufReader: Reader {
46-
fn read(&self, bytes: &[mut u8], len: uint) -> uint {
46+
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
4747
self.as_bytes_reader(|r| r.read(bytes, len) )
4848
}
4949
fn read_byte(&self) -> int {

src/libstd/net_tcp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ impl TcpSocket {
863863

864864
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
865865
impl TcpSocketBuf: io::Reader {
866-
fn read(&self, buf: &[mut u8], len: uint) -> uint {
866+
fn read(&self, buf: &mut [u8], len: uint) -> uint {
867867
if len == 0 { return 0 }
868868
let mut count: uint = 0;
869869

src/libstd/oldmap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub mod chained {
6666

6767
struct HashMap_<K, V> {
6868
mut count: uint,
69-
mut chains: ~[mut Option<@Entry<K,V>>]
69+
mut chains: ~[Option<@Entry<K,V>>]
7070
}
7171

7272
pub type T<K, V> = @HashMap_<K, V>;
@@ -131,7 +131,7 @@ pub mod chained {
131131
fn rehash() {
132132
let n_old_chains = self.chains.len();
133133
let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u);
134-
let new_chains = chains(n_new_chains);
134+
let mut new_chains = chains(n_new_chains);
135135
for self.each_entry |entry| {
136136
let idx = entry.hash % n_new_chains;
137137
entry.next = new_chains[idx];
@@ -369,8 +369,8 @@ pub mod chained {
369369
}
370370
}
371371

372-
fn chains<K,V>(nchains: uint) -> ~[mut Option<@Entry<K,V>>] {
373-
vec::cast_to_mut(vec::from_elem(nchains, None))
372+
fn chains<K,V>(nchains: uint) -> ~[Option<@Entry<K,V>>] {
373+
vec::from_elem(nchains, None)
374374
}
375375

376376
pub fn mk<K:Eq IterBytes Hash, V: Copy>() -> T<K,V> {

src/libstd/rope.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ pub mod node {
788788
* * forest - The forest. This vector is progressively rewritten during
789789
* execution and should be discarded as meaningless afterwards.
790790
*/
791-
pub fn tree_from_forest_destructive(forest: &[mut @Node]) -> @Node {
791+
pub fn tree_from_forest_destructive(forest: &mut [@Node]) -> @Node {
792792
let mut i;
793793
let mut len = vec::len(forest);
794794
while len > 1u {
@@ -1158,18 +1158,17 @@ pub mod node {
11581158
use core::vec;
11591159

11601160
pub struct T {
1161-
stack: ~[mut @Node],
1161+
mut stack: ~[@Node],
11621162
mut stackpos: int,
11631163
}
11641164

11651165
pub fn empty() -> T {
1166-
let stack : ~[mut @Node] = ~[mut];
1166+
let mut stack : ~[@Node] = ~[];
11671167
T { stack: stack, stackpos: -1 }
11681168
}
11691169

11701170
pub fn start(node: @Node) -> T {
1171-
let stack = vec::cast_to_mut(
1172-
vec::from_elem(height(node)+1u, node));
1171+
let stack = vec::from_elem(height(node)+1u, node);
11731172
T {
11741173
stack: stack,
11751174
stackpos: 0,

0 commit comments

Comments
 (0)