Skip to content

Commit b8dacf9

Browse files
committed
---
yaml --- r: 11685 b: refs/heads/master c: 713006c h: refs/heads/master i: 11683: 1496e43 v: v3
1 parent 05a01f2 commit b8dacf9

File tree

23 files changed

+205
-199
lines changed

23 files changed

+205
-199
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 674587cfe5a871336f6337eabae75b20882faff5
2+
refs/heads/master: 713006c7b6afc25ef90ecf78f88c9e9abb31f4b9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/comm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn select2<A: send, B: send>(
180180
rustrt::rust_port_select(dptr, ports, n_ports, yield)
181181
}
182182

183-
let ports = [];
183+
let mut ports = [];
184184
ports += [***p_a, ***p_b];
185185
let n_ports = 2 as ctypes::size_t;
186186
let yield = 0u;

trunk/src/libcore/either.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Function: lefts
4040
Extracts from a vector of either all the left values.
4141
*/
4242
fn lefts<T: copy, U>(eithers: [t<T, U>]) -> [T] {
43-
let result: [T] = [];
43+
let mut result: [T] = [];
4444
for elt: t<T, U> in eithers {
4545
alt elt { left(l) { result += [l]; } _ {/* fallthrough */ } }
4646
}
@@ -53,7 +53,7 @@ Function: rights
5353
Extracts from a vector of either all the right values
5454
*/
5555
fn rights<T, U: copy>(eithers: [t<T, U>]) -> [U] {
56-
let result: [U] = [];
56+
let mut result: [U] = [];
5757
for elt: t<T, U> in eithers {
5858
alt elt { right(r) { result += [r]; } _ {/* fallthrough */ } }
5959
}
@@ -70,8 +70,8 @@ right values.
7070
*/
7171
fn partition<T: copy, U: copy>(eithers: [t<T, U>])
7272
-> {lefts: [T], rights: [U]} {
73-
let lefts: [T] = [];
74-
let rights: [U] = [];
73+
let mut lefts: [T] = [];
74+
let mut rights: [U] = [];
7575
for elt: t<T, U> in eithers {
7676
alt elt { left(l) { lefts += [l]; } right(r) { rights += [r]; } }
7777
}

trunk/src/libcore/extfmt.rs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ mod ct {
8181
type error_fn = fn@(str) -> ! ;
8282

8383
fn parse_fmt_string(s: str, error: error_fn) -> [piece] unsafe {
84-
let pieces: [piece] = [];
84+
let mut pieces: [piece] = [];
8585
let lim = str::len(s);
86-
let buf = "";
86+
let mut buf = "";
8787
fn flush_buf(buf: str, &pieces: [piece]) -> str {
8888
if str::len(buf) > 0u {
8989
let piece = piece_string(buf);
9090
pieces += [piece];
9191
}
9292
ret "";
9393
}
94-
let i = 0u;
94+
let mut i = 0u;
9595
while i < lim {
9696
let curr = str::slice(s, i, i+1u);
9797
if str::eq(curr, "%") {
@@ -285,7 +285,7 @@ mod rt {
285285
fn conv_int(cv: conv, i: int) -> str {
286286
let radix = 10u;
287287
let prec = get_int_precision(cv);
288-
let s = int_to_str_prec(i, radix, prec);
288+
let mut s = int_to_str_prec(i, radix, prec);
289289
if 0 <= i {
290290
if have_flag(cv.flags, flag_sign_always) {
291291
s = "+" + s;
@@ -335,7 +335,7 @@ mod rt {
335335
count_is(c) { (float::to_str_exact, c as uint) }
336336
count_implied { (float::to_str, 6u) }
337337
};
338-
let s = to_str(f, digits);
338+
let mut s = to_str(f, digits);
339339
if 0.0 <= f {
340340
if have_flag(cv.flags, flag_sign_always) {
341341
s = "+" + s;
@@ -389,42 +389,38 @@ mod rt {
389389
}
390390
enum pad_mode { pad_signed, pad_unsigned, pad_nozero, }
391391
fn pad(cv: conv, s: str, mode: pad_mode) -> str unsafe {
392-
let uwidth;
393-
alt cv.width {
392+
let uwidth = alt cv.width {
394393
count_implied { ret s; }
395394
count_is(width) {
396395
// FIXME: Maybe width should be uint
397-
398-
uwidth = width as uint;
396+
width as uint
399397
}
400-
}
398+
};
401399
let strlen = str::char_len(s);
402400
if uwidth <= strlen { ret s; }
403-
let padchar = ' ';
401+
let mut padchar = ' ';
404402
let diff = uwidth - strlen;
405403
if have_flag(cv.flags, flag_left_justify) {
406404
let padstr = str_init_elt(diff, padchar);
407405
ret s + padstr;
408406
}
409-
let might_zero_pad = false;
410-
let signed = false;
411-
alt mode {
412-
pad_nozero {
413-
// fallthrough
414-
415-
}
416-
pad_signed { might_zero_pad = true; signed = true; }
417-
pad_unsigned { might_zero_pad = true; }
418-
}
407+
let {might_zero_pad, signed} = alt mode {
408+
pad_nozero { {might_zero_pad:false, signed:false} }
409+
pad_signed { {might_zero_pad:true, signed:true } }
410+
pad_unsigned { {might_zero_pad:true, signed:false} }
411+
};
419412
fn have_precision(cv: conv) -> bool {
420413
ret alt cv.precision { count_implied { false } _ { true } };
421414
}
422-
let zero_padding = false;
423-
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
424-
!have_precision(cv) {
425-
padchar = '0';
426-
zero_padding = true;
427-
}
415+
let zero_padding = {
416+
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
417+
!have_precision(cv) {
418+
padchar = '0';
419+
true
420+
} else {
421+
false
422+
}
423+
};
428424
let padstr = str_init_elt(diff, padchar);
429425
// This is completely heinous. If we have a signed value then
430426
// potentially rip apart the intermediate result and insert some

trunk/src/libcore/float.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ exact - Whether to enforce the exact number of significant digits
4949
*/
5050
fn to_str_common(num: float, digits: uint, exact: bool) -> str {
5151
if is_NaN(num) { ret "NaN"; }
52-
let (num, accum) = if num < 0.0 { (-num, "-") } else { (num, "") };
52+
let mut (num, accum) = if num < 0.0 { (-num, "-") } else { (num, "") };
5353
let trunc = num as uint;
54-
let frac = num - (trunc as float);
54+
let mut frac = num - (trunc as float);
5555
accum += uint::str(trunc);
5656
if (frac < epsilon && !exact) || digits == 0u { ret accum; }
5757
accum += ".";
58-
let i = digits;
59-
let epsilon = 1. / pow_with_uint(10u, i);
58+
let mut i = digits;
59+
let mut epsilon = 1. / pow_with_uint(10u, i);
6060
while i > 0u && (frac >= epsilon || exact) {
6161
frac *= 10.0;
6262
epsilon *= 10.0;
@@ -132,13 +132,13 @@ Otherwise, some(n) where n is the floating-point
132132
number represented by [num].
133133
*/
134134
fn from_str(num: str) -> option<float> {
135-
let pos = 0u; //Current byte position in the string.
136-
//Used to walk the string in O(n).
137-
let len = str::len(num); //Length of the string, in bytes.
135+
let mut pos = 0u; //Current byte position in the string.
136+
//Used to walk the string in O(n).
137+
let len = str::len(num); //Length of the string, in bytes.
138138

139139
if len == 0u { ret none; }
140-
let total = 0f; //Accumulated result
141-
let c = 'z'; //Latest char.
140+
let mut total = 0f; //Accumulated result
141+
let mut c = 'z'; //Latest char.
142142

143143
//The string must start with one of the following characters.
144144
alt str::char_at(num, 0u) {
@@ -147,7 +147,7 @@ fn from_str(num: str) -> option<float> {
147147
}
148148

149149
//Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly.
150-
let neg = false; //Sign of the result
150+
let mut neg = false; //Sign of the result
151151
alt str::char_at(num, 0u) {
152152
'-' {
153153
neg = true;
@@ -179,7 +179,7 @@ fn from_str(num: str) -> option<float> {
179179
}
180180

181181
if c == '.' {//Examine decimal part
182-
let decimal = 1f;
182+
let mut decimal = 1f;
183183
while(pos < len) {
184184
let char_range = str::char_range_at(num, pos);
185185
c = char_range.ch;
@@ -200,8 +200,8 @@ fn from_str(num: str) -> option<float> {
200200
}
201201

202202
if (c == 'e') | (c == 'E') {//Examine exponent
203-
let exponent = 0u;
204-
let neg_exponent = false;
203+
let mut exponent = 0u;
204+
let mut neg_exponent = false;
205205
if(pos < len) {
206206
let char_range = str::char_range_at(num, pos);
207207
c = char_range.ch;
@@ -275,9 +275,9 @@ fn pow_with_uint(base: uint, pow: uint) -> float {
275275
}
276276
ret 0.;
277277
}
278-
let my_pow = pow;
279-
let total = 1f;
280-
let multiplier = base as float;
278+
let mut my_pow = pow;
279+
let mut total = 1f;
280+
let mut multiplier = base as float;
281281
while (my_pow > 0u) {
282282
if my_pow % 2u == 1u {
283283
total = total * multiplier;

trunk/src/libcore/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn spawn<A:send>(+blk: fn~() -> A) -> future<A> {
9393
9494
"];
9595

96-
let po = comm::port();
96+
let mut po = comm::port();
9797
let ch = comm::chan(po);
9898
task::spawn {||
9999
comm::send(ch, blk())

trunk/src/libcore/i16.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pure fn nonnegative(x: i16) -> bool { x >= 0i16 }
2626

2727
#[doc = "Iterate over the range [`lo`..`hi`)"]
2828
fn range(lo: i16, hi: i16, it: fn(i16)) {
29-
let i = lo;
29+
let mut i = lo;
3030
while i < hi { it(i); i += 1i16; }
3131
}
3232

trunk/src/libcore/i32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pure fn nonnegative(x: i32) -> bool { x >= 0i32 }
2626

2727
#[doc = "Iterate over the range [`lo`..`hi`)"]
2828
fn range(lo: i32, hi: i32, it: fn(i32)) {
29-
let i = lo;
29+
let mut i = lo;
3030
while i < hi { it(i); i += 1i32; }
3131
}
3232

trunk/src/libcore/i64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pure fn nonnegative(x: i64) -> bool { x >= 0i64 }
2626

2727
#[doc = "Iterate over the range [`lo`..`hi`)"]
2828
fn range(lo: i64, hi: i64, it: fn(i64)) {
29-
let i = lo;
29+
let mut i = lo;
3030
while i < hi { it(i); i += 1i64; }
3131
}
3232

trunk/src/libcore/i8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pure fn nonnegative(x: i8) -> bool { x >= 0i8 }
2626

2727
#[doc = "Iterate over the range [`lo`..`hi`)"]
2828
fn range(lo: i8, hi: i8, it: fn(i8)) {
29-
let i = lo;
29+
let mut i = lo;
3030
while i < hi { it(i); i += 1i8; }
3131
}
3232

trunk/src/libcore/int.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Function: range
9090
Iterate over the range [`lo`..`hi`)
9191
*/
9292
fn range(lo: int, hi: int, it: fn(int)) {
93-
let i = lo;
93+
let mut i = lo;
9494
while i < hi { it(i); i += 1; }
9595
}
9696

@@ -106,15 +106,15 @@ radix - The base of the number
106106
*/
107107
fn parse_buf(buf: [u8], radix: uint) -> option<int> {
108108
if vec::len(buf) == 0u { ret none; }
109-
let i = vec::len(buf) - 1u;
110-
let start = 0u;
111-
let power = 1;
109+
let mut i = vec::len(buf) - 1u;
110+
let mut start = 0u;
111+
let mut power = 1;
112112

113113
if buf[0] == ('-' as u8) {
114114
power = -1;
115115
start = 1u;
116116
}
117-
let n = 0;
117+
let mut n = 0;
118118
while true {
119119
alt char::to_digit(buf[i] as char, radix) {
120120
some(d) { n += (d as int) * power; }
@@ -161,9 +161,9 @@ Returns `base` raised to the power of `exponent`
161161
fn pow(base: int, exponent: uint) -> int {
162162
if exponent == 0u { ret 1; } //Not mathemtically true if [base == 0]
163163
if base == 0 { ret 0; }
164-
let my_pow = exponent;
165-
let acc = 1;
166-
let multiplier = base;
164+
let mut my_pow = exponent;
165+
let mut acc = 1;
166+
let mut multiplier = base;
167167
while(my_pow > 0u) {
168168
if my_pow % 2u == 1u {
169169
acc *= multiplier;

trunk/src/libcore/iter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl of iterable<char> for str {
4040
}
4141

4242
fn enumerate<A,IA:iterable<A>>(self: IA, blk: fn(uint, A)) {
43-
let i = 0u;
43+
let mut i = 0u;
4444
self.iter {|a|
4545
blk(i, a);
4646
i += 1u;
@@ -82,7 +82,7 @@ fn flat_map<A,B,IA:iterable<A>,IB:iterable<B>>(
8282
}
8383

8484
fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(-B, A) -> B) -> B {
85-
let b <- b0;
85+
let mut b <- b0;
8686
self.iter {|a|
8787
b = blk(b, a);
8888
}
@@ -92,7 +92,7 @@ fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(-B, A) -> B) -> B {
9292
fn foldr<A:copy,B,IA:iterable<A>>(
9393
self: IA, +b0: B, blk: fn(A, -B) -> B) -> B {
9494

95-
let b <- b0;
95+
let mut b <- b0;
9696
reversed(self) {|a|
9797
b = blk(a, b);
9898
}
@@ -119,7 +119,7 @@ fn count<A,IA:iterable<A>>(self: IA, x: A) -> uint {
119119
}
120120

121121
fn repeat(times: uint, blk: fn()) {
122-
let i = 0u;
122+
let mut i = 0u;
123123
while i < times {
124124
blk();
125125
i += 1u;

trunk/src/libcore/os.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ native mod rustrt {
4141

4242

4343
fn env() -> [(str,str)] {
44-
let pairs = [];
44+
let mut pairs = [];
4545
for p in rustrt::rust_env_pairs() {
4646
let vs = str::splitn_char(p, '=', 1u);
4747
assert vec::len(vs) == 2u;
@@ -87,7 +87,7 @@ mod win32 {
8787
}
8888

8989
fn as_utf16_p<T>(s: str, f: fn(*u16) -> T) -> T {
90-
let t = str::to_utf16(s);
90+
let mut t = str::to_utf16(s);
9191
// Null terminate before passing on.
9292
t += [0u16];
9393
vec::as_buf(t, f)
@@ -468,13 +468,13 @@ fn list_dir(p: path) -> [str] {
468468
#[cfg(target_os = "win32")]
469469
fn star() -> str { "*" }
470470

471-
let p = p;
471+
let mut p = p;
472472
let pl = str::len(p);
473473
if pl == 0u || (p[pl - 1u] as char != path::consts::path_sep
474474
&& p[pl - 1u] as char != path::consts::alt_path_sep) {
475475
p += path::path_sep();
476476
}
477-
let full_paths: [str] = [];
477+
let mut full_paths: [str] = [];
478478
for filename: str in rustrt::rust_list_files(p + star()) {
479479
if !str::eq(filename, ".") {
480480
if !str::eq(filename, "..") {

0 commit comments

Comments
 (0)