Permalink
Browse files

make --enforce-mut-vars always on, add mut annotations to remaining f…

…iles
  • Loading branch information...
1 parent ea60308 commit dc07280b087c89506ad7e5f66f4f88b18d06be2e @nikomatsakis nikomatsakis committed Mar 22, 2012
Showing with 519 additions and 508 deletions.
  1. +16 −13 doc/rust.md
  2. +21 −18 doc/tutorial.md
  3. +4 −14 mk/target.mk
  4. +19 −19 src/cargo/cargo.rs
  5. +2 −2 src/compiletest/compiletest.rs
  6. +4 −4 src/compiletest/errors.rs
  7. +5 −5 src/compiletest/header.rs
  8. +4 −4 src/compiletest/procsrv.rs
  9. +12 −12 src/compiletest/runtest.rs
  10. +5 −5 src/fuzzer/fuzzer.rs
  11. +2 −2 src/libcore/comm.rs
  12. +1 −1 src/libcore/io.rs
  13. +2 −3 src/libcore/iter.rs
  14. +3 −3 src/libcore/os.rs
  15. +1 −1 src/libcore/run.rs
  16. +21 −21 src/libcore/str.rs
  17. +1 −1 src/libcore/task.rs
  18. +36 −36 src/libcore/vec.rs
  19. +7 −7 src/libstd/bitv.rs
  20. +1 −1 src/libstd/deque.rs
  21. +2 −2 src/libstd/map.rs
  22. +12 −12 src/libstd/rope.rs
  23. +4 −4 src/libstd/sha1.rs
  24. +3 −3 src/libstd/sort.rs
  25. +1 −1 src/libstd/test.rs
  26. +1 −3 src/rustc/driver/driver.rs
  27. +2 −3 src/rustc/driver/session.rs
  28. +1 −1 src/rustc/middle/mutbl.rs
  29. +7 −0 src/rustc/syntax/print/pprust.rs
  30. +2 −3 src/rustdoc/astsrv.rs
  31. +4 −4 src/rustdoc/desc_to_brief_pass.rs
  32. +4 −4 src/rustdoc/markdown_writer.rs
  33. +2 −2 src/rustdoc/reexport_pass.rs
  34. +1 −1 src/rustdoc/rustdoc.rs
  35. +3 −3 src/rustdoc/sectionalize_pass.rs
  36. +3 −3 src/rustdoc/unindent_pass.rs
  37. +1 −1 src/test/auxiliary/cci_impl_lib.rs
  38. +1 −1 src/test/auxiliary/cci_iter_lib.rs
  39. +1 −1 src/test/auxiliary/cci_no_inline_lib.rs
  40. +4 −4 src/test/bench/99bob-iter.rs
  41. +2 −2 src/test/bench/99bob-pattern.rs
  42. +4 −4 src/test/bench/99bob-simple.rs
  43. +3 −3 src/test/bench/msgsend.rs
  44. +5 −5 src/test/bench/shootout-binarytrees.rs
  45. +8 −8 src/test/bench/shootout-fannkuchredux.rs
  46. +4 −4 src/test/bench/shootout-fasta.rs
  47. +9 −9 src/test/bench/shootout-mandelbrot.rs
  48. +14 −14 src/test/bench/shootout-nbody.rs
  49. +2 −2 src/test/bench/shootout-pfib.rs
  50. +8 −8 src/test/bench/shootout-spectralnorm.rs
  51. +3 −3 src/test/bench/sudoku.rs
  52. +2 −2 src/test/bench/task-perf-one-million.rs
  53. +2 −2 src/test/bench/task-perf-spawnalot.rs
  54. +1 −1 src/test/bench/task-perf-vector-party.rs
  55. +9 −9 src/test/bench/task-perf-word-count.rs
  56. +3 −1 src/test/run-fail/explicit-fail-msg.rs
  57. +1 −1 src/test/run-fail/unwind-misc-1.rs
  58. +2 −2 src/test/run-pass/alt-join.rs
  59. +1 −1 src/test/run-pass/alt-phi.rs
  60. +1 −1 src/test/run-pass/alt-tag.rs
  61. +1 −1 src/test/run-pass/argument-passing.rs
  62. +6 −6 src/test/run-pass/assign-assign.rs
  63. +1 −1 src/test/run-pass/auto-loop.rs
  64. +1 −1 src/test/run-pass/basic-1.rs
  65. +1 −1 src/test/run-pass/basic-2.rs
  66. +2 −2 src/test/run-pass/basic.rs
  67. +2 −2 src/test/run-pass/bitwise.rs
  68. +1 −1 src/test/run-pass/block-arg.rs
  69. +1 −1 src/test/run-pass/block-iter-1.rs
  70. +1 −1 src/test/run-pass/block-iter-2.rs
  71. +1 −1 src/test/run-pass/break.rs
  72. +2 −2 src/test/run-pass/chan-leak.rs
  73. +3 −3 src/test/run-pass/complex.rs
  74. +1 −1 src/test/run-pass/constraint-prop-expr-move.rs
  75. +2 −2 src/test/run-pass/constraint-prop-swap.rs
  76. +2 −2 src/test/run-pass/expr-alt.rs
  77. +1 −1 src/test/run-pass/expr-block.rs
  78. +1 −1 src/test/run-pass/fn-bare-assign.rs
  79. +1 −1 src/test/run-pass/foreach-nested.rs
  80. +4 −4 src/test/run-pass/foreach-put-structured.rs
  81. +2 −2 src/test/run-pass/foreach-simple-outer-slot.rs
  82. +4 −4 src/test/run-pass/generic-fn.rs
  83. +1 −1 src/test/run-pass/generic-tag-alt.rs
  84. +1 −1 src/test/run-pass/generic-tag.rs
  85. +4 −4 src/test/run-pass/hashmap-memory.rs
  86. +1 −1 src/test/run-pass/i32-sub.rs
  87. +1 −1 src/test/run-pass/i8-incr.rs
  88. +1 −1 src/test/run-pass/iface-generic.rs
  89. +1 −1 src/test/run-pass/import-glob-crate.rs
  90. +3 −3 src/test/run-pass/interior-vec.rs
  91. +2 −2 src/test/run-pass/issue-1257.rs
  92. +1 −1 src/test/run-pass/issue-783.rs
  93. +3 −3 src/test/run-pass/istr.rs
  94. +2 −2 src/test/run-pass/iter-range.rs
  95. +1 −1 src/test/run-pass/ivec-add.rs
  96. +1 −1 src/test/run-pass/last-use-corner-cases.rs
  97. +1 −1 src/test/run-pass/lazy-and-or.rs
  98. +1 −1 src/test/run-pass/lazy-init.rs
  99. +1 −1 src/test/run-pass/lazychan.rs
  100. +1 −1 src/test/run-pass/leak-tag-copy.rs
  101. +1 −1 src/test/run-pass/let-destruct-fresh-mem.rs
  102. +2 −2 src/test/run-pass/linear-for-loop.rs
  103. +1 −1 src/test/run-pass/long-while.rs
  104. +2 −2 src/test/run-pass/loop-break-cont.rs
  105. +1 −1 src/test/run-pass/loop-scope.rs
  106. +1 −1 src/test/run-pass/maybe-mutable.rs
  107. +1 −1 src/test/run-pass/monad.rs
  108. +1 −1 src/test/run-pass/morestack5.rs
  109. +1 −1 src/test/run-pass/move-1-unique.rs
  110. +1 −1 src/test/run-pass/move-1.rs
  111. +1 −1 src/test/run-pass/move-3-unique.rs
  112. +1 −1 src/test/run-pass/move-3.rs
  113. +1 −1 src/test/run-pass/move-scalar.rs
  114. +1 −1 src/test/run-pass/mutable-alias-vec.rs
  115. +1 −1 src/test/run-pass/nested-alts.rs
  116. +1 −1 src/test/run-pass/opeq.rs
  117. +1 −1 src/test/run-pass/operator-overloading.rs
  118. +6 −6 src/test/run-pass/output-slot-variants.rs
  119. +1 −1 src/test/run-pass/over-constrained-vregs.rs
  120. +1 −1 src/test/run-pass/paren-free.rs
  121. +1 −1 src/test/run-pass/regions-self-in-enums.rs
  122. +1 −1 src/test/run-pass/shadow.rs
  123. +1 −1 src/test/run-pass/simple-infer.rs
  124. +1 −1 src/test/run-pass/spawn-fn.rs
  125. +3 −3 src/test/run-pass/static-impl.rs
  126. +1 −1 src/test/run-pass/str-append.rs
  127. +1 −1 src/test/run-pass/str-growth.rs
  128. +3 −3 src/test/run-pass/string-self-append.rs
  129. +4 −1 src/test/run-pass/swap-1.rs
  130. +1 −1 src/test/run-pass/swap-2.rs
  131. +1 −1 src/test/run-pass/task-comm-0.rs
  132. +2 −2 src/test/run-pass/task-comm-10.rs
  133. +1 −1 src/test/run-pass/task-comm-12.rs
  134. +1 −1 src/test/run-pass/task-comm-13.rs
  135. +2 −2 src/test/run-pass/task-comm-14.rs
  136. +1 −1 src/test/run-pass/task-comm-15.rs
  137. +3 −3 src/test/run-pass/task-comm-16.rs
  138. +4 −4 src/test/run-pass/task-comm-3.rs
  139. +2 −2 src/test/run-pass/task-comm-4.rs
  140. +2 −2 src/test/run-pass/task-comm-5.rs
  141. +3 −3 src/test/run-pass/task-comm-6.rs
  142. +4 −4 src/test/run-pass/task-comm-7.rs
  143. +3 −3 src/test/run-pass/task-comm-9.rs
  144. +10 −10 src/test/run-pass/task-comm.rs
  145. +1 −1 src/test/run-pass/terminate-in-initializer.rs
  146. +1 −1 src/test/run-pass/threads.rs
  147. +1 −1 src/test/run-pass/type-params-in-for-each.rs
  148. +5 −2 src/test/run-pass/typestate-cfg-nesting.rs
  149. +1 −1 src/test/run-pass/u32-decr.rs
  150. +2 −2 src/test/run-pass/u8-incr-decr.rs
  151. +1 −1 src/test/run-pass/u8-incr.rs
  152. +1 −1 src/test/run-pass/unique-assign-copy.rs
  153. +1 −1 src/test/run-pass/unique-assign-drop.rs
  154. +1 −1 src/test/run-pass/unique-assign.rs
  155. +1 −1 src/test/run-pass/unique-fn-arg-mut.rs
  156. +1 −1 src/test/run-pass/unique-move-temp.rs
  157. +1 −1 src/test/run-pass/unique-move.rs
  158. +2 −2 src/test/run-pass/unique-send-2.rs
  159. +2 −2 src/test/run-pass/unique-swap.rs
  160. +6 −1 src/test/run-pass/unit.rs
  161. +1 −1 src/test/run-pass/unreachable-code.rs
  162. +1 −1 src/test/run-pass/use-uninit-alt.rs
  163. +1 −1 src/test/run-pass/use-uninit-alt2.rs
  164. +1 −1 src/test/run-pass/utf8.rs
  165. +1 −1 src/test/run-pass/utf8_chars.rs
  166. +1 −1 src/test/run-pass/vec-growth.rs
  167. +1 −1 src/test/run-pass/vec-ivec-deadlock.rs
  168. +1 −1 src/test/run-pass/vec-late-init.rs
  169. +1 −1 src/test/run-pass/vec-push.rs
  170. +5 −5 src/test/run-pass/vec-self-append.rs
  171. +1 −1 src/test/run-pass/vec.rs
  172. +4 −4 src/test/run-pass/weird-exprs.rs
  173. +2 −2 src/test/run-pass/while-and-do-while.rs
  174. +1 −1 src/test/run-pass/while-cont.rs
  175. +3 −3 src/test/run-pass/while-loop-constraints-2.rs
  176. +2 −2 src/test/run-pass/while-prelude-drop.rs
  177. +1 −1 src/test/run-pass/while-with-break.rs
  178. +1 −1 src/test/run-pass/writealias.rs
  179. +1 −1 src/test/run-pass/yield2.rs
View
29 doc/rust.md
@@ -1003,7 +1003,7 @@ fn iter<T>(seq: [T], f: fn(T)) {
for elt: T in seq { f(elt); }
}
fn map<T, U>(seq: [T], f: fn(T) -> U) -> [U] {
- let acc = [];
+ let mut acc = [];
for elt in seq { acc += [f(elt)]; }
acc
}
@@ -1104,7 +1104,7 @@ enum animal {
cat
}
-let a: animal = dog;
+let mut a: animal = dog;
a = cat;
~~~~
@@ -1254,7 +1254,7 @@ not given, and the name is mandatory.
~~~~
impl uint_loops for uint {
fn times(f: fn(uint)) {
- let i = 0u;
+ let mut i = 0u;
while i < self { f(i); i += 1u; }
}
}
@@ -1775,7 +1775,7 @@ expression. No allocation or destruction is entailed.
An example of three different move expressions:
~~~~~~~~
-# let x = [mut 0];
+# let mut x = [mut 0];
# let a = [mut 0];
# let b = 0;
# let y = {mut z: 0};
@@ -1804,8 +1804,8 @@ expression. No allocation or destruction is entailed.
An example of three different swap expressions:
~~~~~~~~
-# let x = [mut 0];
-# let a = [mut 0];
+# let mut x = [mut 0];
+# let mut a = [mut 0];
# let i = 0;
# let y = {mut z: 0};
# let b = {mut c: 0};
@@ -1827,7 +1827,7 @@ expression](#unary-copy-expressions). For example, the following two
expressions have the same effect:
~~~~
-# let x = 0;
+# let mut x = 0;
# let y = 0;
x = y;
@@ -2015,7 +2015,7 @@ loop body. If it evaluates to `false`, control exits the loop.
An example of a simple `while` expression:
~~~~
-# let i = 0;
+# let mut i = 0;
# let println = io::println;
while i < 10 {
@@ -2027,7 +2027,7 @@ while i < 10 {
An example of a `do`-`while` expression:
~~~~
-# let i = 0;
+# let mut i = 0;
# let println = io::println;
do {
@@ -2053,7 +2053,7 @@ For example, the following (contrived) function uses a `loop` with a
~~~~
fn count() -> bool {
- let i = 0;
+ let mut i = 0;
loop {
i += 1;
if i == 20 { ret true; }
@@ -2801,7 +2801,7 @@ fn add(x: int, y: int) -> int {
ret x + y;
}
-let x = add(5,7);
+let mut x = add(5,7);
type binop = fn(int,int) -> int;
let bo: binop = add;
@@ -2880,7 +2880,7 @@ has a set of points before and after it in the implied control flow.
For example, this code:
~~~~~~~~
-# let s;
+# let mut s;
s = "hello, world";
io::println(s);
@@ -3154,7 +3154,10 @@ A _reference_ references a value outside the frame. It may refer to a
value allocated in another frame *or* a boxed value in the heap. The
reference-formation rules ensure that the referent will outlive the reference.
-Local variables are always implicitly mutable.
+Local variables are immutable unless declared with `let mut`. The
+`mut` keyword applies to all local variables declared within that
+declaration (so `let mut x, y` declares two mutable variables, `x` and
+`y`).
Local variables are not initialized when allocated; the entire frame worth of
local variables are allocated at once, on frame-entry, in an uninitialized
View
39 doc/tutorial.md
@@ -26,7 +26,7 @@ a curly-brace language in the tradition of C, C++, and JavaScript.
~~~~
fn fac(n: int) -> int {
- let result = 1, i = 1;
+ let mut result = 1, i = 1;
while i <= n {
result *= i;
i += 1;
@@ -286,16 +286,19 @@ fn this_doesnt(_x: int) {}
## Variable declaration
-The `let` keyword, as we've seen, introduces a local variable. Global
-constants can be defined with `const`:
+The `let` keyword, as we've seen, introduces a local variable. Local
+variables are immutable by default: `let mut` can be used to introduce
+a local variable that can be reassigned. Global constants can be
+defined with `const`:
~~~~
use std;
const repeat: uint = 5u;
fn main() {
- let count = 0u;
+ let hi = "Hi!";
+ let mut count = 0u;
while count < repeat {
- io::println("Hi!");
+ io::println(hi);
count += 1u;
}
}
@@ -320,7 +323,7 @@ annotation:
~~~~
// The type of this vector will be inferred based on its use.
let x = [];
-# x = [3];
+# vec::map(x, fn&(&&_y:int) -> int { _y });
// Explicitly say this is a vector of integers.
let y: [int] = [];
~~~~
@@ -665,7 +668,7 @@ keyword `break` can be used to abort the loop, and `cont` can be used
to abort the current iteration and continue with the next.
~~~~
-let x = 5;
+let mut x = 5;
while true {
x += x - 3;
if x % 5 == 0 { break; }
@@ -761,7 +764,7 @@ failure otherwise. It is typically used to double-check things that
*should* hold at a certain point in a program.
~~~~
-let x = 100;
+let mut x = 100;
while (x > 10) { x -= 10; }
assert x == 10;
~~~~
@@ -933,7 +936,7 @@ of integers backwards:
~~~~
fn for_rev(v: [int], act: fn(int)) {
- let i = vec::len(v);
+ let mut i = vec::len(v);
while (i > 0u) {
i -= 1u;
act(v[i]);
@@ -1273,7 +1276,7 @@ The `+` operator means concatenation when applied to vector types.
Growing a vector in Rust is not as inefficient as it looks :
~~~~
-let myvec = [], i = 0;
+let mut myvec = [], i = 0;
while i < 100 {
myvec += [i];
i += 1;
@@ -1376,7 +1379,7 @@ in `main`, so we're good. But the call could also look like this:
~~~~
# fn myfunc(a: int, b: fn()) {}
# fn get_another_record() -> int { 1 }
-# let x = 1;
+# let mut x = 1;
myfunc(x, {|| x = get_another_record(); });
~~~~
@@ -1436,7 +1439,7 @@ very cheap, but you'll occasionally have to copy them to ensure
safety.
~~~~
-let my_rec = {a: 4, b: [1, 2, 3]};
+let mut my_rec = {a: 4, b: [1, 2, 3]};
alt my_rec {
{a, b} {
log(info, b); // This is okay
@@ -1497,15 +1500,15 @@ Thus, Rust allows functions and datatypes to have type parameters.
~~~~
fn for_rev<T>(v: [T], act: fn(T)) {
- let i = vec::len(v);
+ let mut i = vec::len(v);
while i > 0u {
i -= 1u;
act(v[i]);
}
}
fn map<T, U>(v: [T], f: fn(T) -> U) -> [U] {
- let acc = [];
+ let mut acc = [];
for elt in v { acc += [f(elt)]; }
ret acc;
}
@@ -1548,7 +1551,7 @@ programs that just can't be typed.
~~~~
let n = option::none;
-# n = option::some(1);
+# option::may(n, fn&(&&x:int) {})
~~~~
If you never do anything else with `n`, the compiler will not be able
@@ -1982,7 +1985,7 @@ parameters.
~~~~
# iface to_str { fn to_str() -> str; }
fn comma_sep<T: to_str>(elts: [T]) -> str {
- let result = "", first = true;
+ let mut result = "", first = true;
for elt in elts {
if first { first = false; }
else { result += ", "; }
@@ -2094,7 +2097,7 @@ to leave off the `of` clause.
# fn mk_currency(x: int, s: str) {}
impl int_util for int {
fn times(b: fn(int)) {
- let i = 0;
+ let mut i = 0;
while i < self { b(i); i += 1; }
}
fn dollars() -> currency {
@@ -2450,7 +2453,7 @@ Here is the function which implements the child task:
~~~~
fn stringifier(from_parent: comm::port<uint>,
to_parent: comm::chan<str>) {
- let value: uint;
+ let mut value: uint;
do {
value = comm::recv(from_parent);
comm::send(to_parent, uint::to_str(value, 10u));
View
18 mk/target.mk
@@ -11,13 +11,6 @@
USE_SNAPSHOT_RUNTIME=0
USE_SNAPSHOT_CORELIB=0
-# Do not use --enforce-mut-vars in stage0, for now, as the snapshot
-# has an older version of the check.
-ENFORCE_MUT_VARS_0=
-ENFORCE_MUT_VARS_1=--enforce-mut-vars
-ENFORCE_MUT_VARS_2=--enforce-mut-vars
-ENFORCE_MUT_VARS_3=--enforce-mut-vars
-
define TARGET_STAGE_N
$$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.ll: \
@@ -41,8 +34,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
$$(TSREQ$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
- $$(STAGE$(1)_T_$(2)_H_$(3)) $$(ENFORCE_MUT_VARS_$(1)) \
- -o $$@ $$< && touch $$@
+ $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM): \
rustllvm/$(2)/$$(CFG_RUSTLLVM)
@@ -53,8 +45,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X): \
$$(RUSTC_INPUTS) \
$$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
- $$(STAGE$(1)_T_$(2)_H_$(3)) $$(ENFORCE_MUT_VARS_$(1)) \
- -o $$@ $$<
+ $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$<
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
$$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
@@ -63,8 +54,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC): \
$$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
$$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
- $$(STAGE$(1)_T_$(2)_H_$(3)) $$(ENFORCE_MUT_VARS_$(1)) \
- -o $$@ $$< && touch $$@
+ $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
endef
@@ -127,7 +117,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
$$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
$$(TSREQ$(1)_T_$(2)_H_$(3))
@$$(call E, compile_and_link: $$@)
- $$(STAGE$(1)_T_$(2)_H_$(3)) --enforce-mut-vars -o $$@ $$< && touch $$@
+ $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
endef
View
38 src/cargo/cargo.rs
@@ -93,9 +93,9 @@ fn error(msg: str) {
fn load_link(mis: [@ast::meta_item]) -> (option<str>,
option<str>,
option<str>) {
- let name = none;
- let vers = none;
- let uuid = none;
+ let mut name = none;
+ let mut vers = none;
+ let mut uuid = none;
for a: @ast::meta_item in mis {
alt a.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
@@ -124,12 +124,12 @@ fn load_pkg(filename: str) -> option<pkg> {
};
let c = parser::parse_crate_from_crate_file(filename, [], sess);
- let name = none;
- let vers = none;
- let uuid = none;
- let desc = none;
- let sigs = none;
- let crate_type = none;
+ let mut name = none;
+ let mut vers = none;
+ let mut uuid = none;
+ let mut desc = none;
+ let mut sigs = none;
+ let mut crate_type = none;
for a in c.node.attrs {
alt a.node.value.node {
@@ -273,7 +273,7 @@ fn load_one_source_package(&src: source, p: map::hashmap<str, json::json>) {
_ { none }
};
- let tags = [];
+ let mut tags = [];
alt p.find("tags") {
some(json::list(js)) {
for j in js {
@@ -390,7 +390,7 @@ fn configure(opts: options) -> cargo {
let sources = map::str_hash::<source>();
try_parse_sources(path::connect(syscargo, "sources.json"), sources);
try_parse_sources(path::connect(syscargo, "local-sources.json"), sources);
- let c = {
+ let mut c = {
pgp: pgp::supported(),
root: p,
bindir: path::connect(p, "bin"),
@@ -408,7 +408,7 @@ fn configure(opts: options) -> cargo {
need_dir(c.bindir);
sources.keys { |k|
- let s = sources.get(k);
+ let mut s = sources.get(k);
load_source_packages(c, s);
sources.insert(k, s);
};
@@ -597,7 +597,7 @@ fn cargo_suggestion(c: cargo, syncing: bool, fallback: fn())
ret;
}
if !syncing {
- let npkg = 0u;
+ let mut npkg = 0u;
c.sources.values({ |v| npkg += vec::len(v.packages) });
if npkg == 0u {
error("No packages known. You may wish to run " +
@@ -609,7 +609,7 @@ fn cargo_suggestion(c: cargo, syncing: bool, fallback: fn())
}
fn install_uuid(c: cargo, wd: str, uuid: str) {
- let ps = [];
+ let mut ps = [];
for_each_package(c, { |s, p|
info(#fmt["%s ? %s", p.uuid, uuid]);
if p.uuid == uuid {
@@ -631,7 +631,7 @@ fn install_uuid(c: cargo, wd: str, uuid: str) {
}
fn install_named(c: cargo, wd: str, name: str) {
- let ps = [];
+ let mut ps = [];
for_each_package(c, { |s, p|
if p.name == name {
vec::grow(ps, 1u, (s, p));
@@ -698,7 +698,7 @@ fn cmd_install(c: cargo) unsafe {
};
if str::starts_with(target, "uuid:") {
- let uuid = rest(target, 5u);
+ let mut uuid = rest(target, 5u);
alt str::find_char(uuid, '/') {
option::some(idx) {
let source = str::slice(uuid, 0u, idx);
@@ -710,7 +710,7 @@ fn cmd_install(c: cargo) unsafe {
}
}
} else {
- let name = target;
+ let mut name = target;
alt str::find_char(name, '/') {
option::some(idx) {
let source = str::slice(name, 0u, idx);
@@ -820,7 +820,7 @@ fn cmd_init(c: cargo) {
}
fn print_pkg(s: source, p: package) {
- let m = s.name + "/" + p.name + " (" + p.uuid + ")";
+ let mut m = s.name + "/" + p.name + " (" + p.uuid + ")";
if vec::len(p.tags) > 0u {
m = m + " [" + str::connect(p.tags, ", ") + "]";
}
@@ -842,7 +842,7 @@ fn cmd_search(c: cargo) {
cmd_usage();
ret;
}
- let n = 0;
+ let mut n = 0;
let name = c.opts.free[2];
let tags = vec::slice(c.opts.free, 3u, vec::len(c.opts.free));
for_each_package(c, { |s, p|
View
4 src/compiletest/compiletest.rs
@@ -126,7 +126,7 @@ fn test_opts(config: config) -> test::test_opts {
fn make_tests(config: config) -> [test::test_desc] {
#debug("making tests from %s", config.src_base);
- let tests = [];
+ let mut tests = [];
for file: str in os::list_dir(config.src_base) {
let file = file;
#debug("inspecting file %s", file);
@@ -144,7 +144,7 @@ fn is_test(config: config, testfile: str) -> bool {
let invalid_prefixes = [".", "#", "~"];
let name = path::basename(testfile);
- let valid = false;
+ let mut valid = false;
for ext in valid_extensions {
if str::ends_with(name, ext) { valid = true; }
View
8 src/compiletest/errors.rs
@@ -9,9 +9,9 @@ type expected_error = { line: uint, kind: str, msg: str };
// Load any test directives embedded in the file
fn load_errors(testfile: str) -> [expected_error] {
- let error_patterns = [];
+ let mut error_patterns = [];
let rdr = result::get(io::file_reader(testfile));
- let line_num = 1u;
+ let mut line_num = 1u;
while !rdr.eof() {
let ln = rdr.read_line();
error_patterns += parse_expected(line_num, ln);
@@ -22,15 +22,15 @@ fn load_errors(testfile: str) -> [expected_error] {
fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
let error_tag = "//!";
- let idx;
+ let mut idx;
alt str::find_str(line, error_tag) {
option::none { ret []; }
option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
}
// "//!^^^ kind msg" denotes a message expected
// three lines above current line:
- let adjust_line = 0u;
+ let mut adjust_line = 0u;
let len = str::len(line);
while idx < len && line[idx] == ('^' as u8) {
adjust_line += 1u;
View
10 src/compiletest/header.rs
@@ -22,10 +22,10 @@ type test_props = {
// Load any test directives embedded in the file
fn load_props(testfile: str) -> test_props {
- let error_patterns = [];
- let aux_builds = [];
- let compile_flags = option::none;
- let pp_exact = option::none;
+ let mut error_patterns = [];
+ let mut aux_builds = [];
+ let mut compile_flags = option::none;
+ let mut pp_exact = option::none;
iter_header(testfile) {|ln|
alt parse_error_pattern(ln) {
option::some(ep) { error_patterns += [ep]; }
@@ -53,7 +53,7 @@ fn load_props(testfile: str) -> test_props {
}
fn is_test_ignored(config: config, testfile: str) -> bool {
- let found = false;
+ let mut found = false;
iter_header(testfile) {|ln|
// FIXME: Can't return or break from iterator
// (Fix when Issue #1619 is resolved)
View
8 src/compiletest/procsrv.rs
@@ -60,9 +60,9 @@ fn run(lib_path: str, prog: str, args: [str],
comm::send(ch, (1, output));
};
let status = run::waitpid(pid);
- let errs = "";
- let outs = "";
- let count = 2;
+ let mut errs = "";
+ let mut outs = "";
+ let mut count = 2;
while count > 0 {
let stream = comm::recv(p);
alt check stream {
@@ -91,7 +91,7 @@ fn readclose(fd: c_int) -> str {
// Copied from run::program_output
let file = os::fdopen(fd);
let reader = io::FILE_reader(file, false);
- let buf = "";
+ let mut buf = "";
while !reader.eof() {
let bytes = reader.read_bytes(4096u);
buf += str::from_bytes(bytes);
View
24 src/compiletest/runtest.rs
@@ -47,7 +47,7 @@ fn run_cfail_test(config: config, props: test_props, testfile: str) {
}
fn run_rfail_test(config: config, props: test_props, testfile: str) {
- let procres = compile_test(config, props, testfile);
+ let mut procres = compile_test(config, props, testfile);
if procres.status != 0 { fatal_procres("compilation failed!", procres); }
@@ -75,7 +75,7 @@ fn check_correct_failure_status(procres: procres) {
}
fn run_rpass_test(config: config, props: test_props, testfile: str) {
- let procres = compile_test(config, props, testfile);
+ let mut procres = compile_test(config, props, testfile);
if procres.status != 0 { fatal_procres("compilation failed!", procres); }
@@ -93,9 +93,9 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) {
let rounds =
alt props.pp_exact { option::some(_) { 1 } option::none { 2 } };
- let srcs = [result::get(io::read_whole_file_str(testfile))];
+ let mut srcs = [result::get(io::read_whole_file_str(testfile))];
- let round = 0;
+ let mut round = 0;
while round < rounds {
logv(config, #fmt["pretty-printing round %d", round]);
let procres = print_source(config, testfile, srcs[round]);
@@ -109,15 +109,15 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) {
round += 1;
}
- let expected =
+ let mut expected =
alt props.pp_exact {
option::some(file) {
let filepath = path::connect(path::dirname(testfile), file);
result::get(io::read_whole_file_str(filepath))
}
option::none { srcs[vec::len(srcs) - 2u] }
};
- let actual = srcs[vec::len(srcs) - 1u];
+ let mut actual = srcs[vec::len(srcs) - 1u];
if option::is_some(props.pp_exact) {
// Now we have to care about line endings
@@ -176,7 +176,7 @@ actual:\n\
fn make_typecheck_args(config: config, _testfile: str) -> procargs {
let prog = config.rustc_path;
- let args = ["-", "--no-trans", "--lib", "-L", config.build_base];
+ let mut args = ["-", "--no-trans", "--lib", "-L", config.build_base];
args += split_maybe_args(config.rustcflags);
ret {prog: prog, args: args};
}
@@ -193,8 +193,8 @@ fn check_error_patterns(props: test_props,
fatal("process did not return an error status");
}
- let next_err_idx = 0u;
- let next_err_pat = props.error_patterns[next_err_idx];
+ let mut next_err_idx = 0u;
+ let mut next_err_pat = props.error_patterns[next_err_idx];
for line: str in str::split_char(procres.stderr, '\n') {
if str::contains(line, next_err_pat) {
#debug("found error pattern %s", next_err_pat);
@@ -244,7 +244,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
// where line1:col1: is the starting point, line2:col2:
// is the ending point, and * represents ANSI color codes.
for line: str in str::split_char(procres.stderr, '\n') {
- let was_expected = false;
+ let mut was_expected = false;
vec::iteri(expected_errors) {|i, ee|
if !found_flags[i] {
#debug["prefix=%s ee.kind=%s ee.msg=%s line=%s",
@@ -321,8 +321,8 @@ fn make_compile_args(config: config, props: test_props, extras: [str],
xform: fn(config, str) -> str, testfile: str) ->
procargs {
let prog = config.rustc_path;
- let args = [testfile, "-o", xform(config, testfile),
- "-L", config.build_base] + extras;
+ let mut args = [testfile, "-o", xform(config, testfile),
+ "-L", config.build_base] + extras;
args += split_maybe_args(config.rustcflags);
args += split_maybe_args(props.compile_flags);
ret {prog: prog, args: args};
View
10 src/fuzzer/fuzzer.rs
@@ -217,7 +217,7 @@ fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::ty, tm: test_mode
}
fn under(n: uint, it: fn(uint)) {
- let i: uint = 0u;
+ let mut i: uint = 0u;
while i < n { it(i); i += 1u; }
}
@@ -487,9 +487,9 @@ fn file_might_not_converge(filename: str) -> bool {
fn check_roundtrip_convergence(code: @str, maxIters: uint) {
- let i = 0u;
- let newv = code;
- let oldv = code;
+ let mut i = 0u;
+ let mut newv = code;
+ let mut oldv = code;
while i < maxIters {
oldv = newv;
@@ -576,7 +576,7 @@ fn main(args: [str]) {
#error("usage: %s <testdir>", args[0]);
ret;
}
- let files = [];
+ let mut files = [];
let root = args[1];
find_rust_files(files, root);
View
4 src/libcore/comm.rs
@@ -332,8 +332,8 @@ fn test_select2_stress() {
};
}
- let as = 0;
- let bs = 0;
+ let mut as = 0;
+ let mut bs = 0;
iter::repeat(msgs * times * 2u) {||
alt check select2(po_a, po_b) {
either::left("a") { as += 1 }
View
2 src/libcore/io.rs
@@ -715,7 +715,7 @@ mod tests {
assert(vec::slice(ivals, 0u, vec::len(res)) ==
vec::map(res, {|x| x as int}));
}
- let i = 0u;
+ let mut i = 0u;
while i < 8u {
check_read_ln(i, wide_test, ivals);
i += 1u;
View
5 src/libcore/iter.rs
@@ -232,7 +232,7 @@ fn test_flat_map_with_option() {
#[test]
fn test_flat_map_with_list() {
fn repeat(&&i: int) -> [int] {
- let r = [];
+ let mut r = [];
int::range(0, i) {|_j| r += [i]; }
r
}
@@ -246,8 +246,7 @@ fn test_flat_map_with_list() {
#[test]
fn test_repeat() {
- let c = [],
- i = 0u;
+ let mut c = [], i = 0u;
repeat(5u) {||
c += [(i * i)];
i += 1u;
View
6 src/libcore/os.rs
@@ -617,8 +617,8 @@ mod tests {
#[test]
#[ignore(reason = "fails periodically on mac")]
fn test_getenv_big() {
- let s = "";
- let i = 0;
+ let mut s = "";
+ let mut i = 0;
while i < 100 { s += "aaaaaaaaaa"; i += 1; }
let n = make_rand_name();
setenv(n, s);
@@ -659,7 +659,7 @@ mod tests {
fn test_env_setenv() {
let n = make_rand_name();
- let e = env();
+ let mut e = env();
setenv(n, "VALUE");
assert !vec::contains(e, (n, "VALUE"));
View
2 src/libcore/run.rs
@@ -366,7 +366,7 @@ mod tests {
// Copied from run::program_output
let file = os::fdopen(fd);
let reader = io::FILE_reader(file, false);
- let buf = "";
+ let mut buf = "";
while !reader.eof() {
let bytes = reader.read_bytes(4096u);
buf += str::from_bytes(bytes);
View
42 src/libcore/str.rs
@@ -1675,15 +1675,15 @@ mod tests {
#[test]
fn test_pop_char() {
- let data = "ประเทศไทย中华";
+ let mut data = "ประเทศไทย中华";
let cc = pop_char(data);
assert "ประเทศไทย中" == data;
assert '华' == cc;
}
#[test]
fn test_pop_char_2() {
- let data2 = "华";
+ let mut data2 = "华";
let cc2 = pop_char(data2);
assert "" == data2;
assert '华' == cc2;
@@ -1693,7 +1693,7 @@ mod tests {
#[should_fail]
#[ignore(cfg(target_os = "win32"))]
fn test_pop_char_fail() {
- let data = "";
+ let mut data = "";
let _cc3 = pop_char(data);
}
@@ -1887,7 +1887,7 @@ mod tests {
assert find_str_between(data, "ab", 2u, 6u) == some(3u);
assert find_str_between(data, "ab", 2u, 4u) == none;
- let data = "ประเทศไทย中华Việt Nam";
+ let mut data = "ประเทศไทย中华Việt Nam";
data += data;
assert find_str_between(data, "", 0u, 43u) == some(0u);
assert find_str_between(data, "", 6u, 43u) == some(6u);
@@ -1959,14 +1959,14 @@ mod tests {
assert (eq("bc", unsafe::slice_bytes("abc", 1u, 3u)));
assert (eq("", unsafe::slice_bytes("abc", 1u, 1u)));
fn a_million_letter_a() -> str {
- let i = 0;
- let rs = "";
+ let mut i = 0;
+ let mut rs = "";
while i < 100000 { rs += "aaaaaaaaaa"; i += 1; }
ret rs;
}
fn half_a_million_letter_a() -> str {
- let i = 0;
- let rs = "";
+ let mut i = 0;
+ let mut rs = "";
while i < 100000 { rs += "aaaaa"; i += 1; }
ret rs;
}
@@ -2068,14 +2068,14 @@ mod tests {
assert "华" == slice(data, 30u, 33u);
fn a_million_letter_X() -> str {
- let i = 0;
- let rs = "";
+ let mut i = 0;
+ let mut rs = "";
while i < 100000 { rs += "华华华华华华华华华华"; i += 1; }
ret rs;
}
fn half_a_million_letter_X() -> str {
- let i = 0;
- let rs = "";
+ let mut i = 0;
+ let mut rs = "";
while i < 100000 { rs += "华华华华华"; i += 1; }
ret rs;
}
@@ -2164,15 +2164,15 @@ mod tests {
#[test]
fn test_shift_byte() unsafe {
- let s = "ABC";
+ let mut s = "ABC";
let b = unsafe::shift_byte(s);
assert (s == "BC");
assert (b == 65u8);
}
#[test]
fn test_pop_byte() unsafe {
- let s = "ABC";
+ let mut s = "ABC";
let b = unsafe::pop_byte(s);
assert (s == "AB");
assert (b == 67u8);
@@ -2264,7 +2264,7 @@ mod tests {
let v: [u8] = bytes(s1);
let s2: str = from_bytes(v);
- let i: uint = 0u;
+ let mut i: uint = 0u;
let n1: uint = len(s1);
let n2: uint = vec::len::<u8>(v);
assert (n1 == n2);
@@ -2297,7 +2297,7 @@ mod tests {
#[test]
fn test_chars_iter() {
- let i = 0;
+ let mut i = 0;
chars_iter("x\u03c0y") {|ch|
alt check i {
0 { assert ch == 'x'; }
@@ -2312,7 +2312,7 @@ mod tests {
#[test]
fn test_bytes_iter() {
- let i = 0;
+ let mut i = 0;
bytes_iter("xyz") {|bb|
alt check i {
@@ -2330,7 +2330,7 @@ mod tests {
fn test_split_char_iter() {
let data = "\nMary had a little lamb\nLittle lamb\n";
- let ii = 0;
+ let mut ii = 0;
split_char_iter(data, ' ') {|xx|
alt ii {
@@ -2348,7 +2348,7 @@ mod tests {
fn test_splitn_char_iter() {
let data = "\nMary had a little lamb\nLittle lamb\n";
- let ii = 0;
+ let mut ii = 0;
splitn_char_iter(data, ' ', 2u) {|xx|
alt ii {
@@ -2365,7 +2365,7 @@ mod tests {
fn test_words_iter() {
let data = "\nMary had a little lamb\nLittle lamb\n";
- let ii = 0;
+ let mut ii = 0;
words_iter(data) {|ww|
alt ii {
@@ -2385,7 +2385,7 @@ mod tests {
fn test_lines_iter () {
let lf = "\nMary had a little lamb\nLittle lamb\n";
- let ii = 0;
+ let mut ii = 0;
lines_iter(lf) {|x|
alt ii {
View
2 src/libcore/task.rs
@@ -790,7 +790,7 @@ fn test_spawn_sched_blocking() {
comm::recv(start_po);
fn pingpong(po: comm::port<int>, ch: comm::chan<int>) {
- let val = 20;
+ let mut val = 20;
while val > 0 {
val = comm::recv(po);
comm::send(ch, val - 1);
View
72 src/libcore/vec.rs
@@ -1017,7 +1017,7 @@ mod tests {
fn test_unsafe_ptrs() unsafe {
// Test on-stack copy-from-buf.
let a = [1, 2, 3];
- let ptr = unsafe::to_ptr(a);
+ let mut ptr = unsafe::to_ptr(a);
let b = unsafe::from_buf(ptr, 3u);
assert (len(b) == 3u);
assert (b[0] == 1);
@@ -1039,7 +1039,7 @@ mod tests {
#[test]
fn test_from_fn() {
// Test on-stack from_fn.
- let v = from_fn(3u, square);
+ let mut v = from_fn(3u, square);
assert (len(v) == 3u);
assert (v[0] == 0u);
assert (v[1] == 1u);
@@ -1058,7 +1058,7 @@ mod tests {
#[test]
fn test_from_elem() {
// Test on-stack from_elem.
- let v = from_elem(2u, 10u);
+ let mut v = from_elem(2u, 10u);
assert (len(v) == 2u);
assert (v[0] == 10u);
assert (v[1] == 10u);
@@ -1093,7 +1093,7 @@ mod tests {
#[test]
fn test_tail() {
- let a = [11];
+ let mut a = [11];
assert (tail(a) == []);
a = [11, 12];
@@ -1102,7 +1102,7 @@ mod tests {
#[test]
fn test_last() {
- let n = last_opt([]);
+ let mut n = last_opt([]);
assert (n == none);
n = last_opt([1, 2, 3]);
assert (n == some(3));
@@ -1113,7 +1113,7 @@ mod tests {
#[test]
fn test_slice() {
// Test on-stack -> on-stack slice.
- let v = slice([1, 2, 3], 1u, 3u);
+ let mut v = slice([1, 2, 3], 1u, 3u);
assert (len(v) == 2u);
assert (v[0] == 2);
assert (v[1] == 3);
@@ -1138,8 +1138,8 @@ mod tests {
#[test]
fn test_pop() {
// Test on-stack pop.
- let v = [1, 2, 3];
- let e = pop(v);
+ let mut v = [1, 2, 3];
+ let mut e = pop(v);
assert (len(v) == 2u);
assert (v[0] == 1);
assert (v[1] == 2);
@@ -1159,7 +1159,7 @@ mod tests {
#[test]
fn test_push() {
// Test on-stack push().
- let v = [];
+ let mut v = [];
push(v, 1);
assert (len(v) == 1u);
assert (v[0] == 1);
@@ -1174,7 +1174,7 @@ mod tests {
#[test]
fn test_grow() {
// Test on-stack grow().
- let v = [];
+ let mut v = [];
grow(v, 2u, 1);
assert (len(v) == 2u);
assert (v[0] == 1);
@@ -1192,7 +1192,7 @@ mod tests {
#[test]
fn test_grow_fn() {
- let v = [];
+ let mut v = [];
grow_fn(v, 3u, square);
assert (len(v) == 3u);
assert (v[0] == 0u);
@@ -1202,7 +1202,7 @@ mod tests {
#[test]
fn test_grow_set() {
- let v = [mutable 1, 2, 3];
+ let mut v = [mutable 1, 2, 3];
grow_set(v, 4u, 4, 5);
assert (len(v) == 5u);
assert (v[0] == 1);
@@ -1215,8 +1215,8 @@ mod tests {
#[test]
fn test_map() {
// Test on-stack map.
- let v = [1u, 2u, 3u];
- let w = map(v, square_ref);
+ let mut v = [1u, 2u, 3u];
+ let mut w = map(v, square_ref);
assert (len(w) == 3u);
assert (w[0] == 1u);
assert (w[1] == 4u);
@@ -1240,15 +1240,15 @@ mod tests {
let v0 = [1, 2, 3, 4, 5];
let v1 = [5, 4, 3, 2, 1];
let u = map2::<int, int, int>(v0, v1, f);
- let i = 0;
+ let mut i = 0;
while i < 5 { assert (v0[i] * v1[i] == u[i]); i += 1; }
}
#[test]
fn test_filter_map() {
// Test on-stack filter-map.
- let v = [1u, 2u, 3u];
- let w = filter_map(v, square_if_odd);
+ let mut v = [1u, 2u, 3u];
+ let mut w = filter_map(v, square_if_odd);
assert (len(w) == 2u);
assert (w[0] == 1u);
assert (w[1] == 9u);
@@ -1287,8 +1287,8 @@ mod tests {
#[test]
fn test_foldl() {
// Test on-stack fold.
- let v = [1u, 2u, 3u];
- let sum = foldl(0u, v, add);
+ let mut v = [1u, 2u, 3u];
+ let mut sum = foldl(0u, v, add);
assert (sum == 6u);
// Test on-heap fold.
@@ -1302,7 +1302,7 @@ mod tests {
fn sub(&&a: int, &&b: int) -> int {
a - b
}
- let v = [1, 2, 3, 4];
+ let mut v = [1, 2, 3, 4];
let sum = foldl(0, v, sub);
assert sum == -10;
}
@@ -1312,28 +1312,28 @@ mod tests {
fn sub(&&a: int, &&b: int) -> int {
a - b
}
- let v = [1, 2, 3, 4];
+ let mut v = [1, 2, 3, 4];
let sum = foldr(v, 0, sub);
assert sum == -2;
}
#[test]
fn test_iter_empty() {
- let i = 0;
+ let mut i = 0;
iter::<int>([], { |_v| i += 1 });
assert i == 0;
}
#[test]
fn test_iter_nonempty() {
- let i = 0;
+ let mut i = 0;
iter([1, 2, 3], { |v| i += v });
assert i == 6;
}
#[test]
fn test_iteri() {
- let i = 0;
+ let mut i = 0;
iteri([1, 2, 3], { |j, v|
if i == 0 { assert v == 1; }
assert j + 1u == v as uint;
@@ -1344,14 +1344,14 @@ mod tests {
#[test]
fn test_riter_empty() {
- let i = 0;
+ let mut i = 0;
riter::<int>([], { |_v| i += 1 });
assert i == 0;
}
#[test]
fn test_riter_nonempty() {
- let i = 0;
+ let mut i = 0;
riter([1, 2, 3], { |v|
if i == 0 { assert v == 3; }
i += v
@@ -1361,7 +1361,7 @@ mod tests {
#[test]
fn test_riteri() {
- let i = 0;
+ let mut i = 0;
riteri([0, 1, 2], { |j, v|
if i == 0 { assert v == 2; }
assert j == v as uint;
@@ -1372,7 +1372,7 @@ mod tests {
#[test]
fn test_permute() {
- let results: [[int]];
+ let mut results: [[int]];
results = [];
permute([]) {|v| results += [v]; }
@@ -1464,7 +1464,7 @@ mod tests {
assert position_between([], 0u, 0u, f) == none;
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert position_between(v, 0u, 0u, f) == none;
assert position_between(v, 0u, 1u, f) == none;
@@ -1493,7 +1493,7 @@ mod tests {
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
fn g(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'd' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert find(v, f) == some((1, 'b'));
assert find(v, g) == none;
@@ -1504,7 +1504,7 @@ mod tests {
assert find_between([], 0u, 0u, f) == none;
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert find_between(v, 0u, 0u, f) == none;
assert find_between(v, 0u, 1u, f) == none;
@@ -1533,7 +1533,7 @@ mod tests {
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
fn g(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'd' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert position(v, f) == some(1u);
assert position(v, g) == none;
@@ -1544,7 +1544,7 @@ mod tests {
assert rposition_between([], 0u, 0u, f) == none;
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert rposition_between(v, 0u, 0u, f) == none;
assert rposition_between(v, 0u, 1u, f) == none;
@@ -1573,7 +1573,7 @@ mod tests {
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
fn g(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'd' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert rfind(v, f) == some((3, 'b'));
assert rfind(v, g) == none;
@@ -1584,7 +1584,7 @@ mod tests {
assert rfind_between([], 0u, 0u, f) == none;
fn f(xy: (int, char)) -> bool { let (_x, y) = xy; y == 'b' }
- let v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
+ let mut v = [(0, 'a'), (1, 'b'), (2, 'c'), (3, 'b')];
assert rfind_between(v, 0u, 0u, f) == none;
assert rfind_between(v, 0u, 1u, f) == none;
@@ -1740,7 +1740,7 @@ mod tests {
#[test]
fn test_unshift() {
- let x = [1, 2, 3];
+ let mut x = [1, 2, 3];
unshift(x, 0);
assert x == [0, 1, 2, 3];
}
View
14 src/libstd/bitv.rs
@@ -234,16 +234,16 @@ fn eq_vec(v0: bitv, v1: [uint]) -> bool {
mod tests {
#[test]
fn test_0_elements() {
- let act;
- let exp;
+ let mut act;
+ let mut exp;
act = bitv(0u, false);
exp = vec::from_elem::<uint>(0u, 0u);
assert (eq_vec(act, exp));
}
#[test]
fn test_1_element() {
- let act;
+ let mut act;
act = bitv(1u, false);
assert (eq_vec(act, [0u]));
act = bitv(1u, true);
@@ -252,7 +252,7 @@ mod tests {
#[test]
fn test_10_elements() {
- let act;
+ let mut act;
// all 0
act = bitv(10u, false);
@@ -291,7 +291,7 @@ mod tests {
#[test]
fn test_31_elements() {
- let act;
+ let mut act;
// all 0
act = bitv(31u, false);
@@ -364,7 +364,7 @@ mod tests {
#[test]
fn test_32_elements() {
- let act;
+ let mut act;
// all 0
act = bitv(32u, false);
@@ -439,7 +439,7 @@ mod tests {
#[test]
fn test_33_elements() {
- let act;
+ let mut act;
// all 0
act = bitv(33u, false);
View
2 src/libstd/deque.rs
@@ -126,7 +126,7 @@ mod tests {
assert (d.peek_front() == 42);
log(debug, d.peek_back());
assert (d.peek_back() == 137);
- let i: int = d.pop_front();
+ let mut i: int = d.pop_front();
log(debug, i);
assert (i == 42);
i = d.pop_back();
View
4 src/libstd/map.rs
@@ -453,7 +453,7 @@ mod tests {
let eqer_uint: map::eqfn<uint> = eq_uint;
let hm_uu: map::hashmap<uint, uint> =
map::hashmap::<uint, uint>(hasher_uint, eqer_uint);
- let i: uint = 0u;
+ let mut i: uint = 0u;
while i < num_to_insert {
assert (hm_uu.insert(i, i * i));
#debug("inserting %u -> %u", i, i*i);
@@ -533,7 +533,7 @@ mod tests {
let eqer: map::eqfn<uint> = eq;
let hm: map::hashmap<uint, uint> =
map::hashmap::<uint, uint>(hasher, eqer);
- let i: uint = 0u;
+ let mut i: uint = 0u;
while i < num_to_insert {
assert (hm.insert(i, i * i));
#debug("inserting %u -> %u", i, i*i);
View
24 src/libstd/rope.rs
@@ -1281,18 +1281,18 @@ mod tests {
#[test]
fn of_string2() {
let buf = @ mutable "1234567890";
- let i = 0;
+ let mut i = 0;
while i < 10 { *buf = *buf + *buf; i+=1;}
let sample = @*buf;
let r = of_str(sample);
assert char_len(r) == str::char_len(*sample);
assert rope_to_string(r) == *sample;
- let string_iter = 0u;
+ let mut string_iter = 0u;
let string_len = str::len(*sample);
let rope_iter = iterator::char::start(r);
- let equal = true;
- let pos = 0u;
+ let mut equal = true;
+ let mut pos = 0u;
while equal {
alt(node::char_iterator::next(rope_iter)) {
option::none {
@@ -1314,12 +1314,12 @@ mod tests {
#[test]
fn iter1() {
let buf = @ mutable "1234567890";
- let i = 0;
+ let mut i = 0;
while i < 10 { *buf = *buf + *buf; i+=1;}
let sample = @*buf;
let r = of_str(sample);
- let len = 0u;
+ let mut len = 0u;
let it = iterator::char::start(r);
loop {
alt(node::char_iterator::next(it)) {
@@ -1335,11 +1335,11 @@ mod tests {
fn bal1() {
let init = @ "1234567890";
let buf = @ mutable * init;
- let i = 0;
+ let mut i = 0;
while i < 8 { *buf = *buf + *buf; i+=1;}
let sample = @*buf;
let r1 = of_str(sample);
- let r2 = of_str(init);
+ let mut r2 = of_str(init);
i = 0;
while i < 8 { r2 = append_rope(r2, r2); i+= 1;}
@@ -1354,19 +1354,19 @@ mod tests {
#[test]
fn char_at1() {
//Generate a large rope
- let r = of_str(@ "123456789");
+ let mut r = of_str(@ "123456789");
uint::range(0u, 10u){|_i|
r = append_rope(r, r);
}
//Copy it in the slowest possible way
- let r2 = empty();
+ let mut r2 = empty();
uint::range(0u, char_len(r)){|i|
r2 = append_char(r2, char_at(r, i));
}
assert eq(r, r2);
- let r3 = empty();
+ let mut r3 = empty();
uint::range(0u, char_len(r)){|i|
r3 = prepend_char(r3, char_at(r, char_len(r) - i - 1u));
}
@@ -1387,7 +1387,7 @@ mod tests {
fn concat1() {
//Generate a reasonable rope
let chunk = of_str(@ "123456789");
- let r = empty();
+ let mut r = empty();
uint::range(0u, 10u){|_i|
r = append_rope(r, chunk);
}
View
8 src/libstd/sha1.rs
@@ -264,8 +264,8 @@ mod tests {
type test = {input: str, output: [u8]};
fn a_million_letter_a() -> str {
- let i = 0;
- let rs = "";
+ let mut i = 0;
+ let mut rs = "";
while i < 100000 { rs += "aaaaaaaaaa"; i += 1; }
ret rs;
}
@@ -316,7 +316,7 @@ mod tests {
fn check_vec_eq(v0: [u8], v1: [u8]) {
assert (vec::len::<u8>(v0) == vec::len::<u8>(v1));
let len = vec::len::<u8>(v0);
- let i = 0u;
+ let mut i = 0u;
while i < len {
let a = v0[i];
let b = v1[i];
@@ -338,7 +338,7 @@ mod tests {
// Test that it works when accepting the message in pieces
for t: test in tests {
let len = str::len(t.input);
- let left = len;
+ let mut left = len;
while left > 0u {
let take = (left + 1u) / 2u;
sh.input_str(str::slice(t.input, len - left,
View
6 src/libstd/sort.rs
@@ -167,7 +167,7 @@ mod test_qsort3 {
let f1 = lt;
let f2 = equal;
quick_sort3::<int>(f1, f2, v1);
- let i = 0u;
+ let mut i = 0u;
while i < len {
log(debug, v2[i]);
assert (v2[i] == v1[i]);
@@ -208,7 +208,7 @@ mod test_qsort {
fn leual(&&a: int, &&b: int) -> bool { ret a <= b; }
let f = leual;
quick_sort::<int>(f, v1);
- let i = 0u;
+ let mut i = 0u;
while i < len {
log(debug, v2[i]);
assert (v2[i] == v1[i]);