]> git.lizzy.rs Git - rust.git/commitdiff
test: De-mut the test suite. rs=demuting
authorPatrick Walton <pcwalton@mimiga.net>
Sat, 23 Feb 2013 00:08:16 +0000 (16:08 -0800)
committerPatrick Walton <pcwalton@mimiga.net>
Sat, 23 Feb 2013 02:35:01 +0000 (18:35 -0800)
65 files changed:
src/test/auxiliary/issue_3882.rs
src/test/bench/shootout-fasta.rs
src/test/bench/shootout-nbody.rs
src/test/compile-fail/borrowck-assign-comp.rs
src/test/compile-fail/borrowck-call-sendfn.rs
src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs [deleted file]
src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162.rs [deleted file]
src/test/compile-fail/borrowck-mut-field-imm-base.rs [deleted file]
src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs
src/test/compile-fail/borrowck-uniq-via-box.rs
src/test/compile-fail/borrowck-uniq-via-ref.rs
src/test/compile-fail/issue-1451.rs
src/test/compile-fail/issue-3021-b.rs
src/test/compile-fail/issue-3044.rs
src/test/compile-fail/issue-3177-mutable-struct.rs
src/test/compile-fail/issue-3214.rs
src/test/compile-fail/issue-3601.rs
src/test/compile-fail/issue-3973.rs
src/test/compile-fail/mutable-huh-variance-rec.rs
src/test/compile-fail/non-const.rs [deleted file]
src/test/compile-fail/pure-modifies-aliased.rs
src/test/compile-fail/regions-addr-of-self.rs
src/test/compile-fail/regions-addr-of-upvar-self.rs
src/test/compile-fail/regions-glb-free-free.rs
src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs
src/test/compile-fail/regions-infer-paramd-method.rs
src/test/compile-fail/tps-invariant-class.rs
src/test/compile-fail/tps-invariant-enum.rs
src/test/compile-fail/tps-invariant-trait.rs
src/test/pretty/block-disambig.rs
src/test/run-pass-fulldeps/issue-1926.rs
src/test/run-pass/alignment-gep-tup-like-2.rs
src/test/run-pass/alloca-from-derived-tydesc.rs
src/test/run-pass/alt-implicit-copy-unique.rs
src/test/run-pass/argument-passing.rs
src/test/run-pass/binops.rs
src/test/run-pass/borrowck-binding-mutbl.rs
src/test/run-pass/borrowck-newtype-issue-2573.rs
src/test/run-pass/borrowck-root-while-cond-2.rs
src/test/run-pass/borrowck-root-while-cond.rs
src/test/run-pass/boxed-class-type-substitution.rs
src/test/run-pass/cycle-collection2.rs
src/test/run-pass/cycle-collection5.rs
src/test/run-pass/explicit-self.rs
src/test/run-pass/expr-copy.rs
src/test/run-pass/exterior.rs
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-2718.rs
src/test/run-pass/issue-3389.rs
src/test/run-pass/issue-3447.rs
src/test/run-pass/issue-3904.rs
src/test/run-pass/issue-3979-generics.rs
src/test/run-pass/issue-3979-xcrate.rs
src/test/run-pass/issue-3979.rs
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/log-linearized.rs
src/test/run-pass/mlist-cycle.rs
src/test/run-pass/nested-patterns.rs
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/reflect-visit-type.rs
src/test/run-pass/resource-cycle.rs
src/test/run-pass/resource-cycle2.rs
src/test/run-pass/resource-cycle3.rs
src/test/run-pass/trait-cast.rs
src/test/run-pass/writealias.rs

index c2b95e4e7d653e9d18e37c7530cf2164a01c736d..6d232c34b47e033a6a9b0d034d5ba8b0e888e970 100644 (file)
 
 mod issue_3882 {
     struct Completions {
-        mut len: libc::size_t,
+        len: libc::size_t,
     }
     
     extern mod c {
-        fn linenoiseAddCompletion(lc: *Completions);
+        fn linenoiseAddCompletion(lc: *mut Completions);
     }
 }
index da2f2d5c3d2216d26f9c565a4004b9e6bbfc4217..509861e2f470f51b5ee6e4caf0b61001d1e6a9fa 100644 (file)
 fn LINE_LENGTH() -> uint { return 60u; }
 
 struct MyRandom {
-    mut last: u32
+    last: u32
 }
 
-fn myrandom_next(r: @MyRandom, mx: u32) -> u32 {
+fn myrandom_next(r: @mut MyRandom, mx: u32) -> u32 {
     r.last = (r.last * 3877u32 + 29573u32) % 139968u32;
     mx * r.last / 139968u32
 }
@@ -59,7 +59,7 @@ fn bisect(v: ~[AminoAcids], lo: uint, hi: uint, target: u32) -> char {
 
 fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[AminoAcids], n: int) {
     wr.write_line(~">" + id + ~" " + desc);
-    let rng = @MyRandom {mut last: rand::Rng().next()};
+    let rng = @mut MyRandom {last: rand::Rng().next()};
     let mut op: ~str = ~"";
     for uint::range(0u, n as uint) |_i| {
         str::push_char(&mut op, select_random(myrandom_next(rng, 100u32),
index 67d3391ed133620d66d6602521b918a71534c02d..e7b3547ab8c7edede71cff79b07415d4dc52c9d3 100644 (file)
@@ -170,67 +170,80 @@ mod Body {
     // was 4 * PI * PI originally
     pub const DAYS_PER_YEAR: float = 365.24;
 
-    pub struct Props
-        {mut x: float,
-         mut y: float,
-         mut z: float,
-         mut vx: float,
-         mut vy: float,
-         mut vz: float,
-         mass: float}
+    pub struct Props {
+        x: float,
+        y: float,
+        z: float,
+        vx: float,
+        vy: float,
+        vz: float,
+        mass: float
+    }
 
     pub fn jupiter() -> Body::Props {
-        return Props {mut x: 4.84143144246472090e+00,
-             mut y: -1.16032004402742839e+00,
-             mut z: -1.03622044471123109e-01,
-             mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
-             mut vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
-             mut vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
-             mass: 9.54791938424326609e-04 * SOLAR_MASS};
+        return Props {
+            x: 4.84143144246472090e+00,
+            y: -1.16032004402742839e+00,
+            z: -1.03622044471123109e-01,
+            vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
+            vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
+            vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
+            mass: 9.54791938424326609e-04 * SOLAR_MASS
+        };
     }
 
     pub fn saturn() -> Body::Props {
-        return Props {mut x: 8.34336671824457987e+00,
-             mut y: 4.12479856412430479e+00,
-             mut z: -4.03523417114321381e-01,
-             mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
-             mut vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
-             mut vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
-             mass: 2.85885980666130812e-04 * SOLAR_MASS};
+        return Props {
+            x: 8.34336671824457987e+00,
+            y: 4.12479856412430479e+00,
+            z: -4.03523417114321381e-01,
+            vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
+            vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
+            vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
+            mass: 2.85885980666130812e-04 * SOLAR_MASS
+        };
     }
 
     pub fn uranus() -> Body::Props {
-        return Props {mut x: 1.28943695621391310e+01,
-             mut y: -1.51111514016986312e+01,
-             mut z: -2.23307578892655734e-01,
-             mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
-             mut vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
-             mut vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
-             mass: 4.36624404335156298e-05 * SOLAR_MASS};
+        return Props {
+            x: 1.28943695621391310e+01,
+            y: -1.51111514016986312e+01,
+            z: -2.23307578892655734e-01,
+            vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
+            vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
+            vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
+            mass: 4.36624404335156298e-05 * SOLAR_MASS
+        };
     }
 
     pub fn neptune() -> Body::Props {
-        return Props {mut x: 1.53796971148509165e+01,
-             mut y: -2.59193146099879641e+01,
-             mut z: 1.79258772950371181e-01,
-             mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
-             mut vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
-             mut vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
-             mass: 5.15138902046611451e-05 * SOLAR_MASS};
+        return Props {
+            x: 1.53796971148509165e+01,
+            y: -2.59193146099879641e+01,
+            z: 1.79258772950371181e-01,
+            vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
+            vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
+            vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
+            mass: 5.15138902046611451e-05 * SOLAR_MASS
+        };
     }
 
     pub fn sun() -> Body::Props {
-        return Props {mut x: 0.0,
-             mut y: 0.0,
-             mut z: 0.0,
-             mut vx: 0.0,
-             mut vy: 0.0,
-             mut vz: 0.0,
-             mass: SOLAR_MASS};
+        return Props {
+            x: 0.0,
+            y: 0.0,
+            z: 0.0,
+            vx: 0.0,
+            vy: 0.0,
+            vz: 0.0,
+            mass: SOLAR_MASS
+        };
     }
 
     pub fn offset_momentum(props: &mut Body::Props,
-                       px: float, py: float, pz: float) {
+                           px: float,
+                           py: float,
+                           pz: float) {
         props.vx = -px / SOLAR_MASS;
         props.vy = -py / SOLAR_MASS;
         props.vz = -pz / SOLAR_MASS;
index f5597859433b3b2ced6a0f47c305b79543adc559..283f04a283f4e042e13cab03c136a0a7c99cc1a5 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct point {x: int, mut y: int }
+struct point { x: int, y: int }
 
 fn a() {
     let mut p = point {x: 3, y: 4};
@@ -20,22 +20,13 @@ fn a() {
     p.x = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
 }
 
-fn b() {
-    let mut p = point {x: 3, mut y: 4};
-    // This assignment is legal because `y` is inherently mutable (and
-    // hence &_q.y is &mut int).
-    let _q = &p;
-
-    p.y = 5;
-}
-
 fn c() {
     // this is sort of the opposite.  We take a loan to the interior of `p`
     // and then try to overwrite `p` as a whole.
 
-    let mut p = point {x: 3, mut y: 4};
+    let mut p = point {x: 3, y: 4};
     let _q = &p.y; //~ NOTE loan of mutable local variable granted here
-    p = point {x: 5, mut y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
+    p = point {x: 5, y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
     copy p;
 }
 
@@ -43,7 +34,7 @@ fn d() {
     // just for completeness's sake, the easy case, where we take the
     // address of a subcomponent and then modify that subcomponent:
 
-    let mut p = point {x: 3, mut y: 4};
+    let mut p = point {x: 3, y: 4};
     let _q = &p.y; //~ NOTE loan of mutable field granted here
     p.y = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
     copy p;
index c83f9230dbb996f57ac24eff79e42097630f2c77..51047631ea6655e1646c37d648a93ea2e1774d5b 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-test #2978
 
-fn call(x: @{mut f: fn~()}) {
+fn call(x: @{f: fn~()}) {
     x.f(); //~ ERROR foo
     //~^ NOTE bar
 }
diff --git a/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs b/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs
deleted file mode 100644 (file)
index 64baf3a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
-    uint::range(0, x.len(), |i| op(&x[i]));
-}
-
-struct A {
-    mut a: int
-}
-
-fn main() {
-    let x = [A {mut a: 0}];
-    for each(x) |y| {
-        let z = &y.a; //~ ERROR illegal borrow unless pure
-        x[0].a = 10; //~ NOTE impure due to assigning to mutable field
-        log(error, z);
-    }
-}
diff --git a/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162.rs b/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162.rs
deleted file mode 100644 (file)
index a14fd18..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
-    uint::range(0, x.len(), |i| op(&x[i]));
-}
-
-fn main() {
-    struct A {
-        mut a: int
-    }
-    let x = ~[A {mut a: 0}];
-    for each(x) |y| {
-        let z = &y.a; //~ ERROR illegal borrow unless pure
-        x[0].a = 10; //~ NOTE impure due to assigning to mutable field
-        log(error, z);
-    }
-}
diff --git a/src/test/compile-fail/borrowck-mut-field-imm-base.rs b/src/test/compile-fail/borrowck-mut-field-imm-base.rs
deleted file mode 100644 (file)
index 685efca..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct Foo {
-    mut x: uint
-}
-
-struct Bar {
-    foo: Foo
-}
-
-fn main() {
-    let mut b = Bar { foo: Foo { x: 3 } };
-    let p = &b;
-    let q = &mut b.foo.x;
-    let r = &p.foo.x; //~ ERROR illegal borrow unless pure
-    let s = &b.foo.x; //~ ERROR loan of mutable field as immutable conflicts with prior loan
-    io::println(fmt!("*r = %u", *r));
-    io::println(fmt!("*r = %u", *s));
-    *q += 1;
-    io::println(fmt!("*r = %u", *r));
-    io::println(fmt!("*r = %u", *s));
-}
index e7cbab41079843528ccbf7d66d1807fb9bc9fbe8..4af3bc17240ce166f76af5da675d2a09cac06bdd 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct node_ {
-    mut a: ~cycle
+    a: ~cycle
 }
 
 enum cycle {
@@ -17,11 +17,11 @@ enum cycle {
     empty
 }
 fn main() {
-    let x = ~node(node_ {mut a: ~empty});
+    let mut x = ~node(node_ {a: ~empty});
     // Create a cycle!
-    match *x { //~ NOTE loan of immutable local variable granted here
-      node(ref y) => {
-        y.a = x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
+    match *x { //~ NOTE loan of mutable local variable granted here
+      node(ref mut y) => {
+        y.a = x; //~ ERROR moving out of mutable local variable prohibited due to outstanding loan
       }
       empty => {}
     };
index e4b8214fb984cf31b14efd9e3dad7529266dc01d..9a63c8698c65af004ce6e9addd92ccb7c6e16213 100644 (file)
@@ -14,10 +14,6 @@ fn box_mut(v: @mut ~int) {
     borrow(*v); //~ ERROR illegal borrow unless pure
 }
 
-fn box_rec_mut(v: @{mut f: ~int}) {
-    borrow(v.f); //~ ERROR illegal borrow unless pure
-}
-
 fn box_mut_rec(v: @mut {f: ~int}) {
     borrow(v.f); //~ ERROR illegal borrow unless pure
 }
@@ -42,14 +38,6 @@ fn box_const(v: @const ~int) {
     borrow(*v); //~ ERROR illegal borrow unless pure
 }
 
-fn box_rec_const(v: @{const f: ~int}) {
-    borrow(v.f); //~ ERROR illegal borrow unless pure
-}
-
-fn box_recs_const(v: @{f: {g: {const h: ~int}}}) {
-    borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
-}
-
 fn box_const_rec(v: @const {f: ~int}) {
     borrow(v.f); //~ ERROR illegal borrow unless pure
 }
index 48d39c39e5a47df00f59afd5261bedee927934dd..8d6e7039057f68995943e2d0912f7c7d0220e25e 100644 (file)
@@ -14,10 +14,6 @@ fn box_mut(v: &mut ~int) {
     borrow(*v); // OK: &mut -> &imm
 }
 
-fn box_rec_mut(v: &{mut f: ~int}) {
-    borrow(v.f); //~ ERROR illegal borrow unless pure
-}
-
 fn box_mut_rec(v: &mut {f: ~int}) {
     borrow(v.f); // OK: &mut -> &imm
 }
@@ -42,14 +38,6 @@ fn box_const(v: &const ~int) {
     borrow(*v); //~ ERROR illegal borrow unless pure
 }
 
-fn box_rec_const(v: &{const f: ~int}) {
-    borrow(v.f); //~ ERROR illegal borrow unless pure
-}
-
-fn box_recs_const(v: &{f: {g: {const h: ~int}}}) {
-    borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
-}
-
 fn box_const_rec(v: &const {f: ~int}) {
     borrow(v.f); //~ ERROR illegal borrow unless pure
 }
index 62bc322f41600343602041f27c83ab070906f5e1..2e80a7b09defa4579cb1937a6b12924a855b5ebc 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 // xfail-test
-type T = { mut f: fn@() };
-type S = { f: fn@() };
+struct T { f: fn@() };
+struct S { f: fn@() };
 
 fn fooS(t: S) {
 }
@@ -23,11 +23,11 @@ fn bar() {
 
 fn main() {
     let x: fn@() = bar;
-    fooS({f: x});
-    fooS({f: bar});
+    fooS({f: x});
+    fooS({f: bar});
 
     let x: fn@() = bar;
-    fooT({mut f: x});
-    fooT({mut f: bar});
+    fooT(T {f: x});
+    fooT(T {f: bar});
 }
 
index 09454d4326ab7cc116b4c617db1ba01be95624ad..a782dd58ee671175b5f2da93684e763f155af4d9 100644 (file)
 fn siphash(k0 : u64) {
 
     struct siphash {
-        mut v0: u64,
+        v0: u64,
     }
 
     impl siphash {
-        fn reset() {
+        fn reset(&mut self) {
            self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
            //~^ ERROR unresolved name: k0
         }
index 46ad7f64589446816ca5dd09533a0dfaaab4fe5d..fcd5b1deee5525d3620deff7813b446bdcf3f393 100644 (file)
 fn main() {
     let needlesArr: ~[char] = ~['a', 'f'];
     do vec::foldr(needlesArr) |x, y| {
-        //~^ ERROR 2 parameters were supplied (including the closure passed by the `do` keyword)
-        //~^^ ERROR Unconstrained region variable #2
-        //
-        // this last error is, um, non-ideal.
+        //~^ ERROR Unconstrained region variable #2
     }
+    //~^ ERROR 2 parameters were supplied (including the closure passed by the `do` keyword)
+    //
+    // the first error is, um, non-ideal.
 }
 
index ab28b461a2c6b4e5ecfb3c8a301b485e84e9a304..31c0dc7d9c4e2a0a9ecf6f4518fb42ae996f9483 100644 (file)
@@ -12,7 +12,7 @@
 // error-pattern: instantiating a type parameter with an incompatible type
 struct S<T:Const> {
     s: T,
-    mut cant_nest: ()
+    cant_nest: ()
 }
 
 fn main() {
index ff19551896b860b4b1af111bd37f88084d3b8a9d..2dd58906ddb713ff8fc2ee5160fd793e0e2c05c9 100644 (file)
@@ -10,7 +10,7 @@
 
 fn foo<T>() {
     struct foo {
-        mut x: T, //~ ERROR attempt to use a type argument out of scope
+        x: T, //~ ERROR attempt to use a type argument out of scope
         //~^ ERROR use of undeclared type name
     }
 
index 40d65938795ff3e1f7f77ea9bca721a719c70d99..3dd070b44a04c39b34a15bca6a5d8e53e03f6313 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-test
 struct HTMLImageData {
-    mut image: Option<~str>
+    image: Option<~str>
 }
 
 struct ElementData {
@@ -30,7 +30,7 @@ enum NodeData = {
 };
 
 fn main() {
-    let id = HTMLImageData { image: None };
+    let mut id = HTMLImageData { image: None };
     let ed = ElementData { kind: ~HTMLImageElement(id) };
     let n = NodeData({kind : ~Element(ed)});
     match n.kind {
index 812e0fc8c9660da6e00b9dbb857ff287a4a5aebe..19244d24bcc71e565f4838ff7b88044f362d90bc 100644 (file)
@@ -11,8 +11,8 @@
 // xfail-test
 
 struct Point {
-    mut x: float,
-    mut y: float,
+    x: float,
+    y: float,
 }
 
 impl ToStr for Point { //~ ERROR implements a method not defined in the trait
index 1ee2bb18321c3b536f49aa6c9d287ee8aa350098..6d79e23e999a7893da0d4679d36c36ac96dc4133 100644 (file)
 
 // error-pattern: mismatched types
 
+struct S {
+    g: ~[int]
+}
+
 fn main() {
-    let v = {mut g: ~[0]};
+    let v = S {g: ~[0]};
 
-    fn f(&&v: {mut g: ~[const int]}) {
-        v.g = ~[mut 3]
+    fn f(&&v: {g: ~[const int]}) {
+        v.g = ~[3]
     }
 
     f(v);
diff --git a/src/test/compile-fail/non-const.rs b/src/test/compile-fail/non-const.rs
deleted file mode 100644 (file)
index 3b6522c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that various non const things are rejected.
-
-fn foo<T:Const>(_x: T) { }
-
-struct r {
-  x:int,
-}
-
-impl Drop for r {
-    fn finalize(&self) {}
-}
-
-fn r(x:int) -> r {
-    r {
-        x: x
-    }
-}
-
-struct r2 {
-  x:@mut int,
-}
-
-impl Drop for r2 {
-    fn finalize(&self) {}
-}
-
-fn r2(x:@mut int) -> r2 {
-    r2 {
-        x: x
-    }
-}
-
-fn main() {
-    struct A<T> { f: T }
-    struct B<T> { mut f: T }
-
-    foo(A {f: 3});
-    foo(B {mut f: 3}); //~ ERROR does not fulfill `Const`
-    foo(~[1]);
-    foo(~[mut 1]); //~ ERROR does not fulfill `Const`
-    foo(~1);
-    foo(~mut 1); //~ ERROR does not fulfill `Const`
-    foo(@1);
-    foo(@mut 1); //~ ERROR does not fulfill `Const`
-    foo(r(1)); // this is okay now.
-    foo(r2(@mut 1)); //~ ERROR does not fulfill `Const`
-    foo(A {f: B {mut f: 1}}); //~ ERROR does not fulfill `Const`
-}
index 90c507091e93292bd24bc1a8c9464f7df8e45dfb..2aa81dd4fa21e7658774a8cb2e436399df378e51 100644 (file)
 
 // Check that pure functions cannot modify aliased state.
 
-pure fn modify_in_ref(&&sum: {mut f: int}) {
-    sum.f = 3; //~ ERROR assigning to mutable field prohibited in pure context
+struct S {
+    f: int,
 }
 
-pure fn modify_in_box(sum: @mut {f: int}) {
+pure fn modify_in_box(sum: @mut S) {
     sum.f = 3; //~ ERROR assigning to mutable field prohibited in pure context
 }
 
 trait modify_in_box_rec {
-    pure fn modify_in_box_rec(sum: @{mut f: int});
+    pure fn modify_in_box_rec(sum: @mut S);
 }
 
 impl modify_in_box_rec for int {
-    pure fn modify_in_box_rec(sum: @{mut f: int}) {
+    pure fn modify_in_box_rec(sum: @mut S) {
         sum.f = self; //~ ERROR assigning to mutable field prohibited in pure context
     }
 }
index 2b52200908338f87aaf3cd83974208f33e359fb0..c6c89a3ae04a7cb74a1858c8c182c64b9aeb1a44 100644 (file)
@@ -9,16 +9,16 @@
 // except according to those terms.
 
 struct dog {
-    mut cats_chased: uint,
+    cats_chased: uint,
 }
 
 impl dog {
-    fn chase_cat() {
-        let p: &static/mut uint = &mut self.cats_chased; //~ ERROR illegal borrow
+    fn chase_cat(&mut self) {
+        let p: &static/mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
         *p += 1u;
     }
 
-    fn chase_cat_2() {
+    fn chase_cat_2(&mut self) {
         let p: &blk/mut uint = &mut self.cats_chased;
         *p += 1u;
     }
@@ -31,7 +31,7 @@ fn dog() -> dog {
 }
 
 fn main() {
-    let d = dog();
+    let mut d = dog();
     d.chase_cat();
     debug!("cats_chased: %u", d.cats_chased);
 }
index cf026785420d7a0c99d2f152a762b9e4a1478039..8e98d4341a8b33553ff82270ecb51d8744589261 100644 (file)
@@ -9,13 +9,13 @@
 // except according to those terms.
 
 struct dog {
-    mut food: uint,
+    food: uint,
 }
 
 impl dog {
-    fn chase_cat() {
+    fn chase_cat(&mut self) {
         for uint::range(0u, 10u) |_i| {
-            let p: &'static mut uint = &mut self.food; //~ ERROR illegal borrow
+            let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
             *p = 3u;
         }
     }
index a8bbc24ffd47587f624a9d99b9e8b4a1bc6c4982..f9ea3c6f933a3f5fbeed89f8f648cbaa18ecc778 100644 (file)
@@ -17,7 +17,7 @@ pub struct Flag {
         name: &str,
         desc: &str,
         max_count: uint,
-        mut value: uint
+        value: uint
     }
 
     pub fn flag(name: &r/str, desc: &r/str) -> Flag/&r {
index fabce969b9c3ffd59a0e8c42b6ab3332c74d1ee4..bdd9b372e4ef61c1f3aff3c17415325e85e38fd5 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct invariant {
-    mut f: &int
+    f: &int
 }
 
 fn to_same_lifetime(bi: invariant/&r) {
@@ -17,8 +17,8 @@ fn to_same_lifetime(bi: invariant/&r) {
 }
 
 fn to_shorter_lifetime(bi: invariant/&r) {
-    let bj: invariant/&blk = bi; //~ ERROR mismatched types
-}
+    let bj: invariant/&blk = bi;
+}   
 
 fn to_longer_lifetime(bi: invariant/&r) -> invariant/&static {
     bi //~ ERROR mismatched types
index a75e1deb6a2a320fefb6ce6bef64d57002a76e89..0f1b23b2839c6ee0e76512eefa1ffd7c83358b3b 100644 (file)
@@ -17,14 +17,16 @@ trait foo {
     fn any_int() -> &int;
 }
 
-type with_foo = {mut f: foo};
+struct with_foo {
+    f: foo
+}
 
 trait set_foo_foo {
-    fn set_foo(f: foo);
+    fn set_foo(&mut self, f: foo);
 }
 
 impl set_foo_foo for with_foo {
-    fn set_foo(f: foo) {
+    fn set_foo(&mut self, f: foo) {
         self.f = f; //~ ERROR mismatched types: expected `@foo/&self` but found `@foo/&`
     }
 }
@@ -35,14 +37,16 @@ trait bar {
     fn any_int() -> &int;
 }
 
-type with_bar = {mut f: bar};
+struct with_bar {
+    f: bar
+}
 
 trait set_foo_bar {
-    fn set_foo(f: bar);
+    fn set_foo(&mut self, f: bar);
 }
 
 impl set_foo_bar for with_bar {
-    fn set_foo(f: bar) {
+    fn set_foo(&mut self, f: bar) {
         self.f = f;
     }
 }
index c1a0b2209711c0783d78ba3ba11c2a5277aa15b0..0411eeb05ebe1de6114cc8e324d0591e75a5c211 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct box_impl<T> {
-    mut f: T,
+    f: T,
 }
 
 fn box_impl<T>(f: T) -> box_impl<T> {
index ead155320b81c55b54a9f332572941ecbf76d483..967b201908c4b435d75f2676bf4896cf3145c89c 100644 (file)
@@ -9,8 +9,9 @@
 // except according to those terms.
 
 struct box<T> {
-    mut f: T
+    f: T
 }
+
 enum box_impl<T> = box<T>;
 
 fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
@@ -18,12 +19,12 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
 }
 
 fn main() {
-    let b = box_impl::<@int>(box::<@int> {mut f: @3});
+    let b = box_impl::<@int>(box::<@int> {f: @3});
     set_box_impl(b, @mut 5);
     //~^ ERROR values differ in mutability
 
     // No error when type of parameter actually IS @const int
     let x: @const int = @3; // only way I could find to upcast
-    let b = box_impl::<@const int>(box::<@const int>{mut f: x});
+    let b = box_impl::<@const int>(box::<@const int>{f: x});
     set_box_impl(b, @mut 5);
 }
index adf822328988760e9e11bd3685631b171b77a9a9..60da6d2208a833a4dccac69208a0908314b45831 100644 (file)
@@ -14,7 +14,7 @@ trait box_trait<T> {
 }
 
 struct box<T> {
-    mut f: T
+    f: T
 }
 
 enum box_impl<T> = box<T>;
@@ -33,7 +33,7 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
 }
 
 fn main() {
-    let b = box_impl::<@int>(box::<@int> {mut f: @3});
+    let b = box_impl::<@int>(box::<@int> {f: @3});
     set_box_trait(b as box_trait::<@int>, @mut 5);
     //~^ ERROR values differ in mutability
     set_box_impl(b, @mut 5);
index 17a2db5d1f067744b56de699e4b2698445049c4e..5cc8f6e6edc580ab0cb2258b1b4a96ddca4f34b7 100644 (file)
 
 fn test2() -> int { let val = @0; { } *val }
 
-struct S { mut eax: int }
+struct S { eax: int }
 
 fn test3() {
-    let regs = @S {mut eax: 0};
+    let regs = @mut S {eax: 0};
     match true { true => { } _ => { } }
     (*regs).eax = 1;
 }
index 7d52f13b0750ad6000245f2644548ad2b7f382ad..95a80630d7c6d9cab8d35463c870e90aa7c1e155 100644 (file)
 fn new_parse_sess() -> parser::parse_sess {
     let cm = codemap::new_codemap();
     let handler = diagnostic::mk_handler(option::none);
-    let sess = @{
+    let sess = @mut {
         cm: cm,
-        mut next_id: 1,
+        next_id: 1,
         span_diagnostic: diagnostic::mk_span_handler(handler, cm),
-        mut chpos: 0u,
-        mut byte_pos: 0u
+        chpos: 0u,
+        byte_pos: 0u
     };
     return sess;
 }
index 2a09de7a81c222276db78fbda0c194fc58ddeaa0..2f008e51586950b51065fcead4571be20a9fd9da 100644 (file)
@@ -15,11 +15,11 @@ struct Pair<A,B> {
 enum RecEnum<A> = Rec<A>;
 struct Rec<A> {
     val: A,
-    mut rec: Option<@RecEnum<A>>
+    rec: Option<@mut RecEnum<A>>
 }
 
 fn make_cycle<A:Copy>(a: A) {
-    let g: @RecEnum<A> = @RecEnum(Rec {val: a, mut rec: None});
+    let g: @mut RecEnum<A> = @mut RecEnum(Rec {val: a, rec: None});
     g.rec = Some(g);
 }
 
index 37fdfca4468ce79c0feb92bfe8dcec39112dc39d..ddaa38223ecae07a9cb723c0ac9dc1d47d2575d3 100644 (file)
@@ -10,8 +10,8 @@
 
 enum option<T> { some(T), none, }
 
-struct R<T> {mut v: ~[option<T>]}
+struct R<T> {v: ~[option<T>]}
 
 fn f<T>() -> ~[T] { return ~[]; }
 
-pub fn main() { let r: R<int> = R {mut v: ~[]}; r.v = f(); }
+pub fn main() { let mut r: R<int> = R {v: ~[]}; r.v = f(); }
index 58076b59cebfbeb88589bcb451b57ced0cfa5839..e73eb57d607c1fc7891e009689e224d0b32ff838 100644 (file)
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct Pair { mut a: ~int, mut b: ~int }
+struct Pair { a: ~int, b: ~int }
 
 pub fn main() {
-    let x = ~Pair {mut a: ~10, b: ~20};
+    let mut x = ~Pair {a: ~10, b: ~20};
     match x {
-      ~Pair {a: ref mut a, b: ref b} => {
+      ~Pair {a: ref mut a, b: ref mut b} => {
         assert **a == 10; *a = ~30; assert **a == 30;
       }
     }
index 89c86c1cf430f820f959efdf6015e99c953d153a..95c23753c27e41128b4fc2e245286c0545d63dc0 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-fast
 
-struct X { mut x: int }
+struct X { x: int }
 
 fn f1(a: &mut X, b: &mut int, -c: int) -> int {
     let r = a.x + *b + c;
@@ -19,13 +19,13 @@ fn f1(a: &mut X, b: &mut int, -c: int) -> int {
     return r;
 }
 
-fn f2(a: int, f: fn(int)) -> int { f(1); return a; }
+fn f2(a: int, f: &fn(int)) -> int { f(1); return a; }
 
 pub fn main() {
-    let mut a = X {mut x: 1}, b = 2, c = 3;
+    let mut a = X {x: 1}, b = 2, c = 3;
     assert (f1(&mut a, &mut b, c) == 6);
     assert (a.x == 0);
     assert (b == 10);
-    assert (f2(a.x, |x| a.x = 50 ) == 0);
+    assert (f2(a.x, |x| a.x = 50) == 0);
     assert (a.x == 50);
 }
index 99379813840ffbf30533ccc97a26466eda8d7a71..2044a5c2346b4ef4182b84293d0cbcc9ab2784e4 100644 (file)
@@ -86,9 +86,10 @@ fn test_ptr() {
     pub fn get_task_id() -> libc::intptr_t;
 }
 
+#[deriving_eq]
 struct p {
-  mut x: int,
-  mut y: int,
+  x: int,
+  y: int,
 }
 
 fn p(x: int, y: int) -> p {
@@ -98,16 +99,9 @@ fn p(x: int, y: int) -> p {
     }
 }
 
-impl cmp::Eq for p {
-    pure fn eq(&self, other: &p) -> bool {
-        (*self).x == (*other).x && (*self).y == (*other).y
-    }
-    pure fn ne(&self, other: &p) -> bool { !(*self).eq(other) }
-}
-
 fn test_class() {
-  let q = p(1, 2);
-  let r = p(1, 2);
+  let mut q = p(1, 2);
+  let mut r = p(1, 2);
   
   unsafe {
   error!("q = %x, r = %x",
index 6e8b35f76788d2f049889a714b61bd5dbdff8187..377ed2608e51329b293c5dbe631391d9db34daef 100644 (file)
@@ -8,13 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct F { mut f: ~[int] }
+struct F { f: ~[int] }
 
 fn impure(_v: &[int]) {
 }
 
 pub fn main() {
-    let x = F {f: ~[3]};
+    let mut x = F {f: ~[3]};
 
     match x {
       F {f: ref mut v} => {
index 5dc373aa50fef1b9b49928f654725ab28d8aa62a..7e81345739f64b0a3d41bc83ab11f89cd5519079 100644 (file)
@@ -8,9 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-enum foo = {mut bar: baz};
+struct foo {bar: baz}
 
-enum baz = @{mut baz: int};
+struct baz_ {baz: int}
+
+type baz = @mut baz_;
 
 trait frob {
     fn frob();
index 5b2232daa4a1d554c761da70b60099b1be391e2d..ea165e53ceb1ad797cedeae3cd5c711c18ea04c8 100644 (file)
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct F { mut f: @G }
+struct F { f: @G }
 struct G { g: ~[int] }
 
 pub fn main() {
-    let rec = @F {mut f: @G {g: ~[1, 2, 3]}};
+    let rec = @mut F {f: @G {g: ~[1, 2, 3]}};
     while rec.f.g.len() == 23 {}
 }
index 432847cc1983c725cfda64e3a0ce2bd3c2962643..285796db20e66d2aa5bae68664820923343fc200 100644 (file)
@@ -10,9 +10,9 @@
 
 fn borrow<T>(x: &r/T) -> &r/T {x}
 
-struct Rec { mut f: @int }
+struct Rec { f: @int }
 
 pub fn main() {
-    let rec = @Rec {mut f: @22};
+    let rec = @mut Rec {f: @22};
     while *borrow(rec.f) == 23 {}
 }
index 4fe553ec03958d9296468a499ecb96996a978347..025bf8fd9d94f6fab39dcc750961d97412ff6523 100644 (file)
@@ -12,7 +12,7 @@
 // the boxed type parameter
 
 type Tree<T> = {
-    mut parent: Option<T>,
+    parent: Option<T>,
 };
 
 fn empty<T>() -> Tree<T> { fail!() }
@@ -28,7 +28,7 @@ fn Box() -> Box {
 }
 
 enum layout_data = {
-    mut box: Option<@Box>
+    box: Option<@Box>
 };
 
 pub fn main() { }
index 127a1c970389605db28749fd4efd4609b0b73f2d..125c3ba1027b7669cead13556d53554f5e6f2f4b 100644 (file)
@@ -8,13 +8,13 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct foo { mut z : fn@() }
+struct foo { z: fn@() }
 
 fn nop() { }
-fn nop_foo(_x : @foo) { }
+fn nop_foo(_x : @mut foo) { }
 
 pub fn main() {
-    let w = @foo{ mut z: || nop() };
-    let x : fn@() = || nop_foo(w);
+    let w = @mut foo{ z: || nop() };
+    let x: fn@() = || nop_foo(w);
     w.z = x;
 }
index 6f3297c6602729c26baa7a9a50d636b5f0359562..fe0d294f01a7adbabf8d8f1036e4fd381f86dfca 100644 (file)
@@ -8,15 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct foo { mut z : fn@() }
+struct foo { z: fn@() }
 
 fn nop() { }
-fn nop_foo(_y: @int, _x : @foo) { }
+fn nop_foo(_y: @int, _x: @mut foo) { }
 
 fn o() -> @int { @10 }
 
 pub fn main() {
-    let w = @foo { mut z: || nop() };
+    let w = @mut foo { z: || nop() };
     let x : fn@() = || nop_foo(o(), w);
     w.z = x;
 }
index f162a1bc48a6a20ceaf9298f55c0179d24908087..26e2023e89c50ba75c0e57810fe0f1097b9ac2d1 100644 (file)
@@ -46,7 +46,7 @@ struct thing {
     x: A
 }
 
-struct A { mut a: @int }
+struct A { a: @int }
 
 fn thing(x: A) -> thing {
     thing {
@@ -67,14 +67,14 @@ impl Nus for thing { fn f(&self) {} }
 
 pub fn main() {
 
-    let x = @thing(A {mut a: @10});
+    let x = @thing(A {a: @10});
     assert x.foo() == 10;
     assert x.quux() == 10;
 
-    let y = ~thing(A {mut a: @10});
+    let y = ~thing(A {a: @10});
     assert (copy y).bar() == 10;
     assert y.quux() == 10;
 
-    let z = thing(A {mut a: @11});
+    let z = thing(A {a: @11});
     assert z.spam() == 11;
 }
index 21080280d2c4c10886678f0756f984080dce2b16..2d370bada286cb32285670340c48c2614852f36b 100644 (file)
 
 // xfail-fast
 
-fn f(arg: &A) {
+fn f(arg: &mut A) {
     arg.a = 100;
 }
 
-struct A { mut a: int }
+struct A { a: int }
 
 pub fn main() {
-    let x = A {a: 10};
-    f(&x);
+    let mut x = A {a: 10};
+    f(&mut x);
     assert x.a == 100;
     x.a = 20;
-    f(&copy x);
+    let mut y = copy x;
+    f(&mut y);
     assert x.a == 20;
 }
index f7faf26bc4c409cb22eb763de7990c1bdd7c6e47..2ce67f16c06fbdacf890ad5991a8a79b7fcd51d7 100644 (file)
 
 
 // -*- rust -*-
-struct Point {x: int, y: int, mut z: int}
+struct Point {x: int, y: int, z: int}
 
-fn f(p: @Point) { assert (p.z == 12); p.z = 13; assert (p.z == 13); }
+fn f(p: @mut Point) { assert (p.z == 12); p.z = 13; assert (p.z == 13); }
 
 pub fn main() {
-    let a: Point = Point {x: 10, y: 11, mut z: 12};
-    let b: @Point = @copy a;
+    let a: Point = Point {x: 10, y: 11, z: 12};
+    let b: @mut Point = @mut copy a;
     assert (b.z == 12);
     f(b);
     assert (a.z == 12);
index 8ff51b0c28e69a5984c7d1e9a51b40f8a24586bb..04d75fd08e184f6a8e5ef60a84d5bac7b720f87f 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct cat {
-    mut meow: fn@(),
+    meow: fn@(),
 }
 
 fn cat() -> cat {
index 029fe12fcd9847e8d617b62987f8000fe1accb13..249d1c21376bd98725d5cecc07e280b9f8674bf6 100644 (file)
@@ -15,9 +15,9 @@ pub mod pipes {
     use core::cast::{forget, transmute};
 
     pub struct Stuff<T> {
-        mut state: state,
-        mut blocked_task: Option<task::Task>,
-        mut payload: Option<T>
+        state: state,
+        blocked_task: Option<task::Task>,
+        payload: Option<T>
     }
 
     #[deriving_eq]
@@ -29,17 +29,17 @@ pub enum state {
     }
 
     pub type packet<T> = {
-        mut state: state,
-        mut blocked_task: Option<task::Task>,
-        mut payload: Option<T>
+        state: state,
+        blocked_task: Option<task::Task>,
+        payload: Option<T>
     };
 
     pub fn packet<T:Owned>() -> *packet<T> {
         unsafe {
             let p: *packet<T> = cast::transmute(~Stuff{
-                mut state: empty,
-                mut blocked_task: None::<task::Task>,
-                mut payload: None::<T>
+                state: empty,
+                blocked_task: None::<task::Task>,
+                payload: None::<T>
             });
             p
         }
@@ -70,9 +70,9 @@ pub fn swap_state_rel(+dst: &mut state, src: state) -> state {
         }
     }
 
-    pub fn send<T:Owned>(-p: send_packet<T>, -payload: T) {
-        let p = p.unwrap();
-        let p = unsafe { uniquify(p) };
+    pub fn send<T:Owned>(mut p: send_packet<T>, -payload: T) {
+        let mut p = p.unwrap();
+        let mut p = unsafe { uniquify(p) };
         assert (*p).payload.is_none();
         (*p).payload = Some(payload);
         let old_state = swap_state_rel(&mut (*p).state, full);
@@ -96,9 +96,9 @@ pub fn send<T:Owned>(-p: send_packet<T>, -payload: T) {
         }
     }
 
-    pub fn recv<T:Owned>(-p: recv_packet<T>) -> Option<T> {
-        let p = p.unwrap();
-        let p = unsafe { uniquify(p) };
+    pub fn recv<T:Owned>(mut p: recv_packet<T>) -> Option<T> {
+        let mut p = p.unwrap();
+        let mut p = unsafe { uniquify(p) };
         loop {
             let old_state = swap_state_acq(&mut (*p).state,
                                            blocked);
@@ -117,8 +117,8 @@ pub fn recv<T:Owned>(-p: recv_packet<T>) -> Option<T> {
         }
     }
 
-    pub fn sender_terminate<T:Owned>(p: *packet<T>) {
-        let p = unsafe { uniquify(p) };
+    pub fn sender_terminate<T:Owned>(mut p: *packet<T>) {
+        let mut p = unsafe { uniquify(p) };
         match swap_state_rel(&mut (*p).state, terminated) {
           empty | blocked => {
             // The receiver will eventually clean up.
@@ -134,8 +134,8 @@ pub fn sender_terminate<T:Owned>(p: *packet<T>) {
         }
     }
 
-    pub fn receiver_terminate<T:Owned>(p: *packet<T>) {
-        let p = unsafe { uniquify(p) };
+    pub fn receiver_terminate<T:Owned>(mut p: *packet<T>) {
+        let mut p = unsafe { uniquify(p) };
         match swap_state_rel(&mut (*p).state, terminated) {
           empty => {
             // the sender will clean up
@@ -152,21 +152,25 @@ pub fn receiver_terminate<T:Owned>(p: *packet<T>) {
     }
 
     pub struct send_packet<T> {
-        mut p: Option<*packet<T>>,
+        p: Option<*packet<T>>,
     }
 
     pub impl<T:Owned> Drop for send_packet<T> {
         fn finalize(&self) {
-            if self.p != None {
-                let mut p = None;
-                p <-> self.p;
-                sender_terminate(option::unwrap(p))
+            unsafe {
+                if self.p != None {
+                    let mut p = None;
+                    let self_p: &mut Option<*packet<T>> =
+                        cast::transmute(&self.p);
+                    p <-> *self_p;
+                    sender_terminate(option::unwrap(p))
+                }
             }
         }
     }
 
     pub impl<T:Owned> send_packet<T> {
-        fn unwrap() -> *packet<T> {
+        fn unwrap(&mut self) -> *packet<T> {
             let mut p = None;
             p <-> self.p;
             option::unwrap(p)
@@ -180,21 +184,25 @@ pub fn send_packet<T:Owned>(p: *packet<T>) -> send_packet<T> {
     }
 
     pub struct recv_packet<T> {
-        mut p: Option<*packet<T>>,
+        p: Option<*packet<T>>,
     }
 
     pub impl<T:Owned> Drop for recv_packet<T> {
         fn finalize(&self) {
-            if self.p != None {
-                let mut p = None;
-                p <-> self.p;
-                receiver_terminate(option::unwrap(p))
+            unsafe {
+                if self.p != None {
+                    let mut p = None;
+                    let self_p: &mut Option<*packet<T>> =
+                        cast::transmute(&self.p);
+                    p <-> *self_p;
+                    receiver_terminate(option::unwrap(p))
+                }
             }
         }
     }
 
     pub impl<T:Owned> recv_packet<T> {
-        fn unwrap() -> *packet<T> {
+        fn unwrap(&mut self) -> *packet<T> {
             let mut p = None;
             p <-> self.p;
             option::unwrap(p)
index b25e6ae2d2d9172576e2bd18fec6fde97c04dbdc..5555867073491749c117a842a571bf20677e6833 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 struct trie_node {
-    mut content: ~[~str],
-    mut children: ~[trie_node],
+    content: ~[~str],
+    children: ~[trie_node],
 }
 
 fn print_str_vector(vector: ~[~str]) {
@@ -20,7 +20,7 @@ fn print_str_vector(vector: ~[~str]) {
 }
 
 pub fn main() {
-    let node: trie_node = trie_node {
+    let mut node: trie_node = trie_node {
         content: ~[],
         children: ~[]
     };
index 0bcc5983eb719590cc49a84064e626d819cba37a..0d1b0b9d0029efe4c5d0cc3fa49e026f26637ca1 100644 (file)
 
 struct list<T> {
     element: &self/T,
-    mut next: Option<@list<T>>
+    next: Option<@mut list<T>>
 }
 
 impl<T> list<T>{
-    fn addEnd(&self, element: &self/T) {
+    fn addEnd(&mut self, element: &self/T) {
         let newList = list {
             element: element,
             next: option::None
         };
 
-        self.next = Some(@(newList));
+        self.next = Some(@mut newList);
     }
 }
 
index 885b8da9325da63eb1c7f7fcd34fcc094565e795..8f2b13b6eb028e98b8bc79f9337d27891b6c5a19 100644 (file)
@@ -20,7 +20,7 @@ fn exit(+print: ErrPrinter, prog: &str, arg: &str) {
 }
 
 struct X {
-    mut err: ErrPrinter
+    err: ErrPrinter
 }
 
 impl X {
index ab042922df9422dfe2d7f79ce3e2ff461343c184..ce0ae64856236323c3fcee83bb0dd31ce34ce0c5 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-test
 trait Positioned<S> {
-  fn SetX(&self, S);
+  fn SetX(&mut self, S);
   fn X(&self) -> S;
 }
 
@@ -21,10 +21,10 @@ fn translate(&self, dx: T) {
   }
 }
 
-struct Point { mut x: int, mut y: int }
+struct Point { x: int, y: int }
 
 impl Positioned<int> for Point {
-    fn SetX(&self, x: int) {
+    fn SetX(&mut self, x: int) {
         self.x = x;
     }
     fn X(&self) -> int {
index 07cf9d68d167c6d99f26300d1c4aec67f38a4c13..18ad14153d760e509a9ff8f682baa766375b8449 100644 (file)
 extern mod issue_3979_traits;
 use issue_3979_traits::*;
 
-struct Point { mut x: int, mut y: int }
+struct Point { x: int, y: int }
 
 impl Positioned for Point {
-    fn SetX(&self, x: int) {
+    fn SetX(&mut self, x: int) {
         self.x = x;
     }
     fn X(&self) -> int {
@@ -24,10 +24,10 @@ fn X(&self) -> int {
     }
 }
 
-impl Point: Movable;
+impl Movable for Point;
 
 pub fn main() {
-    let p = Point{ x: 1, y: 2};
+    let mut p = Point{ x: 1, y: 2};
     p.translate(3);
     assert p.X() == 4;
 }
index 5d48d1e72de1c830b0e3987e35385fae1fe7112f..6d6be35bfa06a7e9d31622fea4a18d4d5f8d8841 100644 (file)
@@ -1,3 +1,6 @@
+// xfail-test
+// Reason: ICE with explicit self
+
 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 // except according to those terms.
 
 trait Positioned {
-  fn SetX(&self, int);
+  fn SetX(&mut self, int);
   fn X(&self) -> int;
 }
 
 #[allow(default_methods)]
 trait Movable: Positioned {
-  fn translate(&self, dx: int) {
-    self.SetX(self.X() + dx);
+  fn translate(&mut self, dx: int) {
+    let x = self.X();
+    self.SetX(x + dx);
   }
 }
 
-struct Point { mut x: int, mut y: int }
+struct Point { x: int, y: int }
 
 impl Positioned for Point {
-    fn SetX(&self, x: int) {
+    fn SetX(&mut self, x: int) {
         self.x = x;
     }
     fn X(&self) -> int {
@@ -34,7 +38,7 @@ fn X(&self) -> int {
 impl Movable for Point;
 
 pub fn main() {
-    let p = Point{ x: 1, y: 2};
+    let mut p = Point{ x: 1, y: 2};
     p.translate(3);
     assert p.X() == 4;
 }
index e6c2ff28142148cd4ab32c2858f406bea8443cd3..b68ec3755d5b35d33568241bdc82d766347bd63a 100644 (file)
 // resolved when we finish typechecking the fn@.
 
 
-struct Refs { mut refs: ~[int], n: int }
+struct Refs { refs: ~[int], n: int }
 
 pub fn main() {
-    let e = @Refs{mut refs: ~[], n: 0};
+    let e = @mut Refs{refs: ~[], n: 0};
     let f = fn@ () { log(error, e.n); };
     e.refs += ~[1];
 }
index 152dcb3d4a7a7efc3fe2e3edc0da44ec676fcb3d..465e5b63d6bdcb7ef46534c435ba8c6b930b56a7 100644 (file)
@@ -15,17 +15,17 @@ enum option<T> {
     some(T),
 }
 
-struct Smallintmap<T> {mut v: ~[option<T>]}
+struct Smallintmap<T> {v: ~[option<T>]}
 
 struct V<T> { v: ~[option<T>] }
 
-fn mk<T>() -> @Smallintmap<T> {
+fn mk<T>() -> @mut Smallintmap<T> {
     let mut v: ~[option<T>] = ~[];
-    return @Smallintmap {mut v: v};
+    return @mut Smallintmap {v: v};
 }
 
 fn f<T,U>() {
-    let sim = mk::<U>();
+    let mut sim = mk::<U>();
     log(error, sim);
 }
 
index 8e544c09216ac360ebbe425154fbf50203773453..e886c941a4b6aa2b6e336984fa1d221a624c0596 100644 (file)
 // -*- rust -*-
 extern mod std;
 
-type cell = {mut c: @list};
+type cell = {c: @list};
 
-enum list { link(@cell), nil, }
+enum list { link(@mut cell), nil, }
 
 pub fn main() {
-    let first: @cell = @{mut c: @nil()};
-    let second: @cell = @{mut c: @link(first)};
+    let first: @cell = @mut {c: @nil()};
+    let second: @cell = @mut {c: @link(first)};
     first._0 = @link(second);
     sys.rustrt.gc();
-    let third: @cell = @{mut c: @nil()};
+    let third: @cell = @mut {c: @nil()};
 }
index 846136c242c36ed41cb8be8f82c8b0f920e108e3..10d76cdd9775e31f8c667d5dc4e48ca769e6f02f 100644 (file)
 struct A { a: int, b: @int }
 struct B { a: int, b: C }
 struct D { a: int, d: C }
-struct C { mut c: int }
+struct C { c: int }
 
 pub fn main() {
     match A {a: 10, b: @20} {
         x@A {a, b: @20} => { assert x.a == 10; assert a == 10; }
         A {b, _} => { fail!(); }
     }
-    let x@B {b, _} = B {a: 10, b: C {mut c: 20}};
+    let mut x@B {b, _} = B {a: 10, b: C {c: 20}};
     x.b.c = 30;
     assert b.c == 20;
-    let y@D {d, _} = D {a: 10, d: C {mut c: 20}};
+    let mut y@D {d, _} = D {a: 10, d: C {c: 20}};
     y.d.c = 30;
     assert d.c == 20;
 }
index b25a95cbb8a5667b8fe6a16cd09dd6deb223e2c2..27afde631b2abe146ac89f2d8f75e521ae02ac50 100644 (file)
@@ -470,12 +470,12 @@ fn visit_closure_ptr(&self, ck: uint) -> bool {
     }
 }
 
-enum my_visitor = @Stuff;
+enum my_visitor = @mut Stuff;
 
 struct Stuff {
-    mut ptr1: *c_void,
-    mut ptr2: *c_void,
-    mut vals: ~[~str]
+    ptr1: *c_void,
+    ptr2: *c_void,
+    vals: ~[~str]
 }
 
 impl my_visitor {
@@ -637,10 +637,9 @@ pub fn main() {
     unsafe {
         let r = (1,2,3,true,false, Triple {x:5,y:4,z:3}, (12,));
         let p = ptr::addr_of(&r) as *c_void;
-        let u = my_visitor(@Stuff {mut ptr1: p,
-                             mut ptr2: p,
-                             mut vals: ~[]
-                                  });
+        let u = my_visitor(@mut Stuff {ptr1: p,
+                                       ptr2: p,
+                                       vals: ~[]});
         let v = ptr_visit_adaptor(Inner {inner: u});
         let td = get_tydesc_for(r);
         unsafe { error!("tydesc sz: %u, align: %u",
index 6b57c73d0f2762d2017ef7fd342b337117487354..672e87e4f443d2af284405019b8c42245ff7d388 100644 (file)
@@ -10,7 +10,7 @@
 
 // xfail-test
 use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor};
-enum my_visitor = @{ mut types: ~[str] };
+enum my_visitor = @mut { types: ~[str] };
 
 impl TyVisitor for my_visitor {
     fn visit_bot() -> bool {
@@ -141,7 +141,7 @@ fn visit_ty<T>(v: TyVisitor) {
 }
 
 pub fn main() {
-    let v = my_visitor(@{mut types: ~[]});
+    let v = my_visitor(@mut {types: ~[]});
     let vv = v as TyVisitor;
 
     visit_ty::<bool>(vv);
index d47d56b6021b31d48116e86be7a469bf08ef4c94..f5a959b2dbcab9d088f3c1ac7d8b1b2dbc3d8f9f 100644 (file)
@@ -37,7 +37,7 @@ fn r(v: *int) -> r {
 enum t = Node;
 
 struct Node {
-    mut next: Option<@t>,
+    next: Option<@mut t>,
     r: r
 }
 
@@ -50,8 +50,8 @@ pub fn main() {
         let i2p = cast::reinterpret_cast(&i2);
         cast::forget(i2);
 
-        let x1 = @t(Node{
-            mut next: None,
+        let mut x1 = @mut t(Node{
+            next: None,
               r: {
               let rs = r(i1p);
               debug!("r = %x",
@@ -60,11 +60,11 @@ pub fn main() {
         });
         
         debug!("x1 = %x, x1.r = %x",
-            cast::reinterpret_cast::<@t, uint>(&x1),
+            cast::reinterpret_cast::<@mut t, uint>(&x1),
             cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x1.r))));
 
-        let x2 = @t(Node{
-            mut next: None,
+        let mut x2 = @mut t(Node{
+            next: None,
               r: {
               let rs = r(i2p);
               debug!("r2 = %x",
@@ -74,7 +74,7 @@ pub fn main() {
         });
         
         debug!("x2 = %x, x2.r = %x",
-               cast::reinterpret_cast::<@t, uint>(&x2),
+               cast::reinterpret_cast::<@mut t, uint>(&x2),
                cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x2.r))));
 
         x1.next = Some(x2);
index 1b39093c7d05cc7e82d40afad210063c13d980e2..cf5f36916a04109861d5644c12e14cfdd82f9de8 100644 (file)
@@ -37,7 +37,7 @@ fn r(v: U) -> r {
 enum t = Node;
 
 struct Node {
-    mut next: Option<@t>,
+    next: Option<@mut t>,
     r: r
 }
 
@@ -53,12 +53,12 @@ pub fn main() {
         let u1 = U {a: 0xB, b: 0xC, c: i1p};
         let u2 = U {a: 0xB, b: 0xC, c: i2p};
 
-        let x1 = @t(Node {
-            mut next: None,
+        let x1 = @mut t(Node {
+            next: None,
             r: r(u1)
         });
-        let x2 = @t(Node {
-            mut next: None,
+        let x2 = @mut t(Node {
+            next: None,
             r: r(u2)
         });
         x1.next = Some(x2);
index 036ca2496698c1399ff0c6313a7d3ef86c7b5c05..4cd3df0f87f90171fbc281c2ec8b01ba2922d11c 100644 (file)
@@ -46,7 +46,7 @@ fn r(v: U, w: int, _x: *int) -> R {
 enum t = Node;
 
 struct Node {
-    mut next: Option<@t>,
+    next: Option<@mut t>,
     r: R
 }
 
@@ -62,12 +62,12 @@ pub fn main() {
         let u1 = U {a: 0xB, b: 0xC, c: i1p};
         let u2 = U {a: 0xB, b: 0xC, c: i2p};
 
-        let x1 = @t(Node{
-            mut next: None,
+        let x1 = @mut t(Node{
+            next: None,
             r: r(u1, 42, i1p)
         });
-        let x2 = @t(Node{
-            mut next: None,
+        let x2 = @mut t(Node{
+            next: None,
             r: r(u2, 42, i2p)
         });
         x1.next = Some(x2);
index e0e3c6e15975ce681e1eaf6b5f1dc8e5f8225537..fb3756320f5c4904f7d891829ba873cf93418601 100644 (file)
@@ -1,3 +1,6 @@
+// xfail-test
+// Weird borrow check bug
+
 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 
 // Test cyclic detector when using trait instances.
 
-enum Tree = @TreeR;
+enum Tree = @mut TreeR;
 struct TreeR {
-    mut left: Option<Tree>,
-    mut right: Option<Tree>,
+    left: Option<Tree>,
+    right: Option<Tree>,
     val: to_str
 }
 
 trait to_str {
-    fn to_str() -> ~str;
+    fn to_str(&self) -> ~str;
 }
 
 impl<T:to_str> to_str for Option<T> {
-    fn to_str() -> ~str {
-        match self {
+    fn to_str(&self) -> ~str {
+        match *self {
           None => { ~"none" }
           Some(ref t) => { ~"some(" + t.to_str() + ~")" }
         }
@@ -31,26 +34,26 @@ fn to_str() -> ~str {
 }
 
 impl to_str for int {
-    fn to_str() -> ~str { int::str(self) }
+    fn to_str(&self) -> ~str { int::str(*self) }
 }
 
 impl to_str for Tree {
-    fn to_str() -> ~str {
+    fn to_str(&self) -> ~str {
         let l = self.left, r = self.right;
-        fmt!("[%s, %s, %s]", self.val.to_str(),
-             l.to_str(), r.to_str())
+        let val = &self.val;
+        fmt!("[%s, %s, %s]", val.to_str(), l.to_str(), r.to_str())
     }
 }
 
 fn foo<T:to_str>(x: T) -> ~str { x.to_str() }
 
 pub fn main() {
-    let t1 = Tree(@TreeR{mut left: None,
-                    mut right: None,
-                    val: 1 as to_str });
-    let t2 = Tree(@TreeR{mut left: Some(t1),
-                    mut right: Some(t1),
-                    val: 2 as to_str });
+    let t1 = Tree(@mut TreeR{left: None,
+                             right: None,
+                             val: 1 as to_str });
+    let t2 = Tree(@mut TreeR{left: Some(t1),
+                             right: Some(t1),
+                             val: 2 as to_str });
     let expected = ~"[2, some([1, none, none]), some([1, none, none])]";
     assert t2.to_str() == expected;
     assert foo(t2 as to_str) == expected;
index 2aa3bc30d07b862504788019be940996a611dbf0..c9c5ce0c928fd2e56abc7c992276d5f0657edbb5 100644 (file)
 
 
 // -*- rust -*-
-struct Point {x: int, y: int, mut z: int}
+struct Point {x: int, y: int, z: int}
 
 fn f(p: &mut Point) { p.z = 13; }
 
 pub fn main() {
-    let mut x: Point = Point {x: 10, y: 11, mut z: 12};
+    let mut x: Point = Point {x: 10, y: 11, z: 12};
     f(&mut x);
     assert (x.z == 13);
 }