diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-02-22 16:08:16 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-02-22 18:35:01 -0800 |
| commit | 82062a63485b75b7476d078e722b49e3eb376795 (patch) | |
| tree | 4dbd112876a818c1e227cddb072bf98dcc840092 | |
| parent | 1144fdde1f658e957e6ab54f8bc199e40583e851 (diff) | |
| download | rust-82062a63485b75b7476d078e722b49e3eb376795.tar.gz rust-82062a63485b75b7476d078e722b49e3eb376795.zip | |
test: De-mut the test suite. rs=demuting
65 files changed, 311 insertions, 450 deletions
diff --git a/src/test/auxiliary/issue_3882.rs b/src/test/auxiliary/issue_3882.rs index c2b95e4e7d6..6d232c34b47 100644 --- a/src/test/auxiliary/issue_3882.rs +++ b/src/test/auxiliary/issue_3882.rs @@ -10,10 +10,10 @@ 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); } } diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index da2f2d5c3d2..509861e2f47 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -21,10 +21,10 @@ use io::WriterUtil; 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 select_random(r: u32, genelist: ~[AminoAcids]) -> 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), diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 67d3391ed13..e7b3547ab8c 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -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; diff --git a/src/test/compile-fail/borrowck-assign-comp.rs b/src/test/compile-fail/borrowck-assign-comp.rs index f5597859433..283f04a283f 100644 --- a/src/test/compile-fail/borrowck-assign-comp.rs +++ b/src/test/compile-fail/borrowck-assign-comp.rs @@ -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; diff --git a/src/test/compile-fail/borrowck-call-sendfn.rs b/src/test/compile-fail/borrowck-call-sendfn.rs index c83f9230dbb..51047631ea6 100644 --- a/src/test/compile-fail/borrowck-call-sendfn.rs +++ b/src/test/compile-fail/borrowck-call-sendfn.rs @@ -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 index 64baf3a9457..00000000000 --- a/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs +++ /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 index a14fd18c7d5..00000000000 --- a/src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162.rs +++ /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 index 685efcacf0c..00000000000 --- a/src/test/compile-fail/borrowck-mut-field-imm-base.rs +++ /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)); -} diff --git a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs index e7cbab41079..4af3bc17240 100644 --- a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs +++ b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs @@ -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 => {} }; diff --git a/src/test/compile-fail/borrowck-uniq-via-box.rs b/src/test/compile-fail/borrowck-uniq-via-box.rs index e4b8214fb98..9a63c8698c6 100644 --- a/src/test/compile-fail/borrowck-uniq-via-box.rs +++ b/src/test/compile-fail/borrowck-uniq-via-box.rs @@ -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 } diff --git a/src/test/compile-fail/borrowck-uniq-via-ref.rs b/src/test/compile-fail/borrowck-uniq-via-ref.rs index 48d39c39e5a..8d6e7039057 100644 --- a/src/test/compile-fail/borrowck-uniq-via-ref.rs +++ b/src/test/compile-fail/borrowck-uniq-via-ref.rs @@ -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 } diff --git a/src/test/compile-fail/issue-1451.rs b/src/test/compile-fail/issue-1451.rs index 62bc322f416..2e80a7b09de 100644 --- a/src/test/compile-fail/issue-1451.rs +++ b/src/test/compile-fail/issue-1451.rs @@ -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(S {f: x}); + fooS(S {f: bar}); let x: fn@() = bar; - fooT({mut f: x}); - fooT({mut f: bar}); + fooT(T {f: x}); + fooT(T {f: bar}); } diff --git a/src/test/compile-fail/issue-3021-b.rs b/src/test/compile-fail/issue-3021-b.rs index 09454d4326a..a782dd58ee6 100644 --- a/src/test/compile-fail/issue-3021-b.rs +++ b/src/test/compile-fail/issue-3021-b.rs @@ -13,11 +13,11 @@ extern mod std; 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 } diff --git a/src/test/compile-fail/issue-3044.rs b/src/test/compile-fail/issue-3044.rs index 46ad7f64589..fcd5b1deee5 100644 --- a/src/test/compile-fail/issue-3044.rs +++ b/src/test/compile-fail/issue-3044.rs @@ -11,10 +11,10 @@ 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. } diff --git a/src/test/compile-fail/issue-3177-mutable-struct.rs b/src/test/compile-fail/issue-3177-mutable-struct.rs index ab28b461a2c..31c0dc7d9c4 100644 --- a/src/test/compile-fail/issue-3177-mutable-struct.rs +++ b/src/test/compile-fail/issue-3177-mutable-struct.rs @@ -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() { diff --git a/src/test/compile-fail/issue-3214.rs b/src/test/compile-fail/issue-3214.rs index ff19551896b..2dd58906ddb 100644 --- a/src/test/compile-fail/issue-3214.rs +++ b/src/test/compile-fail/issue-3214.rs @@ -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 } diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index 40d65938795..3dd070b44a0 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -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 { diff --git a/src/test/compile-fail/issue-3973.rs b/src/test/compile-fail/issue-3973.rs index 812e0fc8c96..19244d24bcc 100644 --- a/src/test/compile-fail/issue-3973.rs +++ b/src/test/compile-fail/issue-3973.rs @@ -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 diff --git a/src/test/compile-fail/mutable-huh-variance-rec.rs b/src/test/compile-fail/mutable-huh-variance-rec.rs index 1ee2bb18321..6d79e23e999 100644 --- a/src/test/compile-fail/mutable-huh-variance-rec.rs +++ b/src/test/compile-fail/mutable-huh-variance-rec.rs @@ -10,11 +10,15 @@ // 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 index 3b6522c308d..00000000000 --- a/src/test/compile-fail/non-const.rs +++ /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` -} diff --git a/src/test/compile-fail/pure-modifies-aliased.rs b/src/test/compile-fail/pure-modifies-aliased.rs index 90c507091e9..2aa81dd4fa2 100644 --- a/src/test/compile-fail/pure-modifies-aliased.rs +++ b/src/test/compile-fail/pure-modifies-aliased.rs @@ -10,20 +10,20 @@ // 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 } } diff --git a/src/test/compile-fail/regions-addr-of-self.rs b/src/test/compile-fail/regions-addr-of-self.rs index 2b522009083..c6c89a3ae04 100644 --- a/src/test/compile-fail/regions-addr-of-self.rs +++ b/src/test/compile-fail/regions-addr-of-self.rs @@ -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); } diff --git a/src/test/compile-fail/regions-addr-of-upvar-self.rs b/src/test/compile-fail/regions-addr-of-upvar-self.rs index cf026785420..8e98d4341a8 100644 --- a/src/test/compile-fail/regions-addr-of-upvar-self.rs +++ b/src/test/compile-fail/regions-addr-of-upvar-self.rs @@ -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; } } diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index a8bbc24ffd4..f9ea3c6f933 100644 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ b/src/test/compile-fail/regions-glb-free-free.rs @@ -17,7 +17,7 @@ mod argparse { name: &str, desc: &str, max_count: uint, - mut value: uint + value: uint } pub fn flag(name: &r/str, desc: &r/str) -> Flag/&r { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs index fabce969b9c..bdd9b372e4e 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability.rs @@ -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 diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index a75e1deb6a2..0f1b23b2839 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -17,14 +17,16 @@ trait foo { fn any_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() -> ∫ } -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; } } diff --git a/src/test/compile-fail/tps-invariant-class.rs b/src/test/compile-fail/tps-invariant-class.rs index c1a0b220971..0411eeb05eb 100644 --- a/src/test/compile-fail/tps-invariant-class.rs +++ b/src/test/compile-fail/tps-invariant-class.rs @@ -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> { diff --git a/src/test/compile-fail/tps-invariant-enum.rs b/src/test/compile-fail/tps-invariant-enum.rs index ead155320b8..967b201908c 100644 --- a/src/test/compile-fail/tps-invariant-enum.rs +++ b/src/test/compile-fail/tps-invariant-enum.rs @@ -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); } diff --git a/src/test/compile-fail/tps-invariant-trait.rs b/src/test/compile-fail/tps-invariant-trait.rs index adf82232898..60da6d2208a 100644 --- a/src/test/compile-fail/tps-invariant-trait.rs +++ b/src/test/compile-fail/tps-invariant-trait.rs @@ -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); diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 17a2db5d1f0..5cc8f6e6edc 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -16,10 +16,10 @@ fn test1() { let val = @0; { } *val; } 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; } diff --git a/src/test/run-pass-fulldeps/issue-1926.rs b/src/test/run-pass-fulldeps/issue-1926.rs index 7d52f13b075..95a80630d7c 100644 --- a/src/test/run-pass-fulldeps/issue-1926.rs +++ b/src/test/run-pass-fulldeps/issue-1926.rs @@ -20,12 +20,12 @@ use syntax::parse::parser; 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; } diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 2a09de7a81c..2f008e51586 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -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); } diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs index 37fdfca4468..ddaa38223ec 100644 --- a/src/test/run-pass/alloca-from-derived-tydesc.rs +++ b/src/test/run-pass/alloca-from-derived-tydesc.rs @@ -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(); } diff --git a/src/test/run-pass/alt-implicit-copy-unique.rs b/src/test/run-pass/alt-implicit-copy-unique.rs index 58076b59ceb..e73eb57d607 100644 --- a/src/test/run-pass/alt-implicit-copy-unique.rs +++ b/src/test/run-pass/alt-implicit-copy-unique.rs @@ -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; } } diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 89c86c1cf43..95c23753c27 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -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); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 99379813840..2044a5c2346 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -86,9 +86,10 @@ extern mod test { 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", diff --git a/src/test/run-pass/borrowck-binding-mutbl.rs b/src/test/run-pass/borrowck-binding-mutbl.rs index 6e8b35f7678..377ed2608e5 100644 --- a/src/test/run-pass/borrowck-binding-mutbl.rs +++ b/src/test/run-pass/borrowck-binding-mutbl.rs @@ -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} => { diff --git a/src/test/run-pass/borrowck-newtype-issue-2573.rs b/src/test/run-pass/borrowck-newtype-issue-2573.rs index 5dc373aa50f..7e81345739f 100644 --- a/src/test/run-pass/borrowck-newtype-issue-2573.rs +++ b/src/test/run-pass/borrowck-newtype-issue-2573.rs @@ -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(); diff --git a/src/test/run-pass/borrowck-root-while-cond-2.rs b/src/test/run-pass/borrowck-root-while-cond-2.rs index 5b2232daa4a..ea165e53ceb 100644 --- a/src/test/run-pass/borrowck-root-while-cond-2.rs +++ b/src/test/run-pass/borrowck-root-while-cond-2.rs @@ -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 {} } diff --git a/src/test/run-pass/borrowck-root-while-cond.rs b/src/test/run-pass/borrowck-root-while-cond.rs index 432847cc198..285796db20e 100644 --- a/src/test/run-pass/borrowck-root-while-cond.rs +++ b/src/test/run-pass/borrowck-root-while-cond.rs @@ -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 {} } diff --git a/src/test/run-pass/boxed-class-type-substitution.rs b/src/test/run-pass/boxed-class-type-substitution.rs index 4fe553ec039..025bf8fd9d9 100644 --- a/src/test/run-pass/boxed-class-type-substitution.rs +++ b/src/test/run-pass/boxed-class-type-substitution.rs @@ -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() { } diff --git a/src/test/run-pass/cycle-collection2.rs b/src/test/run-pass/cycle-collection2.rs index 127a1c97038..125c3ba1027 100644 --- a/src/test/run-pass/cycle-collection2.rs +++ b/src/test/run-pass/cycle-collection2.rs @@ -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; } diff --git a/src/test/run-pass/cycle-collection5.rs b/src/test/run-pass/cycle-collection5.rs index 6f3297c6602..fe0d294f01a 100644 --- a/src/test/run-pass/cycle-collection5.rs +++ b/src/test/run-pass/cycle-collection5.rs @@ -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; } diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index f162a1bc48a..26e2023e89c 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -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; } diff --git a/src/test/run-pass/expr-copy.rs b/src/test/run-pass/expr-copy.rs index 21080280d2c..2d370bada28 100644 --- a/src/test/run-pass/expr-copy.rs +++ b/src/test/run-pass/expr-copy.rs @@ -10,17 +10,18 @@ // 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(© x); + let mut y = copy x; + f(&mut y); assert x.a == 20; } diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index f7faf26bc4c..2ce67f16c06 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -12,13 +12,13 @@ // -*- 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); diff --git a/src/test/run-pass/issue-2633.rs b/src/test/run-pass/issue-2633.rs index 8ff51b0c28e..04d75fd08e1 100644 --- a/src/test/run-pass/issue-2633.rs +++ b/src/test/run-pass/issue-2633.rs @@ -9,7 +9,7 @@ // except according to those terms. struct cat { - mut meow: fn@(), + meow: fn@(), } fn cat() -> cat { diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 029fe12fcd9..249d1c21376 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -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 mod pipes { } 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 mod pipes { } } - 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 mod pipes { } } - 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 mod pipes { } } - 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 mod pipes { } } - 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 mod pipes { } 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 mod pipes { } 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) diff --git a/src/test/run-pass/issue-3389.rs b/src/test/run-pass/issue-3389.rs index b25e6ae2d2d..55558670734 100644 --- a/src/test/run-pass/issue-3389.rs +++ b/src/test/run-pass/issue-3389.rs @@ -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: ~[] }; diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs index 0bcc5983eb7..0d1b0b9d002 100644 --- a/src/test/run-pass/issue-3447.rs +++ b/src/test/run-pass/issue-3447.rs @@ -10,17 +10,17 @@ 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); } } diff --git a/src/test/run-pass/issue-3904.rs b/src/test/run-pass/issue-3904.rs index 885b8da9325..8f2b13b6eb0 100644 --- a/src/test/run-pass/issue-3904.rs +++ b/src/test/run-pass/issue-3904.rs @@ -20,7 +20,7 @@ fn exit(+print: ErrPrinter, prog: &str, arg: &str) { } struct X { - mut err: ErrPrinter + err: ErrPrinter } impl X { diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index ab042922df9..ce0ae648562 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -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 @@ trait Movable<S, T>: Positioned<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 { diff --git a/src/test/run-pass/issue-3979-xcrate.rs b/src/test/run-pass/issue-3979-xcrate.rs index 07cf9d68d16..18ad14153d7 100644 --- a/src/test/run-pass/issue-3979-xcrate.rs +++ b/src/test/run-pass/issue-3979-xcrate.rs @@ -13,10 +13,10 @@ 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 @@ impl Positioned for Point { } } -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; } diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs index 5d48d1e72de..6d6be35bfa0 100644 --- a/src/test/run-pass/issue-3979.rs +++ b/src/test/run-pass/issue-3979.rs @@ -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. @@ -9,21 +12,22 @@ // 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 @@ impl Positioned for Point { 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; } diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index e6c2ff28142..b68ec3755d5 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -12,10 +12,10 @@ // 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]; } diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index 152dcb3d4a7..465e5b63d6b 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -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); } diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index 8e544c09216..e886c941a4b 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -12,14 +12,14 @@ // -*- 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()}; } diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index 846136c242c..10d76cdd977 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -11,17 +11,17 @@ 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; } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index b25a95cbb8a..27afde631b2 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -470,12 +470,12 @@ impl<V:TyVisitor + movable_ptr> TyVisitor for ptr_visit_adaptor<V> { } } -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", diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index 6b57c73d0f2..672e87e4f44 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -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); diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index d47d56b6021..f5a959b2dbc 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -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); diff --git a/src/test/run-pass/resource-cycle2.rs b/src/test/run-pass/resource-cycle2.rs index 1b39093c7d0..cf5f36916a0 100644 --- a/src/test/run-pass/resource-cycle2.rs +++ b/src/test/run-pass/resource-cycle2.rs @@ -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); diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index 036ca249669..4cd3df0f87f 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -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); diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index e0e3c6e1597..fb3756320f5 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -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. @@ -10,20 +13,20 @@ // 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 @@ impl<T:to_str> to_str for Option<T> { } 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; diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index 2aa3bc30d07..c9c5ce0c928 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -12,12 +12,12 @@ // -*- 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); } |
