Skip to content

Commit f0f6b61

Browse files
committed
---
yaml --- r: 42964 b: refs/heads/try c: 73a7672 h: refs/heads/master v: v3
1 parent ac47699 commit f0f6b61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+261
-267
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: 3c6b9c2363a70a359e8d4b3a111baaa8ec8dabda
5+
refs/heads/try: 73a7672b8d9ddab92c91d1b343535b9a9a765b68
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/doc/rust.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,12 +1719,15 @@ 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.
17221725

17231726
~~~~
17241727
[1, 2, 3, 4];
17251728
["a", "b", "c", "d"];
17261729
[0, ..128]; // vector with 128 zeros
1727-
[0u8, 0u8, 0u8, 0u8];
1730+
[mut 0u8, 0u8, 0u8, 0u8];
17281731
~~~~
17291732

17301733
### Index expressions
@@ -1746,6 +1749,7 @@ task in a _failing state_.
17461749
# do task::spawn_unlinked {
17471750
17481751
([1, 2, 3, 4])[0];
1752+
([mut 'x', 'y'])[1] = 'z';
17491753
(["a", "b"])[10]; // fails
17501754
17511755
# }
@@ -1908,8 +1912,8 @@ No allocation or destruction is entailed.
19081912
An example of three different swap expressions:
19091913

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

20062010
~~~~
2007-
fn mutate(mut vec: ~[int]) {
2011+
fn mutate(vec: ~[mut int]) {
20082012
vec[0] = 10;
20092013
}
20102014
2011-
let v = ~[1,2,3];
2015+
let v = ~[mut 1,2,3];
20122016
20132017
mutate(copy v); // Pass a copy
20142018

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/libcore/either.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,23 +150,6 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
150150
}
151151

152152
impl<T, U> Either<T, U> {
153-
#[inline(always)]
154-
fn either<V>(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V {
155-
either(f_left, f_right, self)
156-
}
157-
158-
#[inline(always)]
159-
fn flip(self) -> Either<U, T> { flip(self) }
160-
161-
#[inline(always)]
162-
fn to_result(self) -> Result<U, T> { to_result(self) }
163-
164-
#[inline(always)]
165-
fn is_left(&self) -> bool { is_left(self) }
166-
167-
#[inline(always)]
168-
fn is_right(&self) -> bool { is_right(self) }
169-
170153
#[inline(always)]
171154
fn unwrap_left(self) -> T { unwrap_left(self) }
172155

branches/try/src/libcore/prelude.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,40 @@
1212

1313
/* Reexported core operators */
1414

15-
pub use either::{Either, Left, Right};
1615
pub use kinds::{Const, Copy, Owned, Durable};
16+
pub use ops::{Drop};
1717
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
1818
pub use ops::{BitAnd, BitOr, BitXor};
19-
pub use ops::{Drop};
2019
pub use ops::{Shl, Shr, Index};
2120
pub use option::{Option, Some, None};
2221
pub use result::{Result, Ok, Err};
2322

2423
/* Reexported types and traits */
2524

26-
pub use clone::Clone;
27-
pub use cmp::{Eq, Ord};
28-
pub use container::{Container, Mutable, Map, Set};
29-
pub use hash::Hash;
30-
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
31-
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
32-
pub use num::Num;
33-
pub use path::GenericPath;
3425
pub use path::Path;
35-
pub use path::PosixPath;
26+
pub use path::GenericPath;
3627
pub use path::WindowsPath;
37-
pub use pipes::{GenericChan, GenericPort};
38-
pub use ptr::Ptr;
39-
pub use str::{StrSlice, Trimmable};
40-
pub use to_bytes::IterBytes;
41-
pub use to_str::ToStr;
28+
pub use path::PosixPath;
29+
4230
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
31+
pub use str::{StrSlice, Trimmable};
32+
pub use container::{Container, Mutable};
4333
pub use vec::{CopyableVector, ImmutableVector};
4434
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
4535
pub use vec::{OwnedVector, OwnedCopyableVector};
36+
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
37+
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
38+
pub use container::{Container, Mutable, Map, Set};
39+
pub use pipes::{GenericChan, GenericPort};
40+
41+
pub use num::Num;
42+
pub use ptr::Ptr;
43+
pub use to_str::ToStr;
44+
pub use clone::Clone;
45+
46+
pub use cmp::{Eq, Ord};
47+
pub use hash::Hash;
48+
pub use to_bytes::IterBytes;
4649

4750
/* Reexported modules */
4851

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/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use syntax::parse::token::special_idents;
4242

4343
fn abi_info(arch: session::arch) -> cabi::ABIInfo {
4444
return match arch {
45-
arch_x86_64 | arch_arm => x86_64_abi_info(),
45+
arch_x86_64 => x86_64_abi_info(),
4646
_ => cabi::llvm_abi_info()
4747
}
4848
}

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/c_vec.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ use core::task;
4646
/**
4747
* The type representing a foreign chunk of memory
4848
*
49-
* Wrapped in a enum for opacity; FIXME #818 when it is possible to have
50-
* truly opaque types, this should be revisited.
5149
*/
52-
pub enum CVec<T> {
53-
CVecCtor({ base: *mut T, len: uint, rsrc: @DtorRes})
50+
pub struct CVec<T> {
51+
priv base: *mut T,
52+
priv len: uint,
53+
priv rsrc: @DtorRes
5454
}
5555

5656
struct DtorRes {
@@ -85,11 +85,11 @@ fn DtorRes(dtor: Option<fn@()>) -> DtorRes {
8585
* * len - The number of elements in the buffer
8686
*/
8787
pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
88-
return CVecCtor({
88+
return CVec{
8989
base: base,
9090
len: len,
9191
rsrc: @DtorRes(option::None)
92-
});
92+
};
9393
}
9494

9595
/**
@@ -105,11 +105,11 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
105105
*/
106106
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@())
107107
-> CVec<T> {
108-
return CVecCtor({
108+
return CVec{
109109
base: base,
110110
len: len,
111111
rsrc: @DtorRes(option::Some(dtor))
112-
});
112+
};
113113
}
114114

115115
/*
@@ -123,7 +123,7 @@ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@())
123123
*/
124124
pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T {
125125
assert ofs < len(t);
126-
return unsafe { *ptr::mut_offset((*t).base, ofs) };
126+
return unsafe { *ptr::mut_offset(t.base, ofs) };
127127
}
128128

129129
/**
@@ -133,22 +133,18 @@ pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T {
133133
*/
134134
pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) {
135135
assert ofs < len(t);
136-
unsafe { *ptr::mut_offset((*t).base, ofs) = v };
136+
unsafe { *ptr::mut_offset(t.base, ofs) = v };
137137
}
138138

139139
/*
140140
Section: Elimination forms
141141
*/
142142

143143
/// Returns the length of the vector
144-
pub pure fn len<T>(t: CVec<T>) -> uint {
145-
return (*t).len;
146-
}
144+
pub pure fn len<T>(t: CVec<T>) -> uint { t.len }
147145

148146
/// Returns a pointer to the first element of the vector
149-
pub unsafe fn ptr<T>(t: CVec<T>) -> *mut T {
150-
return (*t).base;
151-
}
147+
pub unsafe fn ptr<T>(t: CVec<T>) -> *mut T { t.base }
152148

153149
#[cfg(test)]
154150
mod tests {

branches/try/src/libstd/ebml.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,27 @@ pub mod reader {
8484
}
8585
}
8686

87-
fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} {
87+
struct Res {
88+
val: uint,
89+
next: uint
90+
}
91+
92+
fn vuint_at(data: &[u8], start: uint) -> Res {
8893
let a = data[start];
8994
if a & 0x80u8 != 0u8 {
90-
return {val: (a & 0x7fu8) as uint, next: start + 1u};
95+
return Res {val: (a & 0x7fu8) as uint, next: start + 1u};
9196
}
9297
if a & 0x40u8 != 0u8 {
93-
return {val: ((a & 0x3fu8) as uint) << 8u |
98+
return Res {val: ((a & 0x3fu8) as uint) << 8u |
9499
(data[start + 1u] as uint),
95100
next: start + 2u};
96101
} else if a & 0x20u8 != 0u8 {
97-
return {val: ((a & 0x1fu8) as uint) << 16u |
102+
return Res {val: ((a & 0x1fu8) as uint) << 16u |
98103
(data[start + 1u] as uint) << 8u |
99104
(data[start + 2u] as uint),
100105
next: start + 3u};
101106
} else if a & 0x10u8 != 0u8 {
102-
return {val: ((a & 0x0fu8) as uint) << 24u |
107+
return Res {val: ((a & 0x0fu8) as uint) << 24u |
103108
(data[start + 1u] as uint) << 16u |
104109
(data[start + 2u] as uint) << 8u |
105110
(data[start + 3u] as uint),

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/md4.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ use core::str;
1414
use core::uint;
1515
use core::vec;
1616

17-
pub pure fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} {
17+
struct Quad {
18+
a: u32,
19+
b: u32,
20+
c: u32,
21+
d: u32
22+
}
23+
24+
pub pure fn md4(msg: &[u8]) -> Quad {
1825
// subtle: if orig_len is merely uint, then the code below
1926
// which performs shifts by 32 bits or more has undefined
2027
// results.
@@ -95,11 +102,11 @@ pub pure fn md4(msg: &[u8]) -> {a: u32, b: u32, c: u32, d: u32} {
95102
a += aa; b += bb; c += cc; d += dd;
96103
i += 64u;
97104
}
98-
return {a: a, b: b, c: c, d: d};
105+
return Quad {a: a, b: b, c: c, d: d};
99106
}
100107

101108
pub pure fn md4_str(msg: &[u8]) -> ~str {
102-
let {a, b, c, d} = md4(msg);
109+
let Quad {a, b, c, d} = md4(msg);
103110
pure fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) {
104111
f(a); f(b); f(c); f(d);
105112
}

0 commit comments

Comments
 (0)