test: De-@mut the test suite

This commit is contained in:
Patrick Walton 2013-12-31 15:46:27 -08:00
parent df13c64c3b
commit c3694d732e
72 changed files with 357 additions and 843 deletions

View file

@ -1,30 +0,0 @@
// Copyright 2013 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)];
trait T {
fn foo(@mut self);
}
struct S {
unused: int
}
impl T for S {
fn foo(@mut self) {
}
}
fn main() {
let s = @S { unused: 0 };
let _s2 = s as @mut T; //~ error: types differ in mutability
let _s3 = &s as &mut T; //~ error: types differ in mutability
}

View file

@ -8,19 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[feature(managed_boxes)];
fn takes_imm(x: &int) { }
fn takes_mut(x: @mut int) { }
fn takes_imm(x: @int) { }
fn takes_mut(x: &mut int) { }
fn apply<T>(t: T, f: |T|) {
f(t)
}
fn main() {
apply(@3, takes_mut); //~ ERROR (values differ in mutability)
apply(@3, takes_imm);
apply(&3, takes_mut); //~ ERROR (values differ in mutability)
apply(&3, takes_imm);
apply(@mut 3, takes_mut);
apply(@mut 3, takes_imm); //~ ERROR (values differ in mutability)
apply(&mut 3, takes_mut);
apply(&mut 3, takes_imm); //~ ERROR (values differ in mutability)
}

View file

@ -12,6 +12,5 @@
static x: ~[int] = ~[123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
static y: @[int] = @[123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
static z: @mut [int] = @mut [123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
fn main() {}

View file

@ -12,10 +12,10 @@
// A test case for #2548.
use std::cell::Cell;
struct foo {
x: @mut int,
x: @Cell<int>,
}
#[unsafe_destructor]
@ -23,17 +23,17 @@ impl Drop for foo {
fn drop(&mut self) {
unsafe {
println("Goodbye, World!");
*self.x += 1;
self.x.set(self.x.get() + 1);
}
}
}
fn foo(x: @mut int) -> foo {
fn foo(x: @Cell<int>) -> foo {
foo { x: x }
}
fn main() {
let x = @mut 0;
let x = @Cell::new(0);
{
let mut res = foo(x);
@ -43,5 +43,5 @@ fn main() {
assert_eq!(v.len(), 2);
}
assert_eq!(*x, 1);
assert_eq!(x.get(), 1);
}

View file

@ -10,7 +10,7 @@
#[feature(managed_boxes)];
struct P { child: Option<@mut P> }
struct P { child: Option<@P> }
trait PTrait {
fn getChildOption(&self) -> Option<@P>;
}

View file

@ -1,12 +1,11 @@
#[feature(managed_boxes)];
struct Foo {
f: @mut int,
f: @int,
}
impl Drop for Foo { //~ ERROR cannot implement a destructor on a structure that does not satisfy Send
fn drop(&mut self) {
*self.f = 10;
}
}

View file

@ -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.
#[feature(managed_boxes)];
fn two_args<T>(x: T, y: T) { }
fn main() {
let a: @mut int = @mut 3;
let b: @int = @3;
// NOTE:
//
// The fact that this test fails to compile reflects a known
// shortcoming of the current inference algorithm. These errors
// are *not* desirable.
two_args(a, b); //~ ERROR (values differ in mutability)
}

View file

@ -15,7 +15,6 @@ trait Foo {
fn borrowed_mut(&mut self);
fn managed(@self);
fn managed_mut(@mut self);
fn owned(~self);
}
@ -24,7 +23,6 @@ fn borrowed_receiver(x: &Foo) {
x.borrowed();
x.borrowed_mut(); // See [1]
x.managed(); //~ ERROR does not implement any method
x.managed_mut(); //~ ERROR does not implement any method
x.owned(); //~ ERROR does not implement any method
}
@ -32,7 +30,6 @@ fn borrowed_mut_receiver(x: &mut Foo) {
x.borrowed();
x.borrowed_mut();
x.managed(); //~ ERROR does not implement any method
x.managed_mut(); //~ ERROR does not implement any method
x.owned(); //~ ERROR does not implement any method
}
@ -40,15 +37,6 @@ fn managed_receiver(x: @Foo) {
x.borrowed();
x.borrowed_mut(); // See [1]
x.managed();
x.managed_mut(); //~ ERROR does not implement any method
x.owned(); //~ ERROR does not implement any method
}
fn managed_mut_receiver(x: @mut Foo) {
x.borrowed();
x.borrowed_mut();
x.managed(); //~ ERROR does not implement any method
x.managed_mut();
x.owned(); //~ ERROR does not implement any method
}
@ -56,7 +44,6 @@ fn owned_receiver(x: ~Foo) {
x.borrowed();
x.borrowed_mut(); // See [1]
x.managed(); //~ ERROR does not implement any method
x.managed_mut(); //~ ERROR does not implement any method
x.owned();
}

View file

@ -10,20 +10,22 @@
#[feature(managed_boxes)];
use std::cell::Cell;
struct r {
i: @mut int,
i: @Cell<int>,
}
#[unsafe_destructor]
impl Drop for r {
fn drop(&mut self) {
unsafe {
*(self.i) = *(self.i) + 1;
self.i.set(self.i.get() + 1);
}
}
}
fn r(i: @mut int) -> r {
fn r(i: @Cell<int>) -> r {
r {
i: i
}
@ -34,7 +36,7 @@ struct A {
}
fn main() {
let i = @mut 0;
let i = @Cell::new(0);
{
// Can't do this copy
let x = ~~~A {y: r(i)};

View file

@ -11,7 +11,7 @@
#[feature(managed_boxes)];
struct invariant<'a> {
f: 'static |x: @mut &'a int|
f: 'static |x: &mut &'a int|
}
fn to_same_lifetime<'r>(bi: invariant<'r>) {

View file

@ -11,7 +11,7 @@
#[feature(managed_boxes)];
struct invariant<'a> {
f: 'static || -> @mut &'a int
f: 'static || -> &mut &'a int
}
fn to_same_lifetime<'r>(bi: invariant<'r>) {

View file

@ -10,15 +10,17 @@
#[feature(managed_boxes)];
use std::cell::Cell;
struct r {
i: @mut int,
i: @Cell<int>,
}
#[unsafe_destructor]
impl Drop for r {
fn drop(&mut self) {
unsafe {
*(self.i) = *(self.i) + 1;
self.i.set(self.i.get() + 1);
}
}
}
@ -27,12 +29,12 @@ fn f<T>(_i: ~[T], _j: ~[T]) {
}
fn main() {
let i1 = @mut 0;
let i2 = @mut 1;
let i1 = @Cell::new(0);
let i2 = @Cell::new(1);
let r1 = ~[~r { i: i1 }];
let r2 = ~[~r { i: i2 }];
f(r1.clone(), r2.clone());
//~^ ERROR failed to find an implementation of
info!("{:?}", (r2, *i1));
info!("{:?}", (r1, *i2));
info!("{:?}", (r2, i1.get()));
info!("{:?}", (r1, i2.get()));
}