Skip to content

Commit 52ee598

Browse files
committed
---
yaml --- r: 11846 b: refs/heads/master c: 6b35875 h: refs/heads/master v: v3
1 parent f7f55a9 commit 52ee598

File tree

20 files changed

+146
-139
lines changed

20 files changed

+146
-139
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: 273c5e5f1129949db780619901fe54b9a3d1fecf
2+
refs/heads/master: 6b35875dca67e5dd1e8f986c8528ffbf973fdcbb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/mk/target.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
3838
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
3939
$$(TSREQ$(1)_T_$(2)_H_$(3))
4040
@$$(call E, compile_and_link: $$@)
41-
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
41+
$$(STAGE$(1)_T_$(2)_H_$(3)) --enforce-mut-vars -o $$@ $$< && touch $$@
4242

4343
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM): \
4444
rustllvm/$(2)/$$(CFG_RUSTLLVM)

trunk/src/libstd/bitv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn process(v0: t, v1: t, op: fn(uint, uint) -> uint) -> bool {
4545
let len = vec::len(v1.storage);
4646
assert (vec::len(v0.storage) == len);
4747
assert (v0.nbits == v1.nbits);
48-
let changed = false;
48+
let mut changed = false;
4949
uint::range(0u, len) {|i|
5050
let w0 = v0.storage[i];
5151
let w1 = v1.storage[i];
@@ -113,7 +113,7 @@ fn equal(v0: t, v1: t) -> bool {
113113
// we can eliminate this painful while-loop
114114

115115
let len = vec::len(v1.storage);
116-
let i = 0u;
116+
let mut i = 0u;
117117
while i < len {
118118
if v0.storage[i] != v1.storage[i] { ret false; }
119119
i = i + 1u;
@@ -201,7 +201,7 @@ The resulting string has the same length as the bitvector, and each character
201201
is either '0' or '1'.
202202
"]
203203
fn to_str(v: t) -> str {
204-
let rs = "";
204+
let mut rs = "";
205205
for i: uint in to_vec(v) { if i == 1u { rs += "1"; } else { rs += "0"; } }
206206
ret rs;
207207
}
@@ -215,7 +215,7 @@ bitvector and vector must have the same length
215215
fn eq_vec(v0: t, v1: [uint]) -> bool {
216216
assert (v0.nbits == vec::len::<uint>(v1));
217217
let len = v0.nbits;
218-
let i = 0u;
218+
let mut i = 0u;
219219
while i < len {
220220
let w0 = get(v0, i);
221221
let w1 = v1[i];

trunk/src/libstd/deque.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ fn create<T: copy>() -> t<T> {
2626
fn grow<T: copy>(nelts: uint, lo: uint, elts: [mutable cell<T>]) ->
2727
[mutable cell<T>] {
2828
assert (nelts == vec::len(elts));
29-
let rv = [mutable];
29+
let mut rv = [mutable];
3030

31-
let i = 0u;
31+
let mut i = 0u;
3232
let nalloc = uint::next_power_of_two(nelts + 1u);
3333
while i < nalloc {
3434
if i < nelts {

trunk/src/libstd/ebml.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn doc_at(data: @[u8], start: uint) -> tagged_doc {
7777
}
7878

7979
fn maybe_get_doc(d: doc, tg: uint) -> option<doc> {
80-
let pos = d.start;
80+
let mut pos = d.start;
8181
while pos < d.end {
8282
let elt_tag = vuint_at(*d.data, pos);
8383
let elt_size = vuint_at(*d.data, elt_tag.next);
@@ -100,7 +100,7 @@ fn get_doc(d: doc, tg: uint) -> doc {
100100
}
101101

102102
fn docs(d: doc, it: fn(uint, doc)) {
103-
let pos = d.start;
103+
let mut pos = d.start;
104104
while pos < d.end {
105105
let elt_tag = vuint_at(*d.data, pos);
106106
let elt_size = vuint_at(*d.data, elt_tag.next);
@@ -110,7 +110,7 @@ fn docs(d: doc, it: fn(uint, doc)) {
110110
}
111111

112112
fn tagged_docs(d: doc, tg: uint, it: fn(doc)) {
113-
let pos = d.start;
113+
let mut pos = d.start;
114114
while pos < d.end {
115115
let elt_tag = vuint_at(*d.data, pos);
116116
let elt_size = vuint_at(*d.data, elt_tag.next);
@@ -154,20 +154,19 @@ fn doc_as_i64(d: doc) -> i64 { doc_as_u64(d) as i64 }
154154
type writer = {writer: io::writer, mutable size_positions: [uint]};
155155

156156
fn write_sized_vuint(w: io::writer, n: uint, size: uint) {
157-
let buf: [u8];
158-
alt size {
159-
1u { buf = [0x80u8 | (n as u8)]; }
160-
2u { buf = [0x40u8 | ((n >> 8_u) as u8), n as u8]; }
157+
let buf: [u8] = alt size {
158+
1u { [0x80u8 | (n as u8)] }
159+
2u { [0x40u8 | ((n >> 8_u) as u8), n as u8] }
161160
3u {
162-
buf = [0x20u8 | ((n >> 16_u) as u8), (n >> 8_u) as u8,
163-
n as u8];
161+
[0x20u8 | ((n >> 16_u) as u8), (n >> 8_u) as u8,
162+
n as u8]
164163
}
165164
4u {
166-
buf = [0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
167-
(n >> 8_u) as u8, n as u8];
165+
[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
166+
(n >> 8_u) as u8, n as u8]
168167
}
169168
_ { fail #fmt("vint to write too big: %?", n); }
170-
}
169+
};
171170
w.write(buf);
172171
}
173172

trunk/src/libstd/getopts.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,21 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe {
171171
let n_opts = vec::len::<opt>(opts);
172172
fn f(_x: uint) -> [optval] { ret []; }
173173
let vals = vec::to_mut(vec::from_fn(n_opts, f));
174-
let free: [str] = [];
174+
let mut free: [str] = [];
175175
let l = vec::len(args);
176-
let i = 0u;
176+
let mut i = 0u;
177177
while i < l {
178178
let cur = args[i];
179179
let curlen = str::len(cur);
180180
if !is_arg(cur) {
181181
free += [cur];
182182
} else if str::eq(cur, "--") {
183-
let j = i + 1u;
183+
let mut j = i + 1u;
184184
while j < l { free += [args[j]]; j += 1u; }
185185
break;
186186
} else {
187-
let names;
188-
let i_arg = option::none::<str>;
187+
let mut names;
188+
let mut i_arg = option::none::<str>;
189189
if cur[1] == '-' as u8 {
190190
let tail = str::slice(cur, 2u, curlen);
191191
let tail_eq = str::splitn_char(tail, '=', 1u);
@@ -198,22 +198,21 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe {
198198
option::some::<str>(tail_eq[1]);
199199
}
200200
} else {
201-
let j = 1u;
201+
let mut j = 1u;
202202
names = [];
203203
while j < curlen {
204204
let range = str::char_range_at(cur, j);
205205
names += [short(range.ch)];
206206
j = range.next;
207207
}
208208
}
209-
let name_pos = 0u;
209+
let mut name_pos = 0u;
210210
for nm: name in names {
211211
name_pos += 1u;
212-
let optid;
213-
alt find_opt(opts, nm) {
214-
some(id) { optid = id; }
212+
let optid = alt find_opt(opts, nm) {
213+
some(id) { id }
215214
none { ret err(unrecognized_option(name_str(nm))); }
216-
}
215+
};
217216
alt opts[optid].hasarg {
218217
no {
219218
if !option::is_none::<str>(i_arg) {
@@ -289,7 +288,7 @@ Returns a vector of the arguments provided to all matches of the given option.
289288
Used when an option accepts multiple values.
290289
"]
291290
fn opt_strs(m: match, nm: str) -> [str] {
292-
let acc: [str] = [];
291+
let mut acc: [str] = [];
293292
for v: optval in opt_vals(m, nm) {
294293
alt v { val(s) { acc += [s]; } _ { } }
295294
}

trunk/src/libstd/json.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn to_writer(wr: io::writer, j: json) {
4646
num(n) { wr.write_str(float::to_str(n, 6u)); }
4747
string(s) {
4848
wr.write_char('"');
49-
let escaped = "";
49+
let mut escaped = "";
5050
str::chars_iter(s) { |c|
5151
alt c {
5252
'"' { escaped += "\\\""; }
@@ -67,7 +67,7 @@ fn to_writer(wr: io::writer, j: json) {
6767
}
6868
list(v) {
6969
wr.write_char('[');
70-
let first = true;
70+
let mut first = true;
7171
vec::iter(v) { |item|
7272
if !first {
7373
wr.write_str(", ");
@@ -84,7 +84,7 @@ fn to_writer(wr: io::writer, j: json) {
8484
}
8585

8686
wr.write_str("{ ");
87-
let first = true;
87+
let mut first = true;
8888
d.items { |key, value|
8989
if !first {
9090
wr.write_str(", ");
@@ -189,14 +189,14 @@ impl parser for parser {
189189
}
190190

191191
fn parse_number() -> result<json, error> {
192-
let neg = 1f;
192+
let mut neg = 1f;
193193

194194
if self.ch == '-' {
195195
self.bump();
196196
neg = -1f;
197197
}
198198

199-
let res = alt self.parse_integer() {
199+
let mut res = alt self.parse_integer() {
200200
ok(res) { res }
201201
err(e) { ret err(e); }
202202
};
@@ -219,7 +219,7 @@ impl parser for parser {
219219
}
220220

221221
fn parse_integer() -> result<float, error> {
222-
let res = 0f;
222+
let mut res = 0f;
223223

224224
alt self.ch {
225225
'0' {
@@ -259,8 +259,8 @@ impl parser for parser {
259259
_ { ret self.error("invalid number"); }
260260
}
261261

262-
let res = res;
263-
let dec = 1f;
262+
let mut res = res;
263+
let mut dec = 1f;
264264
while !self.eof() {
265265
alt self.ch {
266266
'0' to '9' {
@@ -279,9 +279,9 @@ impl parser for parser {
279279
fn parse_exponent(res: float) -> result<float, error> {
280280
self.bump();
281281

282-
let res = res;
283-
let exp = 0u;
284-
let neg_exp = false;
282+
let mut res = res;
283+
let mut exp = 0u;
284+
let mut neg_exp = false;
285285

286286
alt self.ch {
287287
'+' { self.bump(); }
@@ -318,8 +318,8 @@ impl parser for parser {
318318
}
319319

320320
fn parse_str() -> result<str, error> {
321-
let escape = false;
322-
let res = "";
321+
let mut escape = false;
322+
let mut res = "";
323323

324324
while !self.eof() {
325325
self.bump();
@@ -336,8 +336,8 @@ impl parser for parser {
336336
't' { str::push_char(res, '\t'); }
337337
'u' {
338338
// Parse \u1234.
339-
let i = 0u;
340-
let n = 0u;
339+
let mut i = 0u;
340+
let mut n = 0u;
341341
while i < 4u {
342342
alt self.next_char() {
343343
'0' to '9' {
@@ -346,6 +346,7 @@ impl parser for parser {
346346
}
347347
_ { ret self.error("invalid \\u escape"); }
348348
}
349+
i += 1u;
349350
}
350351

351352
// Error out if we didn't parse 4 digits.
@@ -376,7 +377,7 @@ impl parser for parser {
376377
self.bump();
377378
self.parse_whitespace();
378379

379-
let values = [];
380+
let mut values = [];
380381

381382
if self.ch == ']' {
382383
self.bump();
@@ -479,7 +480,7 @@ fn eq(value0: json, value1: json) -> bool {
479480
(list(l0), list(l1)) { vec::all2(l0, l1, eq) }
480481
(dict(d0), dict(d1)) {
481482
if d0.size() == d1.size() {
482-
let equal = true;
483+
let mut equal = true;
483484
d0.items { |k, v0|
484485
alt d1.find(k) {
485486
some(v1) {

trunk/src/libstd/list.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ accumulated result.
2828
* f - The function to apply
2929
"]
3030
fn foldl<T: copy, U>(ls: list<U>, z: T, f: fn(T, U) -> T) -> T {
31-
let accum: T = z;
31+
let mut accum: T = z;
3232
iter(ls) {|elt| accum = f(accum, elt);}
3333
accum
3434
}
@@ -41,7 +41,7 @@ When function `f` returns true then an option containing the element
4141
is returned. If `f` matches no elements then none is returned.
4242
"]
4343
fn find<T: copy>(ls: list<T>, f: fn(T) -> bool) -> option<T> {
44-
let ls = ls;
44+
let mut ls = ls;
4545
loop {
4646
alt ls {
4747
cons(hd, tl) {
@@ -55,7 +55,7 @@ fn find<T: copy>(ls: list<T>, f: fn(T) -> bool) -> option<T> {
5555

5656
#[doc = "Returns true if a list contains an element with the given value"]
5757
fn has<T: copy>(ls: list<T>, elt: T) -> bool {
58-
let ls = ls;
58+
let mut ls = ls;
5959
loop {
6060
alt ls {
6161
cons(hd, tl) { if elt == hd { ret true; } else { ls = *tl; } }
@@ -79,7 +79,7 @@ pure fn is_not_empty<T: copy>(ls: list<T>) -> bool {
7979

8080
#[doc = "Returns the length of a list"]
8181
fn len<T>(ls: list<T>) -> uint {
82-
let count = 0u;
82+
let mut count = 0u;
8383
iter(ls) {|_e| count += 1u;}
8484
count
8585
}
@@ -110,7 +110,7 @@ fn iter<T>(l: list<T>, f: fn(T)) {
110110
alt l {
111111
cons(hd, tl) {
112112
f(hd);
113-
let cur = tl;
113+
let mut cur = tl;
114114
loop {
115115
alt *cur {
116116
cons(hd, tl) {

trunk/src/libstd/map.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ mod chained {
9494
fn search_rem<K: copy, V: copy>(
9595
tbl: t<K,V>, k: K, h: uint, idx: uint,
9696
e_root: @entry<K,V>) -> search_result<K,V> {
97-
let e0 = e_root;
98-
let comp = 1u; // for logging
97+
let mut e0 = e_root;
98+
let mut comp = 1u; // for logging
9999
loop {
100100
alt e0.next {
101101
absent {
@@ -207,7 +207,7 @@ mod chained {
207207

208208
fn foreach_entry<K: copy, V: copy>(chain0: chain<K,V>,
209209
blk: fn(@entry<K,V>)) {
210-
let chain = chain0;
210+
let mut chain = chain0;
211211
loop {
212212
alt chain {
213213
absent { ret; }
@@ -222,7 +222,8 @@ mod chained {
222222

223223
fn foreach_chain<K: copy, V: copy>(chains: [const chain<K,V>],
224224
blk: fn(@entry<K,V>)) {
225-
let i = 0u, n = vec::len(chains);
225+
let mut i = 0u;
226+
let n = vec::len(chains);
226227
while i < n {
227228
foreach_entry(chains[i], blk);
228229
i += 1u;

0 commit comments

Comments
 (0)