test: Get rid of some `@mut`s in borrow check tests

This commit is contained in:
Patrick Walton 2013-12-30 17:57:36 -08:00
parent 65d55afd2f
commit df13c64c3b
7 changed files with 3 additions and 45 deletions

View File

@ -49,13 +49,5 @@ fn b() {
q.x += 1; // and OK to mutate it
}
fn c() {
// Here the receiver is in aliased memory but due to write
// barriers we can still consider it immutable.
let q = @mut Point {x: 3, y: 4};
*q + 3;
q.times(3);
}
fn main() {
}

View File

@ -48,16 +48,5 @@ fn b() {
l.x += 1;
}
fn c() {
// Loaning @mut as & is considered legal due to dynamic checks...
let q = @mut point {x: 3, y: 4};
q.impurem();
// ...but we still detect errors statically when we can.
q.blockm(|| {
q.x = 10; //~ ERROR cannot assign
})
}
fn main() {
}

View File

@ -1,18 +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.
#[feature(managed_boxes)];
fn main() {
let v = @mut [ 1, 2, 3 ];
for _x in v.iter() {
v[1] = 4; //~ ERROR cannot assign
}
}

View File

@ -12,7 +12,7 @@
struct foo(~int);
fn borrow(x: @mut foo) {
fn borrow(x: @foo) {
let _y = &***x;
*x = foo(~4); //~ ERROR cannot assign
}

View File

@ -30,11 +30,6 @@ fn managed_receiver(x: @Foo) {
x.borrowed_mut(); //~ ERROR cannot borrow
}
fn managed_mut_receiver(x: @mut Foo) {
x.borrowed();
x.borrowed_mut();
}
fn owned_receiver(x: ~Foo) {
x.borrowed();
x.borrowed_mut(); //~ ERROR cannot borrow

View File

@ -14,6 +14,6 @@ struct F { f: @G }
struct G { g: ~[int] }
pub fn main() {
let rec = @mut F {f: @G {g: ~[1, 2, 3]}};
let rec = @F {f: @G {g: ~[1, 2, 3]}};
while rec.f.g.len() == 23 {}
}

View File

@ -15,6 +15,6 @@ fn borrow<'r,T>(x: &'r T) -> &'r T {x}
struct Rec { f: @int }
pub fn main() {
let rec = @mut Rec {f: @22};
let rec = @Rec {f: @22};
while *borrow(rec.f) == 23 {}
}