test: Get rid of some `@mut`s in borrow check tests
This commit is contained in:
parent
65d55afd2f
commit
df13c64c3b
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {}
|
||||
}
|
||||
|
|
|
@ -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 {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue