]> git.lizzy.rs Git - rust.git/commitdiff
make --enforce-mut-vars always on, add mut annotations to remaining files
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 22 Mar 2012 15:39:41 +0000 (08:39 -0700)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 22 Mar 2012 16:58:19 +0000 (09:58 -0700)
179 files changed:
doc/rust.md
doc/tutorial.md
mk/target.mk
src/cargo/cargo.rs
src/compiletest/compiletest.rs
src/compiletest/errors.rs
src/compiletest/header.rs
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/fuzzer/fuzzer.rs
src/libcore/comm.rs
src/libcore/io.rs
src/libcore/iter.rs
src/libcore/os.rs
src/libcore/run.rs
src/libcore/str.rs
src/libcore/task.rs
src/libcore/vec.rs
src/libstd/bitv.rs
src/libstd/deque.rs
src/libstd/map.rs
src/libstd/rope.rs
src/libstd/sha1.rs
src/libstd/sort.rs
src/libstd/test.rs
src/rustc/driver/driver.rs
src/rustc/driver/session.rs
src/rustc/middle/mutbl.rs
src/rustc/syntax/print/pprust.rs
src/rustdoc/astsrv.rs
src/rustdoc/desc_to_brief_pass.rs
src/rustdoc/markdown_writer.rs
src/rustdoc/reexport_pass.rs
src/rustdoc/rustdoc.rs
src/rustdoc/sectionalize_pass.rs
src/rustdoc/unindent_pass.rs
src/test/auxiliary/cci_impl_lib.rs
src/test/auxiliary/cci_iter_lib.rs
src/test/auxiliary/cci_no_inline_lib.rs
src/test/bench/99bob-iter.rs
src/test/bench/99bob-pattern.rs
src/test/bench/99bob-simple.rs
src/test/bench/msgsend.rs
src/test/bench/shootout-binarytrees.rs
src/test/bench/shootout-fannkuchredux.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-mandelbrot.rs
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-spectralnorm.rs
src/test/bench/sudoku.rs
src/test/bench/task-perf-one-million.rs
src/test/bench/task-perf-spawnalot.rs
src/test/bench/task-perf-vector-party.rs
src/test/bench/task-perf-word-count.rs
src/test/run-fail/explicit-fail-msg.rs
src/test/run-fail/unwind-misc-1.rs
src/test/run-pass/alt-join.rs
src/test/run-pass/alt-phi.rs
src/test/run-pass/alt-tag.rs
src/test/run-pass/argument-passing.rs
src/test/run-pass/assign-assign.rs
src/test/run-pass/auto-loop.rs
src/test/run-pass/basic-1.rs
src/test/run-pass/basic-2.rs
src/test/run-pass/basic.rs
src/test/run-pass/bitwise.rs
src/test/run-pass/block-arg.rs
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-2.rs
src/test/run-pass/break.rs
src/test/run-pass/chan-leak.rs
src/test/run-pass/complex.rs
src/test/run-pass/constraint-prop-expr-move.rs
src/test/run-pass/constraint-prop-swap.rs
src/test/run-pass/expr-alt.rs
src/test/run-pass/expr-block.rs
src/test/run-pass/fn-bare-assign.rs
src/test/run-pass/foreach-nested.rs
src/test/run-pass/foreach-put-structured.rs
src/test/run-pass/foreach-simple-outer-slot.rs
src/test/run-pass/generic-fn.rs
src/test/run-pass/generic-tag-alt.rs
src/test/run-pass/generic-tag.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/i32-sub.rs
src/test/run-pass/i8-incr.rs
src/test/run-pass/iface-generic.rs
src/test/run-pass/import-glob-crate.rs
src/test/run-pass/interior-vec.rs
src/test/run-pass/issue-1257.rs
src/test/run-pass/issue-783.rs
src/test/run-pass/istr.rs
src/test/run-pass/iter-range.rs
src/test/run-pass/ivec-add.rs
src/test/run-pass/last-use-corner-cases.rs
src/test/run-pass/lazy-and-or.rs
src/test/run-pass/lazy-init.rs
src/test/run-pass/lazychan.rs
src/test/run-pass/leak-tag-copy.rs
src/test/run-pass/let-destruct-fresh-mem.rs
src/test/run-pass/linear-for-loop.rs
src/test/run-pass/long-while.rs
src/test/run-pass/loop-break-cont.rs
src/test/run-pass/loop-scope.rs
src/test/run-pass/maybe-mutable.rs
src/test/run-pass/monad.rs
src/test/run-pass/morestack5.rs
src/test/run-pass/move-1-unique.rs
src/test/run-pass/move-1.rs
src/test/run-pass/move-3-unique.rs
src/test/run-pass/move-3.rs
src/test/run-pass/move-scalar.rs
src/test/run-pass/mutable-alias-vec.rs
src/test/run-pass/nested-alts.rs
src/test/run-pass/opeq.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/output-slot-variants.rs
src/test/run-pass/over-constrained-vregs.rs
src/test/run-pass/paren-free.rs
src/test/run-pass/regions-self-in-enums.rs
src/test/run-pass/shadow.rs
src/test/run-pass/simple-infer.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/static-impl.rs
src/test/run-pass/str-append.rs
src/test/run-pass/str-growth.rs
src/test/run-pass/string-self-append.rs
src/test/run-pass/swap-1.rs
src/test/run-pass/swap-2.rs
src/test/run-pass/task-comm-0.rs
src/test/run-pass/task-comm-10.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-15.rs
src/test/run-pass/task-comm-16.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-4.rs
src/test/run-pass/task-comm-5.rs
src/test/run-pass/task-comm-6.rs
src/test/run-pass/task-comm-7.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/task-comm.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/threads.rs
src/test/run-pass/type-params-in-for-each.rs
src/test/run-pass/typestate-cfg-nesting.rs
src/test/run-pass/u32-decr.rs
src/test/run-pass/u8-incr-decr.rs
src/test/run-pass/u8-incr.rs
src/test/run-pass/unique-assign-copy.rs
src/test/run-pass/unique-assign-drop.rs
src/test/run-pass/unique-assign.rs
src/test/run-pass/unique-fn-arg-mut.rs
src/test/run-pass/unique-move-temp.rs
src/test/run-pass/unique-move.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unique-swap.rs
src/test/run-pass/unit.rs
src/test/run-pass/unreachable-code.rs
src/test/run-pass/use-uninit-alt.rs
src/test/run-pass/use-uninit-alt2.rs
src/test/run-pass/utf8.rs
src/test/run-pass/utf8_chars.rs
src/test/run-pass/vec-growth.rs
src/test/run-pass/vec-ivec-deadlock.rs
src/test/run-pass/vec-late-init.rs
src/test/run-pass/vec-push.rs
src/test/run-pass/vec-self-append.rs
src/test/run-pass/vec.rs
src/test/run-pass/weird-exprs.rs
src/test/run-pass/while-and-do-while.rs
src/test/run-pass/while-cont.rs
src/test/run-pass/while-loop-constraints-2.rs
src/test/run-pass/while-prelude-drop.rs
src/test/run-pass/while-with-break.rs
src/test/run-pass/writealias.rs
src/test/run-pass/yield2.rs

index 26d4db3adeb729fa249a074a1275fe992ca40d9a..74cb13446209722251e6af21aa80010e78bb72a8 100644 (file)
@@ -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
index 3f02d3cd116bf7c91240c886a64d8364b9db0f11..c803216f0b5839137dac671b5680c12dfd49cb76 100644 (file)
@@ -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,7 +1500,7 @@ 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]);
@@ -1505,7 +1508,7 @@ fn for_rev<T>(v: [T], act: fn(T)) {
 }
 
 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));
index fbdf42bc0849bacb24ed079356f6174d1b89beeb..7b3dcab0abd44083310f890296335996434b7973 100644 (file)
 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
 
index e7315633cf2c45ccc422a7ddefeb761a031c2651..d7b1c0df949ff83574664ba59f18769c287959ee 100644 (file)
@@ -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|
index 5b77a737089d8d9b29cde6b742fe92b73e114f9d..ed159d6a073b03e2a079b798c37f4ab7af015bef 100644 (file)
@@ -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; }
index f8487ad44cf4996ae239a44fafe0f7af88eda387..1e04eb521094b6b8b02513bc578fb1f95c8e941a 100644 (file)
@@ -9,9 +9,9 @@
 
 // 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,7 +22,7 @@ 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); }
@@ -30,7 +30,7 @@ fn parse_expected(line_num: uint, line: str) -> [expected_error] unsafe {
 
     // "//!^^^ 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;
index 5a2050bf1dab639ebc12219015d0dec7b490abf9..04abf75894edb9a252692adb6ecc86c6a0e63cc9 100644 (file)
 
 // 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)
index f382839d4a6614c85fa862e6a597499cb52066e2..d9a27b405de613fa01232bda8fa278b727e728c0 100644 (file)
@@ -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);
index 798efac887f08fa9d025a01eb89295e56127e8ca..c81f48a811fc0f3777d063d323c8e6a8bdad35d0 100644 (file)
@@ -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,7 +109,7 @@ 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);
@@ -117,7 +117,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: str) {
           }
           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 @@ fn typecheck_source(config: config, testfile: str, src: str) -> procres {
 
     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};
index 9e4a1f3ad29b3e817d5c38f9b57ed726340f17aa..f3ea25ef2d5f7cfea30e8965087cfc37b8070d6c 100644 (file)
@@ -217,7 +217,7 @@ fn fold_ty_rep(j_: @mutable uint, i_: uint, newty_: ast::ty_,
 }
 
 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);
index a4d1d2647eff1ee8adb7e803d511d849c0330617..02e6c232de761fb0a6b76ecb6e638622178e5d61 100644 (file)
@@ -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 }
index a00f384dcb0d60be39c069cfb717d58b9452455a..292ef86641d03d2b655e304e100fd79bd9c2e657 100644 (file)
@@ -715,7 +715,7 @@ fn check_read_ln(len : uint, s: str, ivals: [int]) {
             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;
index 1124bd1af664e48029544e4d75c83d4353fae003..141f7db2cb7670924ae055659039132f07a5b3c1 100644 (file)
@@ -232,7 +232,7 @@ fn if_even(&&i: int) -> option<int> {
 #[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 repeat(&&i: int) -> [int] {
 
 #[test]
 fn test_repeat() {
-    let c = [],
-        i = 0u;
+    let mut c = [], i = 0u;
     repeat(5u) {||
         c += [(i * i)];
         i += 1u;
index 2841202d6b7defb5e19170d86e8f9b7c8d010dee..b9e290a9bb94bf18e288999ff46516d8a19b38bc 100644 (file)
@@ -617,8 +617,8 @@ fn test_setenv_overwrite() {
     #[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 @@ fn test_env_getenv() {
     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"));
 
index d2af1eca3a2bf8bddcb60c3eabc115137765de29..912b4419f519b90dd3a5628c8fe3d4196a682bbc 100644 (file)
@@ -366,7 +366,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);
index ad3ed1f3cfc7b874214d3e0b9cb5bf08846d9388..95dc2e130339c1f31dad33e1490d36c71dce1a21 100644 (file)
@@ -1675,7 +1675,7 @@ fn test_rfind_char() {
 
     #[test]
     fn test_pop_char() {
-        let data = "ประเทศไทย中华";
+        let mut data = "ประเทศไทย中华";
         let cc = pop_char(data);
         assert "ประเทศไทย中" == data;
         assert '华' == cc;
@@ -1683,7 +1683,7 @@ fn test_pop_char() {
 
     #[test]
     fn test_pop_char_2() {
-        let data2 = "华";
+        let mut data2 = "华";
         let cc2 = pop_char(data2);
         assert "" == data2;
         assert '华' == cc2;
@@ -1693,7 +1693,7 @@ fn test_pop_char_2() {
     #[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 @@ fn test_find_str_between() {
         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 @@ fn test_unsafe_slice() unsafe {
         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 @@ fn test_slice() {
         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,7 +2164,7 @@ fn test_is_ascii() {
 
     #[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);
@@ -2172,7 +2172,7 @@ fn test_shift_byte() unsafe {
 
     #[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 @@ fn vec_str_conversions() {
 
         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 @@ fn test_contains() {
 
     #[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 @@ fn test_chars_iter() {
 
     #[test]
     fn test_bytes_iter() {
-        let i = 0;
+        let mut i = 0;
 
         bytes_iter("xyz") {|bb|
             alt check i {
@@ -2330,7 +2330,7 @@ fn test_bytes_iter() {
     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 @@ fn test_split_char_iter() {
     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 @@ fn test_splitn_char_iter() {
     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 @@ fn test_words_iter() {
     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 {
index b7b26c5c4e1f5e021292e5413992cd56cd3f2821..369c5b16349ff8a7489a5a29f3ffda8f7d443a42 100644 (file)
@@ -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);
index 8fcc4b6b821e8dfc84b766833bc8cc50223201e8..71c4bbfe6ea6b611993d10f2433820f9fe9ea558 100644 (file)
@@ -1017,7 +1017,7 @@ fn square_if_odd(&&n: uint) -> option<uint> {
     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 @@ fn test_unsafe_ptrs() unsafe {
     #[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 @@ fn test_from_fn() {
     #[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 @@ fn test_head() {
 
     #[test]
     fn test_tail() {
-        let a = [11];
+        let mut a = [11];
         assert (tail(a) == []);
 
         a = [11, 12];
@@ -1102,7 +1102,7 @@ fn test_tail() {
 
     #[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 @@ fn test_last() {
     #[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 @@ fn test_slice() {
     #[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 @@ fn test_pop() {
     #[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 @@ fn test_push() {
     #[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 @@ fn test_grow() {
 
     #[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 @@ fn test_grow_fn() {
 
     #[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 @@ fn test_grow_set() {
     #[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 @@ fn test_map2() {
         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 @@ fn test_filter() {
     #[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 @@ fn test_foldl2() {
         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 @@ fn test_foldr() {
         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 @@ fn test_iteri() {
 
     #[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 @@ fn test_riter_nonempty() {
 
     #[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 @@ fn test_riteri() {
 
     #[test]
     fn test_permute() {
-        let results: [[int]];
+        let mut results: [[int]];
 
         results = [];
         permute([]) {|v| results += [v]; }
@@ -1464,7 +1464,7 @@ fn test_position_between() {
         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 @@ fn test_find() {
 
         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 @@ fn test_find_between() {
         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 @@ fn test_rposition() {
 
         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 @@ fn test_rposition_between() {
         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 @@ fn test_rfind() {
 
         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 @@ fn test_rfind_between() {
         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 @@ fn from_mut_no_copy() unsafe {
 
     #[test]
     fn test_unshift() {
-        let x = [1, 2, 3];
+        let mut x = [1, 2, 3];
         unshift(x, 0);
         assert x == [0, 1, 2, 3];
     }
index 4b79bf6c050d8966ac0aae5cb61642edf5b5bc28..371f45cb7a986296138d407ee26e17e4d285bc79 100644 (file)
@@ -234,8 +234,8 @@ 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));
@@ -243,7 +243,7 @@ fn test_0_elements() {
 
     #[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 @@ fn test_1_element() {
 
     #[test]
     fn test_10_elements() {
-        let act;
+        let mut act;
         // all 0
 
         act = bitv(10u, false);
@@ -291,7 +291,7 @@ fn test_10_elements() {
 
     #[test]
     fn test_31_elements() {
-        let act;
+        let mut act;
         // all 0
 
         act = bitv(31u, false);
@@ -364,7 +364,7 @@ fn test_31_elements() {
 
     #[test]
     fn test_32_elements() {
-        let act;
+        let mut act;
         // all 0
 
         act = bitv(32u, false);
@@ -439,7 +439,7 @@ fn test_32_elements() {
 
     #[test]
     fn test_33_elements() {
-        let act;
+        let mut act;
         // all 0
 
         act = bitv(33u, false);
index dc5b2a66edbe7417ec09bad55830e83bde93e21c..749cefc5ba6c873a3ad6fe23402021cc9600446c 100644 (file)
@@ -126,7 +126,7 @@ fn test_simple() {
         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();
index 29d3579afa30acfe5728a4256d6ddb71a6f7f2a6..9ca7f346bda38fd6ea7b570813904d5f6bd09692 100644 (file)
@@ -453,7 +453,7 @@ fn uint_id(&&x: uint) -> uint { x }
         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 @@ fn hash(&&u: uint) -> uint {
         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);
index 982bfe36b0384d5aa319b49aa105cb268623e48f..e4438b77a00e32573a587ca2873d86f71e3bda76 100644 (file)
@@ -1281,18 +1281,18 @@ fn of_string1() {
     #[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 @@ fn of_string2() {
     #[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 @@ fn iter1() {
     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 @@ fn bal1() {
     #[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 @@ fn char_at1() {
     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);
         }
index d7deb7a3d0691f4e4373a6cf972330cacabd8b5b..4d5aabf705db6c62184e3248994c763966f0e7d0 100644 (file)
@@ -264,8 +264,8 @@ fn test() unsafe {
         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 @@ fn a_million_letter_a() -> str {
         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 @@ fn check_vec_eq(v0: [u8], v1: [u8]) {
         // 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,
index ce3982fb433c99dbb9d7f9a2451471b83a68e023..461dd1bab3aa41fc25e253906a9cef4b94aff75f 100644 (file)
@@ -167,7 +167,7 @@ fn check_sort(v1: [mutable int], v2: [mutable int]) {
         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 @@ fn check_sort(v1: [mutable int], v2: [mutable int]) {
         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]);
@@ -266,7 +266,7 @@ fn check_sort(v1: [int], v2: [int]) {
         fn le(&&a: int, &&b: int) -> bool { ret a <= b; }
         let f = le;
         let v3 = merge_sort::<int>(f, v1);
-        let i = 0u;
+        let mut i = 0u;
         while i < len {
             log(debug, v3[i]);
             assert (v3[i] == v2[i]);
index cb7d1cde0efde819097e7bef0cd684bda0c0d8d6..271fac730ab9e4838e718dabfc53ad450aaf926c 100644 (file)
@@ -491,7 +491,7 @@ fn sort_tests() {
         let tests =
         {
         let testfn = fn~() { };
-        let tests = [];
+        let mut tests = [];
         for name: str in names {
             let test = {name: name, fn: testfn, ignore: false,
                         should_fail: false};
index 6b5a86989765149dfa3a09f7c294aeb3aba78f12..f0bac2b1d9760261b123dafa794567a9b765a40f 100644 (file)
@@ -422,7 +422,6 @@ fn build_session_options(match: getopts::match,
     let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
     let test = opt_present(match, "test");
     let warn_unused_imports = opt_present(match, "warn-unused-imports");
-    let enforce_mut_vars = opt_present(match, "enforce-mut-vars");
     let sopts: @session::options =
         @{crate_type: crate_type,
           static: static,
@@ -444,8 +443,7 @@ fn build_session_options(match: getopts::match,
           parse_only: parse_only,
           no_trans: no_trans,
           no_asm_comments: no_asm_comments,
-          warn_unused_imports: warn_unused_imports,
-          enforce_mut_vars: enforce_mut_vars};
+          warn_unused_imports: warn_unused_imports};
     ret sopts;
 }
 
index d48ca3f495e4fc34dbc611bea6e818c75fdeb1e6..b691aa65f881fd41e38933822b9900df2b1c7ffa 100644 (file)
@@ -45,8 +45,7 @@ enum crate_type { bin_crate, lib_crate, unknown_crate, }
      parse_only: bool,
      no_trans: bool,
      no_asm_comments: bool,
-     warn_unused_imports: bool,
-     enforce_mut_vars: bool};
+     warn_unused_imports: bool};
 
 type crate_metadata = {name: str, data: [u8]};
 
@@ -154,7 +153,7 @@ fn make_crate_type_attr(t: str) -> ast::attribute {
     }
 
     fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate {
-        let attrs = [];
+        let mut attrs = [];
         if with_bin { attrs += [make_crate_type_attr("bin")]; }
         if with_lib { attrs += [make_crate_type_attr("lib")]; }
         @ast_util::respan(ast_util::dummy_sp(), {
index b6fa6d1fffbf8d19158523c11c761638dff00446..0c40305f14a626fc85fa02c05a73c666a8235ea5 100644 (file)
@@ -305,7 +305,7 @@ fn is_illegal_to_modify_def(cx: @ctx, def: def, msg: msg) -> option<str> {
       // variables are assigned at most once.  But this requires a new kind of
       // propagation (def. not assigned), so I didn't do that.
       def_local(_, false) if msg == msg_move_out { none }
-      def_local(_, false) if cx.tcx.sess.opts.enforce_mut_vars {
+      def_local(_, false) {
         some("immutable local variable")
       }
 
index 433424d27370dd88de7ac9fa8fd96437c04e08d2..76f9f8527f416041e5b0a657d46fcd5ae29d9819 100644 (file)
@@ -1134,6 +1134,13 @@ fn print_decl(s: ps, decl: @ast::decl) {
         space_if_not_bol(s);
         ibox(s, indent_unit);
         word_nbsp(s, "let");
+
+        // if any are mutable, all are mutable
+        if vec::any(locs) {|l| l.node.is_mutbl } {
+            assert vec::all(locs) {|l| l.node.is_mutbl };
+            word_nbsp(s, "mut");
+        }
+
         fn print_local(s: ps, &&loc: @ast::local) {
             ibox(s, indent_unit);
             print_local_decl(s, loc);
index 2b0d502cb098a1946ff474e557802691491fb057..c3e2221cea11f25d7d1b1b11172a0e646fe68740 100644 (file)
@@ -77,7 +77,7 @@ fn act(po: comm::port<msg>, source: str, parse: parser) {
         ignore_errors
     );
 
-    let keep_going = true;
+    let mut keep_going = true;
     while keep_going {
         alt comm::recv(po) {
           handle_request(f) {
@@ -147,8 +147,7 @@ fn build_session() -> (session::session, @mutable bool) {
         parse_only: false,
         no_trans: false,
         no_asm_comments: false,
-        warn_unused_imports: false,
-        enforce_mut_vars: false
+        warn_unused_imports: false
     };
 
     let codemap = codemap::new_codemap();
index 2f3262f459bb7b80162dbae56254a48e27c9ab7d..0ad21a77bdb0f6e2c8d99de1d5f137c972acfff1 100644 (file)
@@ -131,7 +131,7 @@ fn first_sentence(s: str) -> option<str> {
 }
 
 fn first_sentence_(s: str) -> str {
-    let dotcount = 0;
+    let mut dotcount = 0;
     // The index of the character following a single dot. This allows
     // Things like [0..1) to appear in the brief description
     let idx = str::find(s) {|ch|
@@ -163,10 +163,10 @@ fn first_sentence_(s: str) -> str {
 
 fn paragraphs(s: str) -> [str] {
     let lines = str::lines_any(s);
-    let whitespace_lines = 0;
-    let accum = "";
+    let mut whitespace_lines = 0;
+    let mut accum = "";
     let paras = vec::foldl([], lines) {|paras, line|
-        let res = paras;
+        let mut res = paras;
 
         if str::is_whitespace(line) {
             whitespace_lines += 1;
index 501b5b4384e6c5972d613b98cace384fd71ad7c7..c60ae65afe69f942e094cc9b2f1a69e37e7076c8 100644 (file)
@@ -127,7 +127,7 @@ fn readclose(fd: libc::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);
@@ -138,8 +138,8 @@ fn readclose(fd: libc::c_int) -> str {
 
 fn generic_writer(process: fn~(markdown: str)) -> writer {
     let ch = task::spawn_listener {|po: comm::port<writeinstr>|
-        let markdown = "";
-        let keep_going = true;
+        let mut markdown = "";
+        let mut keep_going = true;
         while keep_going {
             alt comm::recv(po) {
               write(s) { markdown += s; }
@@ -281,7 +281,7 @@ fn future_writer() -> (writer, future::future<str>) {
         comm::send(chan, copy instr);
     };
     let future = future::from_fn {||
-        let res = "";
+        let mut res = "";
         loop {
             alt comm::recv(port) {
               write(s) { res += s }
index f711e7d76280d9f249705725b3600c73a37ac5e0..e0795904291168dd996633f362a3c711a35b87c1 100644 (file)
@@ -46,7 +46,7 @@ fn to_assoc_list<K:copy, V:copy>(
     map: map::hashmap<K, V>
 ) -> [(K, V)] {
 
-    let vec = [];
+    let mut vec = [];
     map.items {|k, v|
         vec += [(k, v)];
     }
@@ -183,7 +183,7 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map {
             };
             let modpath = ast_map::path_to_str(vec::init(*path));
 
-            let reexportdocs = [];
+            let mut reexportdocs = [];
             for def in defs {
                 if !def.reexp { cont; }
                 alt def_map.find(def.id) {
index ce24f9b1aeec43a9d4e858aeddf23f6533a257b0..4427d1bfa497b610e0c8fb09fafc52ae13673c08 100755 (executable)
@@ -30,7 +30,7 @@ fn run_passes(
          original through each pass"
     )];
 
-    let passno = 0;
+    let mut passno = 0;
     vec::foldl(doc, passes) {|doc, pass|
         log(debug, #fmt("pass #%d", passno));
         passno += 1;
index fc957835822a2ecacaf91b639d823d919f2017e0..7ce71d88a967015dc80094cd543d410d60c69909 100644 (file)
@@ -90,9 +90,9 @@ fn sectionalize(desc: option<str>) -> (option<str>, [doc::section]) {
 
     let lines = str::lines(option::get(desc));
 
-    let new_desc = none;
-    let current_section = none;
-    let sections = [];
+    let mut new_desc = none;
+    let mut current_section = none;
+    let mut sections = [];
 
     for line in lines {
         alt parse_header(line) {
index 48d7b595f5ff0f860edf8767e64e76ec3fb070ba..342e0914647a75ff0a1f318714d816fc1fe86091 100644 (file)
@@ -19,8 +19,8 @@ fn mk_pass() -> pass {
 
 fn unindent(s: str) -> str {
     let lines = str::lines_any(s);
-    let saw_first_line = false;
-    let saw_second_line = false;
+    let mut saw_first_line = false;
+    let mut saw_second_line = false;
     let min_indent = vec::foldl(uint::max_value, lines) {|min_indent, line|
 
         // After we see the first non-whitespace line, look at
@@ -46,7 +46,7 @@ fn unindent(s: str) -> str {
             min_indent
         } else {
             saw_first_line = true;
-            let spaces = 0u;
+            let mut spaces = 0u;
             str::all(line) {|char|
                 // Only comparing against space because I wouldn't
                 // know what to do with mixed whitespace chars
index 6e58c4cecee84c950067dc0c98529dba7a8fd995..a14dbc2eedd7535c81061624d52d52b3efe45fb5 100644 (file)
@@ -3,7 +3,7 @@
 impl helpers for uint {
     #[inline]
     fn to(v: uint, f: fn(uint)) {
-        let i = self;
+        let mut i = self;
         while i < v {
             f(i);
             i += 1u;
index 668030087bd512cbc23cc705413d48eec219dba5..50d9df243e7cdea5a6f52fd20c0e775919bb87c6 100644 (file)
@@ -2,7 +2,7 @@
 
 #[inline]
 fn iter<T>(v: [T], f: fn(T)) {
-    let i = 0u;
+    let mut i = 0u;
     let n = vec::len(v);
     while i < n {
         f(v[i]);
index 2755fdfa6cf523ef2313aa5e07b4df0161a10476..42f959a4a7dc8788df5cbd7819bddfa8ef68cdf0 100644 (file)
@@ -2,7 +2,7 @@
 
 // same as cci_iter_lib, more-or-less, but not marked inline
 fn iter(v: [uint], f: fn(uint)) {
-    let i = 0u;
+    let mut i = 0u;
     let n = vec::len(v);
     while i < n {
         f(v[i]);
index 6abeb63471fd078e7cf512a16fe4e15a19127d70..46b718a85c776eb4530be39a91517e4ab0d65aa8 100644 (file)
@@ -23,9 +23,9 @@ fn b8() -> str {
 }
 
 fn sub(t: str, n: int) -> str unsafe {
-    let b: str = "";
-    let i: uint = 0u;
-    let ns: str;
+    let mut b: str = "";
+    let mut i: uint = 0u;
+    let mut ns: str;
     alt n {
       0 { ns = "no more bottles"; }
       1 { ns = "1 bottle"; }
@@ -42,7 +42,7 @@ fn sub(t: str, n: int) -> str unsafe {
 
 /* Using an interator */
 fn ninetynine(it: fn(int)) {
-    let n: int = 100;
+    let mut n: int = 100;
     while n > 1 { n -= 1; it(n); }
 }
 
index ec27e3f00547d9ead1b2068920bcd3d07cce292d..a2a1c00b75d6664a01b3ef77fe0f4b7740c0025a 100644 (file)
@@ -51,7 +51,7 @@ fn next(b: bottle) -> bottle {
 fn more(b: bottle) -> bool { alt b { none { ret false; } _ { ret true; } } }
 
 fn main() {
-    let b: bottle = multiple(99);
-    let running: bool = true;
+    let mut b: bottle = multiple(99);
+    let mut running: bool = true;
     while running { show(b); #debug(""); running = more(b); b = next(b); }
 }
index 3fcf6abebb193a58b0aaf287ffe3d2dda6ba0773..2fa2b6cb18ee05c0d4d08eb8bb77c61436e88ecb 100644 (file)
@@ -23,9 +23,9 @@ fn b8() -> str {
 }
 
 fn sub(t: str, n: int) -> str unsafe {
-    let b: str = "";
-    let i: uint = 0u;
-    let ns: str;
+    let mut b: str = "";
+    let mut i: uint = 0u;
+    let mut ns: str;
     alt n {
       0 { ns = "no more bottles"; }
       1 { ns = "1 bottle"; }
@@ -42,7 +42,7 @@ fn sub(t: str, n: int) -> str unsafe {
 
 /* Straightforward counter */
 fn main() {
-    let n: int = 99;
+    let mut n: int = 99;
     while n > 0 {
         log(debug, sub(b1(), n));
         log(debug, sub(b2(), n - 1));
index 7710c3acfd48a1a05b29a43716abadc89137de7b..39c0f8791409761004a466ff2daf9e8e23b0b2b0 100644 (file)
@@ -15,8 +15,8 @@ enum request {
 }
 
 fn server(requests: comm::port<request>, responses: comm::chan<uint>) {
-    let count = 0u;
-    let done = false;
+    let mut count = 0u;
+    let mut done = false;
     while !done {
         alt comm::recv(requests) {
           get_count { comm::send(responses, copy count); }
@@ -37,7 +37,7 @@ fn run(args: [str]) {
     let workers = option::get(uint::from_str(args[2]));
     let start = std::time::precise_time_s();
     let to_child = to_child;
-    let worker_results = [];
+    let mut worker_results = [];
     uint::range(0u, workers) {|_i|
         let builder = task::task_builder();
         worker_results += [task::future_result(builder)];
index eecdb2ee483848a5bf146aa2d45772359bee7fcb..b0bc3c519cc13f63ecc3b2f0bcf7711241fcebaf 100644 (file)
@@ -25,7 +25,7 @@ fn main(args: [str]) {
         8
     };
     let min_depth = 4;
-    let max_depth;
+    let mut max_depth;
     if min_depth + 2 > n {
         max_depth = min_depth + 2;
     } else { max_depth = n; }
@@ -35,13 +35,13 @@ fn main(args: [str]) {
                           stretch_depth,
                           item_check(stretch_tree)));
     let long_lived_tree = bottom_up_tree(0, max_depth);
-    let depth = min_depth;
+    let mut depth = min_depth;
     while depth <= max_depth {
         let iterations = int::pow(2, (max_depth - depth + min_depth) as uint);
-        let chk = 0;
-        let i = 1;
+        let mut chk = 0;
+        let mut i = 1;
         while i <= iterations {
-            let temp_tree = bottom_up_tree(i, depth);
+            let mut temp_tree = bottom_up_tree(i, depth);
             chk += item_check(temp_tree);
             temp_tree = bottom_up_tree(-i, depth);
             chk += item_check(temp_tree);
index 721436719041b9540afc1f04ee882690ff2589f8..3f9f6a63054d491d33f7d6aac8ad309cee95537b 100644 (file)
@@ -9,13 +9,13 @@ fn fannkuch(n: int) -> int {
     let perm = vec::to_mut(vec::from_elem(n as uint, 0));
     let perm1 = vec::to_mut(vec::from_fn(n as uint, perm1init));
     let count = vec::to_mut(vec::from_elem(n as uint, 0));
-    let f = 0;
-    let i = 0;
-    let k = 0;
-    let r = 0;
-    let flips = 0;
-    let nperm = 0;
-    let checksum = 0;
+    let mut f = 0;
+    let mut i = 0;
+    let mut k = 0;
+    let mut r = 0;
+    let mut flips = 0;
+    let mut nperm = 0;
+    let mut checksum = 0;
     r = n;
     while r > 0 {
         i = 0;
@@ -40,7 +40,7 @@ fn fannkuch(n: int) -> int {
         if nperm & 0x1 == 0 { checksum += f; } else { checksum -= f; }
         // Use incremental change to generate another permutation
 
-        let go = true;
+        let mut go = true;
         while go {
             if r == n {
                 io::println(#fmt("%d", checksum));
index a496e878efa7d07ee3d7ba47bb4c3343f6bafbb7..37e5776c2b15295af08014d94295dbbb31cfff82 100644 (file)
@@ -23,8 +23,8 @@ fn myrandom_next(r: myrandom, mx: u32) -> u32 {
 type aminoacids = {ch: char, prob: u32};
 
 fn make_cumulative(aa: [aminoacids]) -> [aminoacids] {
-    let cp: u32 = 0u32;
-    let ans: [aminoacids] = [];
+    let mut cp: u32 = 0u32;
+    let mut ans: [aminoacids] = [];
     for a: aminoacids in aa { cp += a.prob; ans += [{ch: a.ch, prob: cp}]; }
     ret ans;
 }
@@ -45,7 +45,7 @@ fn bisect(v: [aminoacids], lo: uint, hi: uint, target: u32) -> char {
 fn make_random_fasta(id: str, desc: str, genelist: [aminoacids], n: int) {
     log(debug, ">" + id + " " + desc);
     let rng = @{mutable last: std::rand::rng().next()};
-    let op: str = "";
+    let mut op: str = "";
     uint::range(0u, n as uint) {|_i|
         str::push_char(op, select_random(myrandom_next(rng, 100u32),
                                          genelist));
@@ -59,7 +59,7 @@ fn make_random_fasta(id: str, desc: str, genelist: [aminoacids], n: int) {
 
 fn make_repeat_fasta(id: str, desc: str, s: str, n: int) unsafe {
     log(debug, ">" + id + " " + desc);
-    let op: str = "";
+    let mut op: str = "";
     let sl: uint = str::len(s);
     uint::range(0u, n as uint) {|i|
         str::unsafe::push_byte(op, s[i % sl]);
index 5883b047309b51631b270acfe9c73bf5bf31510b..ad24be13ca35693d4a3da455d2556a2c053d5399 100644 (file)
@@ -36,9 +36,9 @@ fn +(x: cmplx) -> cmplx {
 
 fn mb(x: cmplx) -> bool
 {
-    let z = {re: 0., im: 0.};
-    let i = 0;
-    let in = true;
+    let mut z = {re: 0., im: 0.};
+    let mut i = 0;
+    let mut in = true;
     while i < 50 {
         z = z*z + x;
         if cabs(z) >= 4. {
@@ -51,8 +51,8 @@ fn mb(x: cmplx) -> bool
 }
 
 fn fillbyte(x: cmplx, incr: f64) -> u8 {
-    let rv = 0_u8;
-    let i = 0_u8;
+    let mut rv = 0_u8;
+    let mut i = 0_u8;
     while i < 8_u8 {
         let z = {re: x.re + (i as f64)*incr, im: x.im};
         if mb(z) {
@@ -65,7 +65,7 @@ fn fillbyte(x: cmplx, incr: f64) -> u8 {
 
 fn chanmb(i: uint, size: uint, ch: comm::chan<line>) -> ()
 {
-    let crv = [];
+    let mut crv = [];
     let incr = 2./(size as f64);
     let y = incr*(i as f64) - 1.;
     let xincr = 8.*incr;
@@ -107,15 +107,15 @@ fn writer(path: str, writech: comm::chan<comm::chan<line>>, size: uint)
     cout.write_line("P4");
     cout.write_line(#fmt("%u %u", size, size));
     let lines = std::map::uint_hash();
-    let done = 0_u;
-    let i = 0_u;
+    let mut done = 0_u;
+    let mut i = 0_u;
     while i < size {
         let aline = comm::recv(p);
         if aline.i == done {
             #debug("W %u", aline.i);
             cout.write(aline.b);
             done += 1_u;
-            let prev = done;
+            let mut prev = done;
             while prev <= i {
                 if lines.contains_key(prev) {
                     #debug("WS %u", prev);
index cd51c10d64512ace7537f43d0f9dec1684164a68..cc40dfa0b4fe46b129f75293dbd87024e2c977dc 100644 (file)
@@ -21,7 +21,7 @@ fn main(args: [str]) {
     };
     let bodies: [Body::props] = NBodySystem::MakeNBodySystem();
     io::println(#fmt("%f", NBodySystem::energy(bodies)));
-    let i: int = 0;
+    let mut i: int = 0;
     while i < n { NBodySystem::advance(bodies, 0.01); i += 1; }
     io::println(#fmt("%f", NBodySystem::energy(bodies)));
 }
@@ -37,11 +37,11 @@ fn MakeNBodySystem() -> [Body::props] {
             [Body::sun(), Body::jupiter(), Body::saturn(), Body::uranus(),
              Body::neptune()];
 
-        let px: float = 0.0;
-        let py: float = 0.0;
-        let pz: float = 0.0;
+        let mut px: float = 0.0;
+        let mut py: float = 0.0;
+        let mut pz: float = 0.0;
 
-        let i: int = 0;
+        let mut i: int = 0;
         while i < 5 {
             px += bodies[i].vx * bodies[i].mass;
             py += bodies[i].vy * bodies[i].mass;
@@ -58,9 +58,9 @@ fn MakeNBodySystem() -> [Body::props] {
 
     fn advance(bodies: [Body::props], dt: float) {
 
-        let i: int = 0;
+        let mut i: int = 0;
         while i < 5 {
-            let j: int = i + 1;
+            let mut j: int = i + 1;
             while j < 5 { advance_one(bodies[i], bodies[j], dt); j += 1; }
 
             i += 1;
@@ -96,20 +96,20 @@ fn move(b: Body::props, dt: float) {
     }
 
     fn energy(bodies: [Body::props]) -> float unsafe {
-        let dx: float;
-        let dy: float;
-        let dz: float;
-        let distance: float;
-        let e: float = 0.0;
+        let mut dx: float;
+        let mut dy: float;
+        let mut dz: float;
+        let mut distance: float;
+        let mut e: float = 0.0;
 
-        let i: int = 0;
+        let mut i: int = 0;
         while i < 5 {
             e +=
                 0.5 * bodies[i].mass *
                     (bodies[i].vx * bodies[i].vx + bodies[i].vy * bodies[i].vy
                          + bodies[i].vz * bodies[i].vz);
 
-            let j: int = i + 1;
+            let mut j: int = i + 1;
             while j < 5 {
                 dx = bodies[i].x - bodies[j].x;
                 dy = bodies[i].y - bodies[j].y;
index 41ba82853d947e8196d6d7cdb86cd7d8fbbb11d1..72d85bfba6581ab90d4d7e5f123f150601aba994 100644 (file)
@@ -59,7 +59,7 @@ fn parse_opts(argv: [str]) -> config {
 }
 
 fn stress_task(&&id: int) {
-    let i = 0;
+    let mut i = 0;
     loop {
         let n = 15;
         assert (fib(n) == fib(n));
@@ -69,7 +69,7 @@ fn stress_task(&&id: int) {
 }
 
 fn stress(num_tasks: int) {
-    let results = [];
+    let mut results = [];
     range(0, num_tasks) {|i|
         let builder = task::task_builder();
         results += [task::future_result(builder)];
index 3efacf079fd76dd1145dc93437369753f8f0e79e..d1bd69fee0704adab717fb5fbe383d85dab69d22 100644 (file)
@@ -8,10 +8,10 @@ fn eval_A(i: uint, j: uint) -> float {
 
 fn eval_A_times_u(u: [const float], Au: [mutable float]) {
     let N = vec::len(u);
-    let i = 0u;
+    let mut i = 0u;
     while i < N {
         Au[i] = 0.0;
-        let j = 0u;
+        let mut j = 0u;
         while j < N {
             Au[i] += eval_A(i, j) * u[j];
             j += 1u;
@@ -22,10 +22,10 @@ fn eval_A_times_u(u: [const float], Au: [mutable float]) {
 
 fn eval_At_times_u(u: [const float], Au: [mutable float]) {
     let N = vec::len(u);
-    let i = 0u;
+    let mut i = 0u;
     while i < N {
         Au[i] = 0.0;
-        let j = 0u;
+        let mut j = 0u;
         while j < N {
             Au[i] += eval_A(j, i) * u[j];
             j += 1u;
@@ -50,16 +50,16 @@ fn main(args: [str]) {
 
     let u = vec::to_mut(vec::from_elem(N, 1.0));
     let v = vec::to_mut(vec::from_elem(N, 0.0));
-    let i = 0u;
+    let mut i = 0u;
     while i < 10u {
         eval_AtA_times_u(u, v);
         eval_AtA_times_u(v, u);
         i += 1u;
     }
 
-    let vBv = 0.0;
-    let vv = 0.0;
-    let i = 0u;
+    let mut vBv = 0.0;
+    let mut vv = 0.0;
+    let mut i = 0u;
     while i < N {
         vBv += u[i] * v[i];
         vv += v[i] * v[i];
index d87c2cadc1ceeaf129e0d3d0af61fa6d32db4a4d..cf6951b23a6957b9a954ed275645b40e827d9664 100644 (file)
@@ -59,7 +59,7 @@ fn next_color(g: grid, row: u8, col: u8, start_color: u8) -> bool {
             drop_colors(g, avail, row, col);
 
             // find first remaining color that is available
-            let i = 1 as uint;
+            let mut i = 1 as uint;
             while i < (10 as uint) { /* FIXME llvm ctlhd */
                 if bitv::get(avail, i) {
                     g[row][col] = i as u8;
@@ -94,7 +94,7 @@ fn drop_color(g: grid, colors: bitv::bitv, row: u8, col: u8) {
         }
     }
 
-    let work: [(u8, u8)] = []; /* queue of uncolored fields */
+    let mut work: [(u8, u8)] = []; /* queue of uncolored fields */
     u8::range(0u8, 9u8) { |row|
         u8::range(0u8, 9u8) { |col|
             let color = (*g)[row][col];
@@ -102,7 +102,7 @@ fn drop_color(g: grid, colors: bitv::bitv, row: u8, col: u8) {
         }
     }
 
-    let ptr = 0u;
+    let mut ptr = 0u;
     let end = vec::len(work);
     while (ptr < end) {
         let (row, col) = work[ptr];
index bf74f736a83035db55cc5071089ff7de01fddb17..d2cc076594af136852970fdf9f4e89250a5b4ee6 100644 (file)
@@ -9,8 +9,8 @@ enum msg {
 fn calc(children: uint, parent_ch: comm::chan<msg>) {
     let port = comm::port();
     let chan = comm::chan(port);
-    let child_chs = [];
-    let sum = 0;
+    let mut child_chs = [];
+    let mut sum = 0;
 
     iter::repeat (children) {||
         task::spawn {||
index de81e0263d5fb02cf827c5b6474ea99eb971bc9a..8b880e2fb593adbe2f0caf0078adfe40d30256f7 100644 (file)
@@ -1,5 +1,5 @@
 fn f(&&n: uint) {
-    let i = 0u;
+    let mut i = 0u;
     while i < n {
         task::try {|| g() };
         i += 1u;
@@ -13,6 +13,6 @@ fn main(args: [str]) {
         if vec::len(args) < 2u {
             10u
         } else { option::get(uint::parse_buf(str::bytes(args[1]), 10u)) };
-    let i = 0u;
+    let mut i = 0u;
     while i < n { task::spawn {|| f(n); }; i += 1u; }
 }
index 0b24596da643b0d6ccb4301a261a43ff0c8d67ac..c8388102c49d0ea5b1eb7e34a2b7c0616104bfe6 100644 (file)
@@ -5,7 +5,7 @@
 
 fn f(&&n: uint) {
     uint::range(0u, n) {|i|
-        let v: [u8] = [];
+        let mut v: [u8] = [];
         vec::reserve(v, 1000u);
     }
 }
index e8c889ad7ef43090131f9237cc8453389c15e2bc..60cc0c03d4d03f31f6f0e2311e49904d338714db 100644 (file)
@@ -31,7 +31,7 @@ fn map(input: str, emit: map_reduce::putter) {
 }
 
 fn reduce(_word: str, get: map_reduce::getter) {
-    let count = 0;
+    let mut count = 0;
 
     loop { alt get() { some(_) { count += 1; } none { break; } } }
 }
@@ -60,7 +60,7 @@ enum reduce_proto { emit_val(int), done, ref, release, }
 
     fn start_mappers(ctrl: chan<ctrl_proto>, -inputs: [str]) ->
        [future::future<task::task_result>] {
-        let results = [];
+        let mut results = [];
         for i: str in inputs {
             let builder = task::task_builder();
             results += [task::future_result(builder)];
@@ -75,7 +75,7 @@ fn map_task(ctrl: chan<ctrl_proto>, input: str) {
 
         fn emit(im: map::hashmap<str, chan<reduce_proto>>,
                 ctrl: chan<ctrl_proto>, key: str, val: int) {
-            let c;
+            let mut c;
             alt im.find(key) {
               some(_c) {
                 c = _c;
@@ -134,12 +134,12 @@ fn map_reduce(-inputs: [str]) {
         // This task becomes the master control task. It task::_spawns
         // to do the rest.
 
-        let reducers: map::hashmap<str, chan<reduce_proto>>;
+        let mut reducers: map::hashmap<str, chan<reduce_proto>>;
 
         reducers = map::str_hash();
 
-        let num_mappers = vec::len(inputs) as int;
-        let results = start_mappers(chan(ctrl), inputs);
+        let mut num_mappers = vec::len(inputs) as int;
+        let mut results = start_mappers(chan(ctrl), inputs);
 
         while num_mappers > 0 {
             alt recv(ctrl) {
@@ -148,7 +148,7 @@ fn map_reduce(-inputs: [str]) {
                 num_mappers -= 1;
               }
               find_reducer(k, cc) {
-                let c;
+                let mut c;
                 // log(error, "finding reducer for " + k);
                 alt reducers.find(k) {
                   some(_c) {
@@ -191,7 +191,7 @@ fn main(argv: [str]) {
     map_reduce::map_reduce(inputs);
     let stop = time::precise_time_ns();
 
-    let elapsed = stop - start;
+    let mut elapsed = stop - start;
     elapsed /= 1000000u64;
 
     log(error, "MapReduce completed in "
@@ -199,7 +199,7 @@ fn main(argv: [str]) {
 }
 
 fn read_word(r: io::reader) -> option<str> {
-    let w = "";
+    let mut w = "";
 
     while !r.eof() {
         let c = r.read_char();
index 527a103e34227b7af1fe40b16a4ffcdd76ba2e13..8014ee75c1596c5f3ab6ca8ea75200a3b654f989 100644 (file)
@@ -1,2 +1,4 @@
 // error-pattern:wooooo
-fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; }
+fn main() {
+    let mut a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o";
+}
index 8d79987a4fee352587004fd6e89b2df5c5f98d94..28e93d0edbda8063488acc34f7a9ec7f49fbf059 100644 (file)
@@ -16,7 +16,7 @@ fn eq(&&s: [@str], &&t: [@str]) -> bool {
     }
 
     let map = map::hashmap(hash, eq);
-    let arr = [];
+    let mut arr = [];
     uint::range(0u, 10u) {|i|
         arr += [@"key stuff"];
         map.insert(arr, arr + [@"value stuff"]);
index 77b52da4acfc660593d17080b76dc77fc8046fbb..60ddb99c26a71dd2269093b516bde348aaef7229 100644 (file)
@@ -3,8 +3,8 @@
 import option;
 
 fn foo<T>(y: option<T>) {
-    let x: int;
-    let rs: [int] = [];
+    let mut x: int;
+    let mut rs: [int] = [];
     /* tests that x doesn't get put in the precondition for the
        entire if expression */
 
index c63c622e2efef61b6db15e165acde10ec61325f5..58b19eeeed21747e12db7e7dd7b86edde18f00e2 100644 (file)
@@ -5,7 +5,7 @@ enum thing { a, b, c, }
 fn foo(it: fn(int)) { it(10); }
 
 fn main() {
-    let x = true;
+    let mut x = true;
     alt a {
       a { x = true; foo {|_i|} }
       b { x = false; }
index 11fad7375b5c133db130b3c2be345421c1f32e14..7bd21a114c97210bef96d6464555cb786a36e65a 100644 (file)
@@ -9,7 +9,7 @@ enum color {
 }
 
 fn process(c: color) -> int {
-    let x: int;
+    let mut x: int;
     alt c {
       rgb(r, _, _) { #debug("rgb"); log(debug, r); x = r; }
       rgba(_, _, _, a) { #debug("rgba"); log(debug, a); x = a; }
index 24184cdc2d960e5d41336983bfaff5152310649f..3af1d92a8ea86ff84a685e604f568840f3575947 100644 (file)
@@ -9,7 +9,7 @@ fn f1(a: {mutable x: int}, &b: int, -c: int) -> int {
 fn f2(a: int, f: fn(int)) -> int { f(1); ret a; }
 
 fn main() {
-    let a = {mutable x: 1}, b = 2, c = 3;
+    let mut a = {mutable x: 1}, b = 2, c = 3;
     assert (f1(a, b, c) == 6);
     assert (a.x == 0);
     assert (b == 10);
index fffb35e81fb230423fa3818f49ab75574e1941f2..210053f2e73e1a246448b8ce80a55f453bab08e8 100644 (file)
@@ -1,19 +1,19 @@
 // Issue 483 - Assignment expressions result in nil
 fn test_assign() {
-    let x: int;
-    let y: () = x = 10;
+    let mut x: int;
+    let mut y: () = x = 10;
     assert (x == 10);
-    let z = x = 11;
+    let mut z = x = 11;
     assert (x == 11);
     z = x = 12;
     assert (x == 12);
 }
 
 fn test_assign_op() {
-    let x: int = 0;
-    let y: () = x += 10;
+    let mut x: int = 0;
+    let mut y: () = x += 10;
     assert (x == 10);
-    let z = x += 11;
+    let mut z = x += 11;
     assert (x == 21);
     z = x += 12;
     assert (x == 33);
index 6e83d2ca0aa5657fb8f6d6878466a64417ec6be3..f5f0332dc431c2ad57c0ee29254b6df823d52d18 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
-    let sum = 0;
+    let mut sum = 0;
     for x in [1, 2, 3, 4, 5] { sum += x; }
     assert (sum == 15);
 }
index fb610279c77b7c60fda65d918d29723d9e35e507..55a5ac7314c3c2d66ac16a45c9f280a2028a0ab9 100644 (file)
@@ -14,7 +14,7 @@ fn main() {
     let ch = chan(p);
     task::spawn {|| a(ch); };
     task::spawn {|| a(ch); };
-    let n: int = 0;
+    let mut n: int = 0;
     n = recv(p);
     n = recv(p);
     //    #debug("Finished.");
index 6a238b4c4bcac4e537875ac44ebee93a25f46ff3..e45ff2c4c71ffd6ccb9f18db7aa64f618b2eaa32 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
     let ch = chan(p);
     task::spawn {|| a(ch); };
     task::spawn {|| b(ch); };
-    let n: int = 0;
+    let mut n: int = 0;
     n = recv(p);
     n = recv(p);
     #debug("Finished.");
index 323451c98abf0d2da1e4a414239c04f2fe5085ab..8ef7d50b9593e7f58ad40a0eb5be83b0fd1b6039 100644 (file)
@@ -28,13 +28,13 @@ fn g(x: int, y: str) -> int {
 }
 
 fn main() {
-    let n: int = 2 + 3 * 7;
+    let mut n: int = 2 + 3 * 7;
     let s: str = "hello there";
     let p = comm::port();
     let ch = comm::chan(p);
     task::spawn {|| a(ch); };
     task::spawn {|| b(ch); };
-    let x: int = 10;
+    let mut x: int = 10;
     x = g(n, s);
     log(debug, x);
     n = recv(p);
index f04cd76a93e11a5661bb4e66646232c65010cc4f..6651bc22f78d02366fb16d603c2a7fb0558f4375 100644 (file)
@@ -11,8 +11,8 @@ fn target() {
 }
 
 fn general() {
-    let a: int = 1;
-    let b: int = 2;
+    let mut a: int = 1;
+    let mut b: int = 2;
     a ^= b;
     b ^= a;
     a = a ^ b;
index 94e1973bbe72a078f49ab47fbf6cadbb5615291e..b13b819b2dc8e9093abe3a0282038848accae958 100644 (file)
@@ -8,7 +8,7 @@ fn main() {
     }
 
     // Usable at all:
-    let any_negative = vec::any(v) { |e| float::is_negative(e) };
+    let mut any_negative = vec::any(v) { |e| float::is_negative(e) };
     assert any_negative;
 
     // Higher precedence than assignments:
index 8a01150e313c2d877de63f997b25c141bdeefc0e..e91c5fe5d23ce13da54ca4f4caf6444806b36c9a 100644 (file)
@@ -2,7 +2,7 @@
 
 fn main() {
     let v = [1, 2, 3, 4, 5, 6, 7];
-    let odds = 0;
+    let mut odds = 0;
     iter_vec(v, {|i|
         log(error, i);
         if i % 2 == 1 {
index 085f468c60adc5780b5be426c392ae7620c368c7..bc984241aae6a16250b0116ae93883675e2c1fe6 100644 (file)
@@ -2,7 +2,7 @@
 
 fn main() {
     let v = [1, 2, 3, 4, 5];
-    let sum = 0;
+    let mut sum = 0;
     iter_vec(v, {|i|
         iter_vec(v, {|j|
             log(error, i * j);
index 962c360ca7b19e9279f1623d32397fccf844dae1..a13843d37cf4f35343a7a9c83d9040c6a82a5722 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn main() {
-    let i = 0;
+    let mut i = 0;
     while i < 20 { i += 1; if i == 10 { break; } }
     assert (i == 10);
     do  { i += 1; if i == 20 { break; } } while i < 30
index 20eb185b02a433bbc181fc990b764373c81b3d71..152f74d683d34f8bb7012966f16f90450bdd8d9f 100644 (file)
@@ -15,7 +15,7 @@ enum request { quit, close(chan<bool>), }
 fn request_task(c: chan<ctx>) {
     let p = port();
     send(c, chan(p));
-    let req: request;
+    let mut req: request;
     req = recv(p);
     // Need to drop req before receiving it again
     req = recv(p);
@@ -25,7 +25,7 @@ fn new_cx() -> ctx {
     let p = port();
     let ch = chan(p);
     let t = task::spawn {|| request_task(ch); };
-    let cx: ctx;
+    let mut cx: ctx;
     cx = recv(p);
     ret cx;
 }
index 854711286ddb50a30e8778ba3cf5e219fdfe176a..c715f3b677b10778b9dfb64f24ee2ad05e4cf323 100644 (file)
@@ -9,17 +9,17 @@ fn nothing() { }
 fn putstr(s: str) { }
 
 fn putint(i: int) {
-    let i: int = 33;
+    let mut i: int = 33;
     while i < 36 { putstr("hi"); i = i + 1; }
 }
 
 fn zerg(i: int) -> int { ret i; }
 
 fn foo(x: int) -> int {
-    let y: t = x + 2;
+    let mut y: t = x + 2;
     putstr("hello");
     while y < 10 { putint(y); if y * 3 == 4 { y = y + 2; nothing(); } }
-    let z: t;
+    let mut z: t;
     z = 0x55;
     foo(z);
     ret 0;
index c737628b0c4b528f1a9c0809da677edc1d43ca1a..a2550197d0eb30da2b22457615ceb7644c95f2f1 100644 (file)
@@ -3,7 +3,7 @@ fn main() unsafe {
     fn foo(_a: uint, _b: uint) : uint::le(_a, _b) {}
     let a: uint = 1u;
     let b: uint = 4u;
-    let c: uint = 17u;
+    let mut c: uint = 17u;
     check (uint::le(a, b));
     c <- a;
     log(debug, foo(c, b));
index 59202911a9a6550aab92736126a854c59b876c55..76d6a733e98c026546301a60919bf18215554fd3 100644 (file)
@@ -1,7 +1,7 @@
 fn main() unsafe {
     fn foo(_a: uint, _b: uint) : uint::le(_a, _b) {}
-    let a: uint = 4u;
-    let b: uint = 1u;
+    let mut a: uint = 4u;
+    let mut b: uint = 1u;
     check (uint::le(b, a));
     b <-> a;
     log(debug, foo(a, b));
index 93495115ba7a77fa2a0d8f1e11bcb2ff41ee56de..7badeedf824d53f2889af21ab1979671e5da3e96 100644 (file)
@@ -5,14 +5,14 @@
 
 // Tests for using alt as an expression
 fn test_basic() {
-    let rs: bool = alt true { true { true } false { false } };
+    let mut rs: bool = alt true { true { true } false { false } };
     assert (rs);
     rs = alt false { true { false } false { true } };
     assert (rs);
 }
 
 fn test_inferrence() {
-    let rs = alt true { true { true } false { false } };
+    let mut rs = alt true { true { true } false { false } };
     assert (rs);
 }
 
index 3aab0a6474486262970ff43b17573af727f2647c..b760763be0b61134298595f123d7c715ce038698 100644 (file)
@@ -9,7 +9,7 @@
 fn test_rec() { let rs = { {v1: 10, v2: 20} }; assert (rs.v2 == 20); }
 
 fn test_filled_with_stuff() {
-    let rs = { let a = 0; while a < 10 { a += 1; } a };
+    let rs = { let mut a = 0; while a < 10 { a += 1; } a };
     assert (rs == 10);
 }
 
index 53972843433da94dd8326e1168f93c063c9aa3fc..1b5504e8b86796c0a76af5d977476734bf0a051c 100644 (file)
@@ -8,7 +8,7 @@ fn g(f: native fn(int, &bool), &called: bool) {
 }
 
 fn main() {
-    let called = false;
+    let mut called = false;
     let h = f;
     g(h, called);
     assert called == true;
index c77a37cf27c2f5a4466cf7942868f5ed50e388da..6afd21559dd1ab888628ba794420d1504ac4016c 100644 (file)
@@ -6,7 +6,7 @@
 
 fn main() {
     let a: [mutable int] = [mutable -1, -1, -1, -1];
-    let p: int = 0;
+    let mut p: int = 0;
     two {|i|
         two {|j| a[p] = 10 * i + j; p += 1; };
     };
index d5ceb8202642b74c5331c0d0ec3fc0ac51d15892..4bf37df776d1c2b5ec55728e3cf6b1f61093d905 100644 (file)
@@ -1,14 +1,14 @@
 
 
 fn pairs(it: fn((int, int))) {
-    let i: int = 0;
-    let j: int = 0;
+    let mut i: int = 0;
+    let mut j: int = 0;
     while i < 10 { it((i, j)); i += 1; j += i; }
 }
 
 fn main() {
-    let i: int = 10;
-    let j: int = 0;
+    let mut i: int = 10;
+    let mut j: int = 0;
     pairs() {|p|
         let (_0, _1) = p;
         log(debug, _0);
index 047819bfb75bd1edd4e50e0f78bc907e1541cab6..c27b26066645ea3f9f4a77ea16900e24a183b384 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn main() {
-    let sum: int = 0;
+    let mut sum: int = 0;
     first_ten {|i| #debug("main"); log(debug, i); sum = sum + i; };
     #debug("sum");
     log(debug, sum);
@@ -11,6 +11,6 @@ fn main() {
 }
 
 fn first_ten(it: fn(int)) {
-    let i: int = 0;
+    let mut i: int = 0;
     while i < 10 { #debug("first_ten"); it(i); i = i + 1; }
 }
index 6f854efa85780bdd178ef455cf3bb2aec552b35e..4aac6559fe3d7d3130a7e84e87bb1a23d147f77e 100644 (file)
@@ -7,12 +7,12 @@
 type triple = {x: int, y: int, z: int};
 
 fn main() {
-    let x = 62;
-    let y = 63;
+    let mut x = 62;
+    let mut y = 63;
     let a = 'a';
-    let b = 'b';
+    let mut b = 'b';
     let p: triple = {x: 65, y: 66, z: 67};
-    let q: triple = {x: 68, y: 69, z: 70};
+    let mut q: triple = {x: 68, y: 69, z: 70};
     y = id::<int>(x);
     log(debug, y);
     assert (x == y);
index ebbbb87d3e2cd5939ee92554f7af49f888720af7..37727bcf03ae5d53a39ec9e80d82240718b32f24 100644 (file)
@@ -3,7 +3,7 @@
 enum foo<T> { arm(T), }
 
 fn altfoo<T>(f: foo<T>) {
-    let hit = false;
+    let mut hit = false;
     alt f { arm::<T>(x) { #debug("in arm"); hit = true; } }
     assert (hit);
 }
index cf134c1efdeade23804a6bbd4e3932c1a119a4e5..3d72538ca02b08220053c97e711c3a2954cbd183 100644 (file)
@@ -2,4 +2,4 @@
 
 enum option<T> { some(@T), none, }
 
-fn main() { let a: option<int> = some::<int>(@10); a = none::<int>; }
+fn main() { let mut a: option<int> = some::<int>(@10); a = none::<int>; }
index c241d3d9eb1aee45dc6875b2da65085b9870eec0..e3392da13d730ed128d36f7ff11482d1b2282eec 100644 (file)
@@ -44,7 +44,7 @@ fn map_task(ctrl: chan<ctrl_proto>, input: str) {
 
         fn emit(im: map::hashmap<str, int>, ctrl: chan<ctrl_proto>, key: str,
                 val: str) {
-            let c;
+            let mut c;
             alt im.find(key) {
               some(_c) { c = _c }
               none {
@@ -69,19 +69,19 @@ fn map_reduce(inputs: [str]) {
         // This task becomes the master control task. It spawns others
         // to do the rest.
 
-        let reducers: map::hashmap<str, int>;
+        let mut reducers: map::hashmap<str, int>;
 
         reducers = map::str_hash();
 
         start_mappers(chan(ctrl), inputs);
 
-        let num_mappers = vec::len(inputs) as int;
+        let mut num_mappers = vec::len(inputs) as int;
 
         while num_mappers > 0 {
             alt recv(ctrl) {
               mapper_done { num_mappers -= 1; }
               find_reducer(k, cc) {
-                let c;
+                let mut c;
                 alt reducers.find(str::from_bytes(k)) {
                   some(_c) { c = _c; }
                   none { c = 0; }
index 5dd3ce8de2ce0b7130021bbe95bd3f3ecd7c2fc2..56f4d975b7cec367b5626063214e8b4254343429 100644 (file)
@@ -2,4 +2,4 @@
 
 
 // -*- rust -*-
-fn main() { let x: i32 = -400_i32; x = 0_i32 - x; assert (x == 400_i32); }
+fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; assert (x == 400_i32); }
index 4a51fd58517a7a2de5b9ec0c922cdd1785b5ac39..ddc1f5073ea925b2f86b573ec0907b5f7cea84a6 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn main() {
-    let x: i8 = -12i8;
+    let mut x: i8 = -12i8;
     let y: i8 = -12i8;
     x = x + 1i8;
     x = x - 1i8;
index c37dc989f389b8b057bcf931cf49752c0072e7cf..21c195377c980a0aad70fc62521a74756465717d 100644 (file)
@@ -16,7 +16,7 @@ fn to_str() -> str { "()" }
 }
 impl <T> of map<T> for [T] {
     fn map<U>(f: fn(T) -> U) -> [U] {
-        let r = [];
+        let mut r = [];
         for x in self { r += [f(x)]; }
         r
     }
index 58a6a7321e4f79290b73dc071a78b284b3bd703c..50e7257a6a011f2d1fa43295163c1cf4fdfc68df 100644 (file)
@@ -3,7 +3,7 @@
 import vec::*;
 
 fn main() {
-    let v = from_elem(0u, 0);
+    let mut v = from_elem(0u, 0);
     v += [4, 2];
     assert (reversed(v) == [2, 4]);
 }
index 988cea0042fef63dd1af2251e405fbc67313a20f..a006fea656de7ffe099677276f49f56a3f8bbd59 100644 (file)
@@ -6,11 +6,11 @@
 }
 
 fn main() unsafe {
-    let v: [int] = [];
+    let mut v: [int] = [];
     assert (vec_len(v) == 0u); // zero-length
-    let x = [1, 2];
+    let mut x = [1, 2];
     assert (vec_len(x) == 2u); // on stack
-    let y = [1, 2, 3, 4, 5];
+    let mut y = [1, 2, 3, 4, 5];
     assert (vec_len(y) == 5u); // on heap
 
     v += [];
index 1ec446d09e92f69c47628ab638b9a19cf6073562..7ae714ac060915015f89a914c2607ad107b8283a 100644 (file)
@@ -1,6 +1,6 @@
 fn main () {
-  let line = "";
-  let i = 0;
+  let mut line = "";
+  let mut i = 0;
   do {
     line = if i == 9 { "exit" } else { "notexit" };
     i += 1;
index 0dc78cbaec314e0b4d696e55d6064399d598e9ec..76d26e0b0255407d69513c41c1c56ef757602bd2 100644 (file)
@@ -13,7 +13,7 @@ fn b(c: chan<chan<int>>) {
         spawn {|| b(ch); };
         recv(p);
     }
-    let i = 0;
+    let mut i = 0;
     while i < 100 {
         doit();
         i += 1;
index db54df099672bb8c6d5af16b48684e32224f34c7..af6b55934ebae9bb168ef6ac7566aa1ca53ee783 100644 (file)
@@ -33,16 +33,16 @@ fn test_heap_add() {
 }
 
 fn test_append() {
-    let s = "";
+    let mut s = "";
     s += "a";
     assert (s == "a");
 
-    let s = "a";
+    let mut s = "a";
     s += "b";
     log(debug, s);
     assert (s == "ab");
 
-    let s = "c";
+    let mut s = "c";
     s += "offee";
     assert (s == "coffee");
 
index c82c1eb97e9e9f76ac126a9f2c20b6c0b18b6a06..797049b5d51cfe80db618a25161ad10394c43ab6 100644 (file)
@@ -2,12 +2,12 @@
 
 fn range(a: int, b: int, it: fn(int)) {
     assert (a < b);
-    let i: int = a;
+    let mut i: int = a;
     while i < b { it(i); i += 1; }
 }
 
 fn main() {
-    let sum: int = 0;
+    let mut sum: int = 0;
     range(0, 100) {|x| sum += x; }
     log(debug, sum);
 }
index e79ca8bae38b17496148949e363f779842217691..b0289ceb64da222708fac223d2cd4669a4207118 100644 (file)
@@ -3,7 +3,7 @@
 fn double_int(a: int) -> [int] { ret [a] + [a]; }
 
 fn main() {
-    let d = double(1);
+    let mut d = double(1);
     assert (d[0] == 1);
     assert (d[1] == 1);
 
index dea4e2031a5b9e58054ef19e27c15cdb1c5f0341..2ae8986c7f146758dca6b23a07e3733ead593d03 100644 (file)
@@ -16,7 +16,7 @@ fn main() {
     call_me({|| *q}, q);
 
     // Check that no false positives are found in loops.
-    let q = ~40, p = 10;
+    let mut q = ~40, p = 10;
     loop {
         let i = q;
         p += *i;
index 2639e9e2a0a18049ee7c3d8ea7314a4fb9b3be17..e5d1f814047f4e3dc037e6af9d22f0a2cc056fbc 100644 (file)
@@ -5,7 +5,7 @@
 fn main() {
     let x = 1 == 2 || 3 == 3;
     assert (x);
-    let y: int = 10;
+    let mut y: int = 10;
     log(debug, x || incr(y));
     assert (y == 10);
     if true && x { assert (true); } else { assert (false); }
index 392665eee067150e05802988484a0773ba59952a..dd9cd7b063567f3567f1319067ef4415ac457859 100644 (file)
@@ -2,4 +2,4 @@
 
 fn foo(x: int) { log(debug, x); }
 
-fn main() { let x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); }
+fn main() { let mut x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); }
index 2e6042096187fa174f7a248503c08d25cc734bc3..8651c81a41fc7c30dbd4540e2f7886536cf21a42 100644 (file)
@@ -7,7 +7,7 @@
 fn main() {
     let p = port();
     let ch = chan(p);
-    let y: int;
+    let mut y: int;
 
     task::spawn {|| child(ch); };
     y = recv(p);
index 515b9691b222ca385442c766b1cc755d2ddbf861..1b90eeb3c55601fc7a1c0c9400969fa7418ac6ea 100644 (file)
@@ -2,4 +2,4 @@
 
 enum t { a, b(@int), }
 
-fn main() { let x = b(@10); x = a; }
+fn main() { let mut x = b(@10); x = a; }
index 9a41ef7f084e6abaaf7c4330ed374aaf88a8cbd6..e5bc476cff9cb45aebf770c678cb752a6abe5f7b 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     let u = {x: 10, y: @{a: 20}};
-    let {x: x, y: @{a: a}} = u;
+    let mut {x: x, y: @{a: a}} = u;
     x = 100;
     a = 100;
     assert (x == 100);
index d36551c723e885a1fb8c2eb48522fcd64e46db18..f7025949c2c97681e127e14b9ffa0e87019e4810 100644 (file)
@@ -2,12 +2,12 @@
 
 fn main() {
     let x = [1, 2, 3];
-    let y = 0;
+    let mut y = 0;
     for i: int in x { log(debug, i); y += i; }
     log(debug, y);
     assert (y == 6);
     let s = "hello there";
-    let i: int = 0;
+    let mut i: int = 0;
     for c: u8 in s {
         if i == 0 { assert (c == 'h' as u8); }
         if i == 1 { assert (c == 'e' as u8); }
index 4e68287b18fd2403d987908c638996054ba12cbd..f9c7bfd4c7c50ef658334b06bbf093b4ccf01204 100644 (file)
@@ -1,3 +1,3 @@
 
 
-fn main() { let i: int = 0; while i < 1000000 { i += 1; let x = 3; } }
+fn main() { let mut i: int = 0; while i < 1000000 { i += 1; let x = 3; } }
index 9667c4ca767b299ed1561d3aa436293f53897432..a62526de7da6c9105312ce95ee9e4299bb4cefa1 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
-  let i = 0u;
+  let mut i = 0u;
   loop {
     log(error, "a");
     i += 1u;
@@ -8,7 +8,7 @@ fn main() {
     }
   }
   assert (i == 10u);
-  let is_even = false;
+  let mut is_even = false;
   loop {
     if i == 21u {
         break;
index 85d39ee0bbca66649a2563892b57c91baf46f19f..546679fc3915741980e9d087d31ad547afc39985 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     let x = [10, 20, 30];
-    let sum = 0;
+    let mut sum = 0;
     for x in x { sum += x; }
     assert (sum == 60);
 }
index e5afe657142f58d3a92276b9d10b6cbed591bd79..788c24aa24d27b0221b9d44cb119c27ae23c9eea 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn len(v: [const int]) -> uint {
-    let i = 0u;
+    let mut i = 0u;
     for x: int in v { i += 1u; }
     ret i;
 }
index bdfb6ff8b707bf0ef74d12dfa00395b6ad5e1080..d5a05d47cf066188f1e4525530414da221b59928 100644 (file)
@@ -4,7 +4,7 @@
 
 impl <A> of monad<A> for [A] {
     fn bind<B>(f: fn(A) -> [B]) -> [B] {
-        let r = [];
+        let mut r = [];
         for elt in self { r += f(elt); }
         r
     }
index db67db86626addafa986d4070062aaceee988fd3..ea4f6466ae8dc87e2605cf5afc0d2fa708fd6444 100644 (file)
@@ -10,7 +10,7 @@ fn getbig(&&i: int) {
 }
 
 fn main() {
-    let sz = 400u;
+    let mut sz = 400u;
     while sz < 500u {
         task::try {|| getbig(200) };
         sz += 1u;
index 27351a1f123abc4b02a0dbffc1f8ce8f3e856480..64268bcabaa05353791e086c6f1e5982df973aec 100644 (file)
@@ -1,7 +1,7 @@
 
 fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
     let bar = foo;
-    let y: ~{x: int, y: int, z: int};
+    let mut y: ~{x: int, y: int, z: int};
     if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; }
     ret y.y;
 }
index 9124bd3e0a9655f81879f642c84caf30786beb6f..586fa3c89aa7b47eef7047c2b448c35b9d77316f 100644 (file)
@@ -1,6 +1,6 @@
 fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
     let bar = foo;
-    let y: @{x: int, y: int, z: int};
+    let mut y: @{x: int, y: int, z: int};
     if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; }
     ret y.y;
 }
index 13ff41ba3fb8188e060de578d28512e10a3799e4..f14592a7508df5b9a49ceab5c970bfb11df80549 100644 (file)
@@ -3,7 +3,7 @@
 
 fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
     let bar = foo;
-    let y: ~{x: int, y: int, z: int};
+    let mut y: ~{x: int, y: int, z: int};
     if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; }
     ret y.y;
 }
index eb1e125725c6f62cc4e60d18ebc10eeac38be507..3105a80fea1515d3b2517d9263894bd2a062ddb8 100644 (file)
@@ -3,7 +3,7 @@
 
 fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
     let bar = foo;
-    let y: @{x: int, y: int, z: int};
+    let mut y: @{x: int, y: int, z: int};
     if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; }
     ret y.y;
 }
index 0594ee91fe12f158628c4cae55dde39012cfe366..3930d5371315465a146678568fe1a8432766800a 100644 (file)
@@ -1,7 +1,7 @@
 fn main() {
 
     let y: int = 42;
-    let x: int;
+    let mut x: int;
     x <- y;
     assert (x == 42);
 }
index f0493017671684c2338dc620997405bacf03ec6b..b56f80d9700fcfb3b0f4ea831272964c73b637a1 100644 (file)
@@ -6,7 +6,7 @@
 fn grow(&v: [int]) { v += [1]; }
 
 fn main() {
-    let v: [int] = [];
+    let mut v: [int] = [];
     grow(v);
     grow(v);
     grow(v);
index 29ffe6e4bc0ff6e8e9037ebaee21d7cd354c0b0e..b0493b32c1e56388f1e6730e22c64532976f8f24 100644 (file)
@@ -4,7 +4,7 @@
 fn foo() {
     alt some::<int>(5) {
       some::<int>(x) {
-        let bar;
+        let mut bar;
         alt none::<int> { none::<int> { bar = 5; } _ { baz(); } }
         log(debug, bar);
       }
index 75fb607b866f8935558f77a1274b07d037a41c03..59bbbcf794505a2d4f2f8d73324678f33f8c21ab 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn main() {
-    let x: int = 1;
+    let mut x: int = 1;
     x *= 2;
     log(debug, x);
     assert (x == 2);
index a04b2272e37ff590711c146c48cdfe195b56733b..2f0b41dc0c6c31f65c560908754f7f4a781923a7 100644 (file)
@@ -16,7 +16,7 @@ fn [](x: bool) -> int {
 }
 
 fn main() {
-    let p = {x: 10, y: 20};
+    let mut p = {x: 10, y: 20};
     p += {x: 101, y: 102};
     p -= {x: 100, y: 100};
     assert p + {x: 5, y: 5} == {x: 16, y: 27};
index 41d5b2871b326c6f21e151bad06afc431cbb7886..ae21a487441b6146f355ff9c3819f53f8df07cfc 100644 (file)
 fn ret_ext_ext_mem() -> @{a: @int, b: @int} { ret @{a: @10, b: @10}; }
 
 fn main() {
-    let int_i: int;
-    let ext_i: @int;
-    let int_rec: {a: int, b: int};
-    let ext_rec: @{a: int, b: int};
-    let ext_mem: {a: @int, b: @int};
-    let ext_ext_mem: @{a: @int, b: @int};
+    let mut int_i: int;
+    let mut ext_i: @int;
+    let mut int_rec: {a: int, b: int};
+    let mut ext_rec: @{a: int, b: int};
+    let mut ext_mem: {a: @int, b: @int};
+    let mut ext_ext_mem: @{a: @int, b: @int};
     int_i = ret_int_i(); // initializing
 
     int_i = ret_int_i(); // non-initializing
index b2bea85db4c05a76d6551e994563265b12e5297f..d2824bb73e4ece519eb8538df3a5c490205078e8 100644 (file)
@@ -3,7 +3,7 @@
 
 // Regression test for issue #152.
 fn main() {
-    let b: uint = 1u;
+    let mut b: uint = 1u;
     while b <= 32u {
         0u << b;
         b <<= 1u;
index 8d68a5e7c4c986985d42ad28c3924803511936ae..f277498201da68c9dfc9fda450e3fbd5db5c99c1 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
     let x = true;
-    if x { let i = 10; while i > 0 { i -= 1; } }
+    if x { let mut i = 10; while i > 0 { i -= 1; } }
     alt x { true { #debug("right"); } false { #debug("wrong"); } }
 }
index 46bb11c7839bd6d5d52f4c61ce2bd76626816156..ef7a8ae1ed7aebae17da206e21483b665f879ffb 100644 (file)
@@ -5,7 +5,7 @@ enum int_wrapper {
 fn main() {
     let x = 3;
     let y = int_wrapper_ctor(&x);
-    let z : &int;
+    let mut z : &int;
     alt y {
         int_wrapper_ctor(zz) { z = zz; }
     }
index fd7edefb390538b59eb13f01fca29245a016e43d..7362feaef63afc6254d92ee1d1e0cf50f33cdc2e 100644 (file)
@@ -1,7 +1,7 @@
 // -*- rust -*-
 fn foo(c: [int]) {
     let a: int = 5;
-    let b: [int] = [];
+    let mut b: [int] = [];
 
 
     alt none::<int> {
index e320d1b6d01ecdb0eff2cf91e2d5106f999916b0..7526a7ed169137d5da9f718864b11f83b40c1645 100644 (file)
@@ -1,3 +1,3 @@
 
 
-fn main() { let n; n = 1; log(debug, n); }
+fn main() { let mut n; n = 1; log(debug, n); }
index 92c6613c0fd2abb020551ebc3818f42161abd9bc..a7daf058abec8469ee900d65254881acb1b6be2a 100644 (file)
@@ -13,6 +13,6 @@ fn main() {
     task::spawn {|| x("hello from first spawned fn", 65); };
     task::spawn {|| x("hello from second spawned fn", 66); };
     task::spawn {|| x("hello from third spawned fn", 67); };
-    let i: int = 30;
+    let mut i: int = 30;
     while i > 0 { i = i - 1; #debug("parent sleeping"); yield(); }
 }
index c2b698be1bcd4d29630d3ad38764001bfb7525b2..c7eb7ae4a340cd8803b3fa31b8e41ee0ad8742ec 100644 (file)
@@ -12,7 +12,7 @@ impl baz for str { fn plus() -> int { 200 } }
 impl util for uint {
     fn str() -> str { uint::str(self) }
     fn times(f: fn(uint)) {
-        let c = 0u;
+        let mut c = 0u;
         while c < self { f(c); c += 1u; }
     }
 }
@@ -21,7 +21,7 @@ impl util<T> for [T] {
     fn length() -> uint { vec::len(self) }
     fn iter(f: fn(T)) { for x in self { f(x); } }
     fn map<U>(f: fn(T) -> U) -> [U] {
-        let r = [];
+        let mut r = [];
         for elt in self { r += [f(elt)]; }
         r
     }
@@ -36,7 +36,7 @@ impl foo for int { fn plus() -> int { self + 10 } }
     assert [1].length().str() == "1";
     assert [3, 4].map({|a| a + 4})[0] == 7;
     assert [3, 4].map::<uint>({|a| a as uint + 4u})[0] == 7u;
-    let x = 0u;
+    let mut x = 0u;
     10u.times {|_n| x += 2u;}
     assert x == 20u;
 }
index dd689afff95324ea0379c3b1d23d15e3f1b45f82..03cda225bf6f1cd78a8f0426b77f9e15e6628898 100644 (file)
@@ -5,7 +5,7 @@
 import str;
 
 fn test1() {
-    let s: str = "hello";
+    let mut s: str = "hello";
     s += "world";
     log(debug, s);
     assert (s[9] == 'd' as u8);
index 5c0d34b3501903199dc6abc27d3b1259824b2e83..eca411a35aa14c08e76d016bc806d3fb8dce8662 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn main() {
-    let s = "a";
+    let mut s = "a";
     s += "b";
     assert (s[0] == 'a' as u8);
     assert (s[1] == 'b' as u8);
index c09d6c7cb56bccbaded2150e9ece38492335816f..c293c8741e2830dc6aca5e07de45531c036aafd6 100644 (file)
@@ -3,9 +3,9 @@
 
 fn main() {
     // Make sure we properly handle repeated self-appends.
-    let a: str = "A";
-    let i = 20;
-    let expected_len = 1u;
+    let mut a: str = "A";
+    let mut i = 20;
+    let mut expected_len = 1u;
     while i > 0 {
         log(error, str::len(a));
         assert (str::len(a) == expected_len);
index c9fc58a93aaa7bec42dc81cf3371a5dced076cff..5cab30e86315ba30249847c130ee85be8b5f57a7 100644 (file)
@@ -1 +1,4 @@
-fn main() { let x = 3; let y = 7; x <-> y; assert (x == 7); assert (y == 3); }
+fn main() {
+    let mut x = 3; let mut y = 7;
+    x <-> y; assert (x == 7); assert (y == 3);
+}
index 19c56111b6172f735413d5ee66a2d0d86e69360c..c9a599fb73f76abefda5927f9fe82d38a21e0a82 100644 (file)
@@ -5,7 +5,7 @@ fn main() {
     swap(a, 2, 4);
     assert (a[2] == 4);
     assert (a[4] == 2);
-    let n = 42;
+    let mut n = 42;
     n <-> a[0];
     assert (a[0] == 42);
     assert (n == 0);
index 0d0a70ae816c8d2fa1f31fac560199582997308d..75c282e7a90a5002c7c039d1cd1a9e93999cc486 100644 (file)
@@ -21,7 +21,7 @@ fn test05() {
     let po = comm::port();
     let ch = comm::chan(po);
     task::spawn {|| test05_start(ch); };
-    let value = comm::recv(po);
+    let mut value = comm::recv(po);
     log(error, value);
     value = comm::recv(po);
     log(error, value);
index d3c1d19f3eb0b319fa199382a440bc74fe59dbdb..907b4fc769d01d6668003af88f96e49a6de20732 100644 (file)
@@ -6,8 +6,8 @@ fn start(c: comm::chan<comm::chan<str>>) {
     let p = comm::port();
     comm::send(c, comm::chan(p));
 
-    let a;
-    let b;
+    let mut a;
+    let mut b;
     a = comm::recv(p);
     assert a == "A";
     log(error, a);
index 417d7b38d38f79c40044d9882b202e62d874227c..ba5184570f2da88f5d7806b6ad1f1d3c6f32c091 100644 (file)
@@ -12,7 +12,7 @@ fn test00() {
     task::run(builder) {|| start(i); };
 
     // Sleep long enough for the task to finish.
-    let i = 0;
+    let mut i = 0;
     while i < 10000 {
         task::yield();
         i += 1;
index 5998dd15cf2010974647d44ffa8707efc8f78cff..eb8ffc6b8a83d782b69a980889e0e970999df235 100644 (file)
@@ -4,7 +4,7 @@
 import comm::send;
 
 fn start(c: comm::chan<int>, start: int, number_of_messages: int) {
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages { send(c, start + i); i += 1; }
 }
 
index 48f4ca7a8b24b1d0c6b2ddb3c9af69af240103d1..4a6ae05fccb53be7612f2760c6356c5f89f4c2f5 100644 (file)
@@ -7,7 +7,7 @@ fn main() {
     let ch = comm::chan(po);
 
     // Spawn 10 tasks each sending us back one int.
-    let i = 10;
+    let mut i = 10;
     while (i > 0) {
         log(debug, i);
         task::spawn {|| child(i, ch); };
@@ -18,7 +18,7 @@ fn main() {
     // anything back, so we deadlock here.
 
     i = 10;
-    let value = 0;
+    let mut value = 0;
     while (i > 0) {
         log(debug, i);
         value = comm::recv(po);
index d762b7fca903b4907aa0bedd52988852c2676cd5..952306bebe1b3742027d5841d88ad8a5bf7aee9e 100644 (file)
@@ -4,7 +4,7 @@
 import task;
 
 fn start(c: comm::chan<int>, i0: int) {
-    let i = i0;
+    let mut i = i0;
     while i > 0 {
         comm::send(c, 0);
         i = i - 1;
index ccfcff07aaa84f755915686b05a6d77e4bee389f..b79134505c9b52261bbcb73670a510366277c115 100644 (file)
@@ -15,7 +15,7 @@ fn test_rec() {
     let ch = chan(po);
     let r0: r = {val0: 0, val1: 1u8, val2: '2'};
     send(ch, r0);
-    let r1: r;
+    let mut r1: r;
     r1 = recv(po);
     assert (r1.val0 == 0);
     assert (r1.val1 == 1u8);
@@ -53,7 +53,7 @@ enum t { tag1, tag2(int), tag3(int, u8, char), }
     send(ch, tag2(10));
     send(ch, tag3(10, 11u8, 'A'));
     // FIXME: Do port semantics really guarantee these happen in order?
-    let t1: t;
+    let mut t1: t;
     t1 = recv(po);
     assert (t1 == tag1);
     t1 = recv(po);
@@ -72,7 +72,7 @@ fn test_chan() {
     // Does the transmitted channel still work?
 
     send(ch1, 10);
-    let i: int;
+    let mut i: int;
     i = recv(po0);
     assert (i == 10);
 }
index 0785ecf7aa0a38982e69e1e017c2a4218a5bff89..648b6ba7fa3ead4e2154122e0dadf482dd4676fe 100644 (file)
@@ -9,7 +9,7 @@
 
 fn test00_start(ch: chan<int>, message: int, count: int) {
     #debug("Starting test00_start");
-    let i: int = 0;
+    let mut i: int = 0;
     while i < count {
         #debug("Sending Message");
         send(ch, message + 0);
@@ -27,10 +27,10 @@ fn test00() {
     let po = comm::port();
     let ch = chan(po);
 
-    let i: int = 0;
+    let mut i: int = 0;
 
     // Create and spawn tasks...
-    let results = [];
+    let mut results = [];
     while i < number_of_tasks {
         let builder = task::task_builder();
         results += [task::future_result(builder)];
@@ -41,7 +41,7 @@ fn test00() {
     }
 
     // Read from spawned tasks...
-    let sum = 0;
+    let mut sum = 0;
     for r in results {
         i = 0;
         while i < number_of_messages {
index b27d0669c6143fd0099f54d5d49ead02698b328a..f7de33c63d62d593f2dfac911e18b1cff14046d9 100644 (file)
@@ -5,8 +5,8 @@
 fn main() { test00(); }
 
 fn test00() {
-    let r: int = 0;
-    let sum: int = 0;
+    let mut r: int = 0;
+    let mut sum: int = 0;
     let p = comm::port();
     let c = comm::chan(p);
     send(c, 1);
index bbae3f343a8da7d4dffc59de4f1e944c1a46fc53..a0d4f4595bece7885912817827cd732897c477df 100644 (file)
@@ -5,11 +5,11 @@
 
 fn test00() {
     let r: int = 0;
-    let sum: int = 0;
+    let mut sum: int = 0;
     let p = comm::port();
     let c = comm::chan(p);
     let number_of_messages: int = 1000;
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages { comm::send(c, i + 0); i += 1; }
     i = 0;
     while i < number_of_messages { sum += comm::recv(p); i += 1; }
index 635751091656299e6401b53ce6e98fef2e9f6a02..b363b25e864aab5a90bdf820e947944307b4130a 100644 (file)
@@ -7,15 +7,15 @@
 fn main() { test00(); }
 
 fn test00() {
-    let r: int = 0;
-    let sum: int = 0;
+    let mut r: int = 0;
+    let mut sum: int = 0;
     let p = comm::port();
     let c0 = chan(p);
     let c1 = chan(p);
     let c2 = chan(p);
     let c3 = chan(p);
     let number_of_messages: int = 1000;
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages {
         send(c0, i + 0);
         send(c1, i + 0);
index 64649b85459714859444650bcab17a7c09486a7b..61ce4009c211f1371b15b607ceda8c412d39a0ca 100644 (file)
@@ -5,13 +5,13 @@
 fn main() { test00(); }
 
 fn test00_start(c: comm::chan<int>, start: int, number_of_messages: int) {
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages { comm::send(c, start + i); i += 1; }
 }
 
 fn test00() {
-    let r: int = 0;
-    let sum: int = 0;
+    let mut r: int = 0;
+    let mut sum: int = 0;
     let p = comm::port();
     let number_of_messages: int = 10;
     let c = comm::chan(p);
@@ -29,7 +29,7 @@ fn test00() {
         test00_start(c, number_of_messages * 3, number_of_messages);
     }
 
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages {
         r = comm::recv(p);
         sum += r;
index ff80b5bd4567bfcfb729cce7e600fb55b107800c..4cab65639b17bed98c03f8f4deee8b6667f01f18 100644 (file)
@@ -5,13 +5,13 @@
 fn main() { test00(); }
 
 fn test00_start(c: comm::chan<int>, number_of_messages: int) {
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages { comm::send(c, i + 0); i += 1; }
 }
 
 fn test00() {
     let r: int = 0;
-    let sum: int = 0;
+    let mut sum: int = 0;
     let p = comm::port();
     let number_of_messages: int = 10;
     let ch = comm::chan(p);
@@ -22,7 +22,7 @@ fn test00() {
         test00_start(ch, number_of_messages);
     }
 
-    let i: int = 0;
+    let mut i: int = 0;
     while i < number_of_messages {
         sum += comm::recv(p);
         log(debug, r);
index 925f89ed67dcde8654dcaa9e23fa467290074031..a39d1b6b7fa5d3d3dafc3cf402aebc7d343a7c3d 100644 (file)
@@ -19,7 +19,7 @@ fn main() {
 
 fn test00_start(ch: chan<int>, message: int, count: int) {
     #debug("Starting test00_start");
-    let i: int = 0;
+    let mut i: int = 0;
     while i < count {
         #debug("Sending Message");
         send(ch, message + 0);
@@ -36,16 +36,16 @@ fn test00() {
     let po = port();
     let ch = chan(po);
 
-    let i: int = 0;
+    let mut i: int = 0;
 
-    let results = [];
+    let mut results = [];
     while i < number_of_tasks {
         i = i + 1;
         let builder = task::task_builder();
         results += [task::future_result(builder)];
         task::run(builder) {|| test00_start(ch, i, number_of_messages);}
     }
-    let sum: int = 0;
+    let mut sum: int = 0;
     for r in results {
         i = 0;
         while i < number_of_messages { sum += recv(po); i = i + 1; }
@@ -79,14 +79,14 @@ fn test02() {
 
 fn test04_start() {
     #debug("Started task");
-    let i: int = 1024 * 1024;
+    let mut i: int = 1024 * 1024;
     while i > 0 { i = i - 1; }
     #debug("Finished task");
 }
 
 fn test04() {
     #debug("Spawning lots of tasks.");
-    let i: int = 4;
+    let mut i: int = 4;
     while i > 0 { i = i - 1; task::spawn {|| test04_start(); }; }
     #debug("Finishing up.");
 }
@@ -103,7 +103,7 @@ fn test05() {
     let po = comm::port();
     let ch = chan(po);
     task::spawn {|| test05_start(ch); };
-    let value: int;
+    let mut value: int;
     value = recv(po);
     value = recv(po);
     value = recv(po);
@@ -112,7 +112,7 @@ fn test05() {
 
 fn test06_start(&&task_number: int) {
     #debug("Started task.");
-    let i: int = 0;
+    let mut i: int = 0;
     while i < 1000000 { i = i + 1; }
     #debug("Finished task.");
 }
@@ -121,9 +121,9 @@ fn test06() {
     let number_of_tasks: int = 4;
     #debug("Creating tasks");
 
-    let i: int = 0;
+    let mut i: int = 0;
 
-    let results = [];
+    let mut results = [];
     while i < number_of_tasks {
         i = i + 1;
         let builder = task::task_builder();
index 90c51e984c0c54692aad779731d75dffea95d742..aee8b9ab641817147efbe07d247e72645dcd6746 100644 (file)
@@ -6,7 +6,7 @@
 
 fn test_break() { loop { let x: @int = break; } }
 
-fn test_cont() { let i = 0; while i < 1 { i += 1; let x: @int = cont; } }
+fn test_cont() { let mut i = 0; while i < 1 { i += 1; let x: @int = cont; } }
 
 fn test_ret() { let x: @int = ret; }
 
index 9f4e6e1fdd84fea4e2c5adb2e7c779f706dd9b8f..aa55b47d40dc849d30c4024e0f826840f6e2a28c 100644 (file)
@@ -4,7 +4,7 @@
 import task;
 
 fn main() {
-    let i = 10;
+    let mut i = 10;
     while i > 0 { task::spawn {|| child(i); }; i = i - 1; }
     #debug("main thread exiting");
 }
index 645f6407bfef8d14b92023cb020e14fcd5f69a6c..3e84e34173312e1b259ebda4fc4414a70a6ee4b8 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn range(lo: uint, hi: uint, it: fn(uint)) {
-    let lo_ = lo;
+    let mut lo_ = lo;
     while lo_ < hi { it(lo_); lo_ += 1u; }
 }
 
index ccde41545d9c6c38a8ad2a169d718c5f6022bb52..8c1c3ef7a705d57acee7ecfd93d12f180593f9ee 100644 (file)
@@ -1,9 +1,12 @@
 
 
-fn f() { let x = 10; let y = 11; if true { alt x { _ { y = x; } } } else { } }
+fn f() {
+    let x = 10; let mut y = 11;
+    if true { alt x { _ { y = x; } } } else { }
+}
 
 fn main() {
     let x = 10;
-    let y = 11;
+    let mut y = 11;
     if true { while false { y = x; } } else { }
 }
index d258effa663ba05210b33af10139833e9f5bce71..0606f86dc44a86315061296486449c64760ae98f 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn main() {
-    let word: u32 = 200000u32;
+    let mut word: u32 = 200000u32;
     word = word - 1u32;
     assert (word == 199999u32);
 }
index 91bf0f9945e4c693400b6594bf18ca95baabd9ee..beb4495ad93c843c3c0cf4ebb8958d06fbce696b 100644 (file)
@@ -6,9 +6,9 @@
 // These constants were chosen because they aren't used anywhere
 // in the rest of the generated code so they're easily grep-able.
 fn main() {
-    let x: u8 = 19u8; // 0x13
+    let mut x: u8 = 19u8; // 0x13
 
-    let y: u8 = 35u8; // 0x23
+    let mut y: u8 = 35u8; // 0x23
 
     x = x + 7u8; // 0x7
 
index 66304d3307297d99a275b7512867b1323b5a7a54..671f1aee570deeb713bcefaf51858f854489ba1e 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn main() {
-    let x: u8 = 12u8;
+    let mut x: u8 = 12u8;
     let y: u8 = 12u8;
     x = x + 1u8;
     x = x - 1u8;
index 389480bff1c4752d9dcbd94ff4b524afeeef13f6..2ae6ea8d2893d930df25ded4072a49e88a2a36be 100644 (file)
@@ -1,7 +1,7 @@
 fn main() {
     let i = ~mutable 1;
     // Should be a copy
-    let j;
+    let mut j;
     j = i;
     *i = 2;
     *j = 3;
index 4a3a12cb9cc9389dad814f585ea0c7ecdd918e4a..b8728a10bd8ee9bb3a2a743932db9067cebee4c9 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     let i = ~1;
-    let j = ~2;
+    let mut j = ~2;
     // Should drop the previous value of j
     j = i;
     assert *j == 1;
index 01a057573c8ecddb686d0957d4ded86fe82110ca..282861adcb7daf63ece849a7506abfd2ecd9deed 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
-    let i;
+    let mut i;
     i = ~1;
     assert *i == 1;
 }
\ No newline at end of file
index 7743b4b44a4e1ecc38888ec438c4e6df6834eb6c..8d9386d70fff70d4d3dd6fdd75b1819e8ca39cda 100644 (file)
@@ -3,7 +3,7 @@ fn f(&i: ~int) {
 }
 
 fn main() {
-    let i = ~100;
+    let mut i = ~100;
     f(i);
     assert *i == 200;
 }
\ No newline at end of file
index 0bfba121f52231644bfe098cc6ddc30a6ebf0fb8..677a28293729ec4e45bdfb9c49538bda496a8b6e 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
-    let i;
+    let mut i;
     i <- ~100;
     assert *i == 100;
 }
\ No newline at end of file
index cc7ce4fed691c5b1aeb9092093588454acb18b9e..5dde8eff44e60f08f16c41fcc43e687539f3c945 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     let i = ~100;
-    let j;
+    let mut j;
     j <- i;
     assert *j == 100;
 }
\ No newline at end of file
index 976ca32104e95d3aa60d4233da8f3268b9bd9b91..945bf250af29ec8a7bdc895bc8a4821ee6ce8ebb 100644 (file)
@@ -11,13 +11,13 @@ fn main() {
     let p = comm::port();
     let ch = comm::chan(p);
     let n = 100u;
-    let expected = 0u;
+    let mut expected = 0u;
     uint::range(0u, n) {|i|
         task::spawn {|| child(ch, i); };
         expected += i;
     }
 
-    let actual = 0u;
+    let mut actual = 0u;
     uint::range(0u, n) {|_i|
         let j = comm::recv(p);
         actual += *j;
index d6912e87fb18be9f4f55a1f06f7527510e48f3fb..5b9fb5c036ebdb03ee37c9dbb59125811a54fe3c 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
-    let i = ~100;
-    let j = ~200;
+    let mut i = ~100;
+    let mut j = ~200;
     i <-> j;
     assert i == ~200;
     assert j == ~100;
index 815c760dfaa78b78276a9c3f0bd411741d5081b8..7fb752423497fe49cb099724222423ace931e69d 100644 (file)
@@ -4,4 +4,9 @@
 // -*- rust -*-
 fn f(u: ()) { ret u; }
 
-fn main() { let u1: () = (); let u2: () = f(u1); u2 = (); ret (); }
+fn main() {
+    let u1: () = ();
+    let mut u2: () = f(u1);
+    u2 = ();
+    ret ();
+}
index d229448ce02edc66e7ef78801172624ac7da525a..5b3a65bee01cfba6359a52f6b5305f8926ba6b66 100644 (file)
@@ -40,7 +40,7 @@ fn ret_guard() {
 fn vec_ret() { let _v = [1, 2, ret, 4]; }
 
 fn fail_then_concat() {
-    let x = [], y = [3];
+    let mut x = [], y = [3];
     fail;
     x += y;
     "good" + "bye";
index 579b939ccb43da5ee06d2fc88e1d54563297a3f5..3280e61b855496fca8d3b39125a5252078cd1688 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn foo<T>(o: myoption<T>) -> int {
-    let x: int = 5;
+    let mut x: int = 5;
     alt o { none::<T> { } some::<T>(t) { x += 1; } }
     ret x;
 }
index 24b7e19da5b695bebff27633ccb3154175feee62..283c4c630a380457383919f1b0817505dcd73949 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn foo<T>(o: myoption<T>) -> int {
-    let x: int;
+    let mut x: int;
     alt o { none::<T> { fail; } some::<T>(t) { x = 5; } }
     ret x;
 }
index b2288162bd6bfb3387d8c3b368014c127eaad011..b9f3f5688b66f193c344b1011d20825dacfdfff8 100644 (file)
@@ -30,7 +30,7 @@ fn main() {
     assert (oo as int == 0xd6);
 
     fn check_str_eq(a: str, b: str) {
-        let i: int = 0;
+        let mut i: int = 0;
         for ab: u8 in a {
             log(debug, i);
             log(debug, ab);
index ed3da9bf53b633d5f0b37033bdbf6052196d1c72..99842f2ebc7f187cdf48270810bf2d9aec6f8235 100644 (file)
@@ -19,7 +19,7 @@ fn main() {
     assert (!str::is_utf8([0xc0_u8]));
     assert (!str::is_utf8([0xc0_u8, 0x10_u8]));
 
-    let stack = "a×c€";
+    let mut stack = "a×c€";
     assert (str::pop_char(stack) == '€');
     assert (str::pop_char(stack) == 'c');
     str::push_char(stack, 'u');
index 7835b82c4d7bee8f59ca213d8baa9acd1e14dc68..343004c81c28be78f38cd57f769ea1f413369228 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn main() {
-    let v = [1];
+    let mut v = [1];
     v += [2];
     v += [3];
     v += [4];
index 7c0515ce48b5727651874deb40b9ab196c162d2d..a2571b57b7a1f4f73ce0be4e5a44a7662d672158 100644 (file)
@@ -1 +1 @@
-fn main() { let a = [1, 2, 3, 4, 5]; let b = [a, a]; b += b; }
+fn main() { let a = [1, 2, 3, 4, 5]; let mut b = [a, a]; b += b; }
index 7b27feab6f460178f0965381307a018fde499153..9b97ed092cd66623b531d03e8cb2661478e23299 100644 (file)
@@ -1,7 +1,7 @@
 
 
 fn main() {
-    let later: [int];
+    let mut later: [int];
     if true { later = [1]; } else { later = [2]; }
     log(debug, later[0]);
 }
index bf6b7638eacfe51f2c67314c5f58970eb219b1b3..56661e13a328152af89d5ee17a585edb1f5e9c9c 100644 (file)
@@ -2,4 +2,4 @@
 
 fn push<T: copy>(&v: [const T], t: T) { v += [t]; }
 
-fn main() { let v = [1, 2, 3]; push(v, 1); }
+fn main() { let mut v = [1, 2, 3]; push(v, 1); }
index e8a39b2a0553cedb8da9f191c0c3f495018d2482..e9e6cce4a87798b78733b591d0db394dea341258 100644 (file)
@@ -3,7 +3,7 @@
 
 fn test_heap_to_heap() {
     // a spills onto the heap
-    let a = [0, 1, 2, 3, 4];
+    let mut a = [0, 1, 2, 3, 4];
     a += a;
     assert (vec::len(a) == 10u);
     assert (a[0] == 0);
@@ -20,7 +20,7 @@ fn test_heap_to_heap() {
 
 fn test_stack_to_heap() {
     // a is entirely on the stack
-    let a = [0, 1, 2];
+    let mut a = [0, 1, 2];
     // a spills to the heap
     a += a;
     assert (vec::len(a) == 6u);
@@ -34,9 +34,9 @@ fn test_stack_to_heap() {
 
 fn test_loop() {
     // Make sure we properly handle repeated self-appends.
-    let a: [int] = [0];
-    let i = 20;
-    let expected_len = 1u;
+    let mut a: [int] = [0];
+    let mut i = 20;
+    let mut expected_len = 1u;
     while i > 0 {
         log(error, vec::len(a));
         assert (vec::len(a) == expected_len);
index 95025f5b3cbcb46d5c107a6c5cd6ca46e98cd43b..f1cc97ab61aa0502d7f63b67742d5c094ab33b6e 100644 (file)
@@ -6,7 +6,7 @@ fn main() {
     let v: [int] = [10, 20];
     assert (v[0] == 10);
     assert (v[1] == 20);
-    let x: int = 0;
+    let mut x: int = 0;
     assert (v[x] == 10);
     assert (v[x + 1] == 20);
     x = x + 1;
index af942417ae8790a78d1639762b0ae3a9389ac55a..6da9397044ce3f5381103481f00b561a53fee826 100644 (file)
@@ -36,9 +36,9 @@ fn zombiejesus() {
 }
 
 fn notsure() {
-    let _x;
-    let _y = (_x = 0) == (_x = 0);
-    let _z = (_x <- 0) < (_x = 0);
+    let mut _x;
+    let mut _y = (_x = 0) == (_x = 0);
+    let mut _z = (_x <- 0) < (_x = 0);
     let _a = (_x += 0) == (_x = 0);
     let _b = (_y <-> _z) == (_y <-> _z);
 }
@@ -56,7 +56,7 @@ fn canttouchthis() -> uint {
 
 fn angrydome() {
     loop { if break { } }
-    let i = 0;
+    let mut i = 0;
     do  { i += 1; if i == 1 { alt cont { _ { } } } } while false
 }
 
index 336633623be4273e519370497dbbbd1786458f5c..c0dacbaf54941a24f2ada7a06f52f78766bba295 100644 (file)
@@ -1,8 +1,8 @@
 
 
 fn main() {
-    let x: int = 10;
-    let y: int = 0;
+    let mut x: int = 10;
+    let mut y: int = 0;
     while y < x { log(debug, y); #debug("hello"); y = y + 1; }
     do {
         #debug("goodbye");
index 9054d765e04739cccfa3af11359f2a2efff184fb..24b0d530fc3f42c261366694e5f62ee314d168d9 100644 (file)
@@ -1,6 +1,6 @@
 // Issue #825: Should recheck the loop contition after continuing
 fn main() {
-    let i = 1;
+    let mut i = 1;
     while i > 0 {
         assert (i > 0);
         log(debug, i);
index 4f207a431545d1b02aea735966bc8e24d58c0e8b..2293724739a1a4424439d40932210f763c1a34c4 100644 (file)
@@ -1,8 +1,8 @@
 fn main() {
 
-    let y: int = 42;
-    let z: int = 42;
-    let x: int;
+    let mut y: int = 42;
+    let mut z: int = 42;
+    let mut x: int;
     while z < 50 {
         z += 1;
         while false { x <- y; y = z; }
index b248eb332f675d9e635c3a79736f4fe9e7992b8f..9e4a2a170b7f157610cf5458a1b04d29f3d29c9d 100644 (file)
@@ -3,7 +3,7 @@ enum t { a, b(str), }
 
 fn make(i: int) -> t {
     if i > 10 { ret a; }
-    let s = "hello";
+    let mut s = "hello";
     // Ensure s is non-const.
 
     s += "there";
@@ -11,7 +11,7 @@ fn make(i: int) -> t {
 }
 
 fn main() {
-    let i = 0;
+    let mut i = 0;
 
 
     // The auto slot for the result of make(i) should not leak.
index 2fe5f8b432b1e9525bc925d3a74f5807adb95a08..24907f948dc6092ed4e905c18fc155fdc8f1c378 100644 (file)
@@ -3,7 +3,7 @@
 
 // -*- rust -*-
 fn main() {
-    let i: int = 90;
+    let mut i: int = 90;
     while i < 100 {
         log(debug, i);
         i = i + 1;
index fff85460ee17f4451a23198023c853e86987e271..816b08db72401ebe2d0a9de0df6de4cbf1482d3d 100644 (file)
@@ -7,7 +7,7 @@
 fn f(&p: point) { p.z = 13; }
 
 fn main() {
-    let x: point = {x: 10, y: 11, mutable z: 12};
+    let mut x: point = {x: 10, y: 11, mutable z: 12};
     f(x);
     assert (x.z == 13);
 }
index ba5145870e1764d6c87a8d2959037cc043f38065..a01e311daa870e53aa1d80c6692691609894bd6f 100644 (file)
@@ -2,6 +2,6 @@
 use std;
 
 fn main() {
-    let i: int = 0;
+    let mut i: int = 0;
     while i < 100 { i = i + 1; log(error, i); task::yield(); }
 }