Skip to content

Commit 4570d8e

Browse files
committed
---
yaml --- r: 42845 b: refs/heads/try c: 767d2c0 h: refs/heads/master i: 42843: 0dd9276 v: v3
1 parent 52c2751 commit 4570d8e

38 files changed

+169
-164
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 19dfec2aaf746535de1521f68421f9980dbf25de
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
5-
refs/heads/try: aa9c28ef47d8b6a57e91b5468d70900d8e4172de
5+
refs/heads/try: 767d2c0a97e56525af9ab3229851760f7b74970a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/doc/rust.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ For example:
12341234

12351235
~~~~
12361236
trait Num {
1237-
static pure fn from_int(n: int) -> Self;
1237+
static pure fn from_int(n: int) -> self;
12381238
}
12391239
impl float: Num {
12401240
static pure fn from_int(n: int) -> float { n as float }
@@ -1716,12 +1716,15 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
17161716

17171717
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
17181718
more comma-separated expressions of uniform type in square brackets.
1719+
The keyword `mut` can be written after the opening bracket to
1720+
indicate that the elements of the resulting vector may be mutated.
1721+
When no mutability is specified, the vector is immutable.
17191722

17201723
~~~~
17211724
[1, 2, 3, 4];
17221725
["a", "b", "c", "d"];
17231726
[0, ..128]; // vector with 128 zeros
1724-
[0u8, 0u8, 0u8, 0u8];
1727+
[mut 0u8, 0u8, 0u8, 0u8];
17251728
~~~~
17261729

17271730
### Index expressions
@@ -1743,6 +1746,7 @@ task in a _failing state_.
17431746
# do task::spawn_unlinked {
17441747
17451748
([1, 2, 3, 4])[0];
1749+
([mut 'x', 'y'])[1] = 'z';
17461750
(["a", "b"])[10]; // fails
17471751
17481752
# }
@@ -1905,8 +1909,8 @@ No allocation or destruction is entailed.
19051909
An example of three different swap expressions:
19061910

19071911
~~~~~~~~
1908-
# let mut x = &mut [0];
1909-
# let mut a = &mut [0];
1912+
# let mut x = &[mut 0];
1913+
# let mut a = &[mut 0];
19101914
# let i = 0;
19111915
# let y = {mut z: 0};
19121916
# let b = {mut c: 0};
@@ -2001,11 +2005,11 @@ the unary copy operator is typically only used to cause an argument to a functio
20012005
An example of a copy expression:
20022006

20032007
~~~~
2004-
fn mutate(mut vec: ~[int]) {
2008+
fn mutate(vec: ~[mut int]) {
20052009
vec[0] = 10;
20062010
}
20072011
2008-
let v = ~[1,2,3];
2012+
let v = ~[mut 1,2,3];
20092013
20102014
mutate(copy v); // Pass a copy
20112015

branches/try/doc/tutorial-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ Finally, tasks can be configured to not propagate failure to each
440440
other at all, using `task::spawn_unlinked` for _isolated failure_.
441441

442442
~~~
443-
# fn random() -> uint { 100 }
444-
# fn sleep_for(i: uint) { for i.times { task::yield() } }
443+
# fn random() -> int { 100 }
444+
# fn sleep_for(i: int) { for i.times { task::yield() } }
445445
# do task::try::<()> {
446446
let (time1, time2) = (random(), random());
447447
do task::spawn_unlinked {

branches/try/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: ~[T]
1798+
elements: ~[mut T]
17991799
}
18001800
18011801
enum Option<T> {

branches/try/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 : ~[maybe_pointy],
46+
mut n : ~[mut 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 : ~[],
61+
mut n : ~[mut],
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 mut v : ~[@pointy] = ~[];
71+
let v : ~[mut @pointy] = ~[mut];
7272

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

branches/try/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 : ~[T]) {
28+
fn shuffle<T>(r : rand::rng, &v : ~[mut 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 mut a = ~[1, 2, 3];
89+
let a = ~[mut 1, 2, 3];
9090
shuffle(r, a);
9191
log(error, a);
9292

branches/try/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 = [0, ..4096];
159+
let mut bytes = [mut 0, ..4096];
160160
while !reader.eof() {
161161
let nread = reader.read(bytes, bytes.len());
162162
writer.write(bytes.view(0, nread));

branches/try/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: ~[uint]
109+
mut storage: ~[mut uint]
110110
}
111111

112-
fn BigBitv(storage: ~[uint]) -> BigBitv {
112+
fn BigBitv(storage: ~[mut 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 = from_elem(nelems, elem);
236+
let s = cast_to_mut(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 mut st = from_elem(self.nbits / uint_bits + 1, 0);
521+
let st = cast_to_mut(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})}

branches/try/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 {

branches/try/src/libstd/map.rs

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

145145
struct HashMap_<K, V> {
146146
mut count: uint,
147-
mut chains: ~[Option<@Entry<K,V>>]
147+
mut chains: ~[mut Option<@Entry<K,V>>]
148148
}
149149

150150
pub type T<K, V> = @HashMap_<K, V>;
@@ -209,7 +209,7 @@ pub mod chained {
209209
fn rehash() {
210210
let n_old_chains = self.chains.len();
211211
let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u);
212-
let mut new_chains = chains(n_new_chains);
212+
let new_chains = chains(n_new_chains);
213213
for self.each_entry |entry| {
214214
let idx = entry.hash % n_new_chains;
215215
entry.next = new_chains[idx];
@@ -458,8 +458,8 @@ pub mod chained {
458458
}
459459
}
460460

461-
fn chains<K,V>(nchains: uint) -> ~[Option<@Entry<K,V>>] {
462-
vec::from_elem(nchains, None)
461+
fn chains<K,V>(nchains: uint) -> ~[mut Option<@Entry<K,V>>] {
462+
vec::cast_to_mut(vec::from_elem(nchains, None))
463463
}
464464

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

branches/try/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

branches/try/src/libstd/rope.rs

Lines changed: 5 additions & 4 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,17 +1158,18 @@ pub mod node {
11581158
use core::vec;
11591159

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

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

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

0 commit comments

Comments
 (0)