diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs
index 72ce66c20bd..90b01f8888b 100644
--- a/src/test/auxiliary/cci_nested_lib.rs
+++ b/src/test/auxiliary/cci_nested_lib.rs
@@ -10,6 +10,8 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
+
pub struct Entry {
key: A,
value: B
@@ -17,11 +19,12 @@ pub struct Entry {
pub struct alist {
eq_fn: extern "Rust" fn(A,A) -> bool,
- data: @mut ~[Entry]
+ data: @RefCell<~[Entry]>,
}
pub fn alist_add(lst: &alist, k: A, v: B) {
- lst.data.push(Entry{key:k, value:v});
+ let mut data = lst.data.borrow_mut();
+ data.get().push(Entry{key:k, value:v});
}
pub fn alist_get B {
let eq_fn = lst.eq_fn;
- for entry in lst.data.iter() {
+ let data = lst.data.borrow();
+ for entry in data.get().iter() {
if eq_fn(entry.key.clone(), k.clone()) {
return entry.value.clone();
}
@@ -41,12 +45,18 @@ pub fn alist_get() -> alist {
fn eq_int(a: int, b: int) -> bool { a == b }
- return alist {eq_fn: eq_int, data: @mut ~[]};
+ return alist {
+ eq_fn: eq_int,
+ data: @RefCell::new(~[]),
+ };
}
#[inline]
pub fn new_int_alist_2() -> alist {
#[inline]
fn eq_int(a: int, b: int) -> bool { a == b }
- return alist {eq_fn: eq_int, data: @mut ~[]};
+ return alist {
+ eq_fn: eq_int,
+ data: @RefCell::new(~[]),
+ };
}
diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs
index f5d2fb9ffd2..15dde899ce3 100644
--- a/src/test/auxiliary/issue-2631-a.rs
+++ b/src/test/auxiliary/issue-2631-a.rs
@@ -14,11 +14,12 @@
extern mod extra;
+use std::cell::RefCell;
use std::hashmap::HashMap;
-pub type header_map = HashMap<~str, @mut ~[@~str]>;
+pub type header_map = HashMap<~str, @RefCell<~[@~str]>>;
// the unused ty param is necessary so this gets monomorphized
pub fn request(req: &header_map) {
- let _x = (*((**req.get(&~"METHOD")).clone())[0u]).clone();
+ let _x = (*((**req.get(&~"METHOD")).clone()).get()[0u]).clone();
}
diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs
index 39bcfde2826..75587f17b10 100644
--- a/src/test/bench/sudoku.rs
+++ b/src/test/bench/sudoku.rs
@@ -86,7 +86,7 @@ impl Sudoku {
return Sudoku::new(g)
}
- pub fn write(&self, writer: @mut io::Writer) {
+ pub fn write(&self, writer: &mut io::Writer) {
for row in range(0u8, 9u8) {
write!(writer, "{}", self.grid[row][0]);
for col in range(1u8, 9u8) {
@@ -280,5 +280,5 @@ fn main() {
Sudoku::read(BufferedReader::new(io::stdin()))
};
sudoku.solve();
- sudoku.write(@mut io::stdout() as @mut io::Writer);
+ sudoku.write(&mut io::stdout());
}
diff --git a/src/test/compile-fail/cast-immutable-mutable-trait.rs b/src/test/compile-fail/cast-immutable-mutable-trait.rs
deleted file mode 100644
index 817696c6d20..00000000000
--- a/src/test/compile-fail/cast-immutable-mutable-trait.rs
+++ /dev/null
@@ -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 or the MIT license
-// , 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
-}
diff --git a/src/test/compile-fail/fn-variance-1.rs b/src/test/compile-fail/fn-variance-1.rs
index a4ebfef1774..2277f7080af 100644
--- a/src/test/compile-fail/fn-variance-1.rs
+++ b/src/test/compile-fail/fn-variance-1.rs
@@ -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, 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)
}
diff --git a/src/test/compile-fail/issue-10487.rs b/src/test/compile-fail/issue-10487.rs
index d116b7b67ca..302e883942e 100644
--- a/src/test/compile-fail/issue-10487.rs
+++ b/src/test/compile-fail/issue-10487.rs
@@ -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() {}
diff --git a/src/test/compile-fail/issue-2548.rs b/src/test/compile-fail/issue-2548.rs
index 21b6959692f..def712d9e8d 100644
--- a/src/test/compile-fail/issue-2548.rs
+++ b/src/test/compile-fail/issue-2548.rs
@@ -12,10 +12,10 @@
// A test case for #2548.
+use std::cell::Cell;
+
struct foo {
- x: @mut int,
-
-
+ x: @Cell,
}
#[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) -> 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);
}
diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs
index 4665687db85..fe57d7171a6 100644
--- a/src/test/compile-fail/issue-3668.rs
+++ b/src/test/compile-fail/issue-3668.rs
@@ -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>;
}
diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs
index 2ea12ab9fdc..de277b4c36e 100644
--- a/src/test/compile-fail/kindck-destructor-owned.rs
+++ b/src/test/compile-fail/kindck-destructor-owned.rs
@@ -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;
}
}
diff --git a/src/test/compile-fail/lub-in-args.rs b/src/test/compile-fail/lub-in-args.rs
deleted file mode 100644
index 0ce8ee40d3b..00000000000
--- a/src/test/compile-fail/lub-in-args.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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-fn two_args(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)
-}
diff --git a/src/test/compile-fail/object-pointer-types.rs b/src/test/compile-fail/object-pointer-types.rs
index a1a577a1856..2270cb6f498 100644
--- a/src/test/compile-fail/object-pointer-types.rs
+++ b/src/test/compile-fail/object-pointer-types.rs
@@ -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();
}
diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs
index 6c19ef9700f..9c9b4a9f4d5 100644
--- a/src/test/compile-fail/pinned-deep-copy.rs
+++ b/src/test/compile-fail/pinned-deep-copy.rs
@@ -10,20 +10,22 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
struct r {
- i: @mut int,
+ i: @Cell,
}
#[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) -> 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)};
diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs
index 6a6b8f95e63..b36933c4957 100644
--- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs
+++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs
@@ -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>) {
diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
index 4210c52e7f6..449cbc6970f 100644
--- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
+++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
@@ -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>) {
diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs
index 9771fea04ef..c604e66507e 100644
--- a/src/test/compile-fail/unique-vec-res.rs
+++ b/src/test/compile-fail/unique-vec-res.rs
@@ -10,15 +10,17 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
struct r {
- i: @mut int,
+ i: @Cell,
}
#[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(_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()));
}
diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs
index 8d6eaef8b34..3f789fa456a 100644
--- a/src/test/pretty/block-disambig.rs
+++ b/src/test/pretty/block-disambig.rs
@@ -14,6 +14,8 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
fn test1() { let val = @0; { } *val; }
fn test2() -> int { let val = @0; { } *val }
@@ -21,9 +23,9 @@ fn test2() -> int { let val = @0; { } *val }
struct S { eax: int }
fn test3() {
- let regs = @mut S {eax: 0};
+ let regs = @Cell::new(S {eax: 0});
match true { true => { } _ => { } }
- (*regs).eax = 1;
+ regs.set(S {eax: 1});
}
fn test4() -> bool { let regs = @true; if true { } *regs || false }
@@ -51,10 +53,13 @@ fn test8() -> int {
}
}
-fn test9() { let regs = @mut 0; match true { true => { } _ => { } } *regs += 1; }
+fn test9() {
+ let regs = @Cell::new(0);
+ match true { true => { } _ => { } } regs.set(regs.get() + 1);
+}
fn test10() -> int {
- let regs = @mut ~[0];
+ let regs = @~[0];
match true { true => { } _ => { } }
(*regs)[0]
}
diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs
index b87303467ce..09e7d0bc28c 100644
--- a/src/test/run-fail/unwind-misc-1.rs
+++ b/src/test/run-fail/unwind-misc-1.rs
@@ -14,7 +14,7 @@
#[feature(managed_boxes)];
fn main() {
- let _count = @mut 0u;
+ let _count = @0u;
let mut map = std::hashmap::HashMap::new();
let mut arr = ~[];
for _i in range(0u, 10u) {
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 8f7f8c4fa58..02ce1fd4b26 100644
--- a/src/test/run-pass/alignment-gep-tup-like-2.rs
+++ b/src/test/run-pass/alignment-gep-tup-like-2.rs
@@ -10,6 +10,8 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
+
struct Pair {
a: A, b: B
}
@@ -17,12 +19,15 @@ struct Pair {
struct RecEnum(Rec);
struct Rec {
val: A,
- rec: Option<@mut RecEnum>
+ rec: Option<@RefCell>>
}
fn make_cycle(a: A) {
- let g: @mut RecEnum = @mut RecEnum(Rec {val: a, rec: None});
- g.rec = Some(g);
+ let g: @RefCell> = @RefCell::new(RecEnum(Rec {val: a, rec: None}));
+ {
+ let mut gb = g.borrow_mut();
+ gb.get().rec = Some(g);
+ }
}
struct Invoker {
diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs
index 1810f33eadb..8058556a469 100644
--- a/src/test/run-pass/auto-encode.rs
+++ b/src/test/run-pass/auto-encode.rs
@@ -35,8 +35,8 @@ fn test_ebml<'a, A:
Encodable +
Decodable>
>(a1: &A) {
- let mut wr = @mut std::io::mem::MemWriter::new();
- let mut ebml_w = EBWriter::Encoder(wr);
+ let mut wr = std::io::mem::MemWriter::new();
+ let mut ebml_w = EBWriter::Encoder(&mut wr);
a1.encode(&mut ebml_w);
let bytes = wr.inner_ref().as_slice();
diff --git a/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs b/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs
index 3f6bcb4d5b7..8871035908b 100644
--- a/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs
+++ b/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs
@@ -12,15 +12,18 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
+
pub fn main() {
- let x: @mut @Option<~int> = @mut @None;
- match x {
- @@Some(ref _y) => {
+ let x: @RefCell<@Option<~int>> = @RefCell::new(@None);
+ let mut xb = x.borrow_mut();
+ match *xb.get() {
+ @Some(ref _y) => {
// here, the refcount of `*x` is bumped so
// `_y` remains valid even if `*x` is modified.
- *x = @None;
+ *xb.get() = @None;
}
- @@None => {
+ @None => {
// here, no bump of the ref count of `*x` is needed, but in
// fact a bump occurs anyway because of how pattern marching
// works.
diff --git a/src/test/run-pass/borrowck-preserve-box-in-pat.rs b/src/test/run-pass/borrowck-preserve-box-in-pat.rs
index 2fd2c689a3c..b333bcae582 100644
--- a/src/test/run-pass/borrowck-preserve-box-in-pat.rs
+++ b/src/test/run-pass/borrowck-preserve-box-in-pat.rs
@@ -12,23 +12,25 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
use std::ptr;
struct F { f: ~int }
pub fn main() {
- let x = @mut @F {f: ~3};
- match x {
- @@F{f: ref b_x} => {
+ let x = @RefCell::new(@F {f: ~3});
+ let mut xb = x.borrow_mut();
+ match *xb.get() {
+ @F{f: ref b_x} => {
assert_eq!(**b_x, 3);
- assert_eq!(ptr::to_unsafe_ptr(&(x.f)), ptr::to_unsafe_ptr(b_x));
+ assert_eq!(ptr::to_unsafe_ptr(&(xb.get().f)), ptr::to_unsafe_ptr(b_x));
- *x = @F {f: ~4};
+ *xb.get() = @F {f: ~4};
info!("ptr::to_unsafe_ptr(*b_x) = {:x}",
ptr::to_unsafe_ptr(&(**b_x)) as uint);
assert_eq!(**b_x, 3);
- assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
+ assert!(ptr::to_unsafe_ptr(&(*xb.get().f)) != ptr::to_unsafe_ptr(&(**b_x)));
}
}
}
diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs
index aaa08ea49b3..97d92f421c1 100644
--- a/src/test/run-pass/borrowck-univariant-enum.rs
+++ b/src/test/run-pass/borrowck-univariant-enum.rs
@@ -10,6 +10,8 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
enum newtype {
newtype(int)
}
@@ -19,12 +21,12 @@ pub fn main() {
// Test that borrowck treats enums with a single variant
// specially.
- let x = @mut 5;
- let y = @mut newtype(3);
- let z = match *y {
+ let x = @Cell::new(5);
+ let y = @Cell::new(newtype(3));
+ let z = match y.get() {
newtype(b) => {
- *x += 1;
- *x * b
+ x.set(x.get() + 1);
+ x.get() * b
}
};
assert_eq!(z, 18);
diff --git a/src/test/run-pass/cast-mutable-trait.rs b/src/test/run-pass/cast-mutable-trait.rs
deleted file mode 100644
index 09d10502b84..00000000000
--- a/src/test/run-pass/cast-mutable-trait.rs
+++ /dev/null
@@ -1,36 +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 or the MIT license
-// , 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 bar(t: @mut T) {
- t.foo();
-}
-
-pub fn main() {
- let s = @mut S { unused: 0 };
- let s2 = s as @mut T;
- s2.foo();
- bar(s2);
- bar(s as @mut T);
-}
diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs
index e44d7c41931..8c142768944 100644
--- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs
+++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs
@@ -11,86 +11,92 @@
#[feature(managed_boxes)];
trait noisy {
- fn speak(&self) -> int;
+ fn speak(&mut self) -> int;
}
struct dog {
- priv barks : @mut uint,
+ priv barks: uint,
- volume : @mut int,
+ volume: int,
}
impl dog {
- fn bark(&self) -> int {
- info!("Woof {} {}", *self.barks, *self.volume);
- *self.barks += 1u;
- if *self.barks % 3u == 0u {
- *self.volume += 1;
+ fn bark(&mut self) -> int {
+ info!("Woof {} {}", self.barks, self.volume);
+ self.barks += 1u;
+ if self.barks % 3u == 0u {
+ self.volume += 1;
}
- if *self.barks % 10u == 0u {
- *self.volume -= 2;
+ if self.barks % 10u == 0u {
+ self.volume -= 2;
}
- info!("Grrr {} {}", *self.barks, *self.volume);
- *self.volume
+ info!("Grrr {} {}", self.barks, self.volume);
+ self.volume
}
}
impl noisy for dog {
- fn speak(&self) -> int { self.bark() }
+ fn speak(&mut self) -> int {
+ self.bark()
+ }
}
fn dog() -> dog {
dog {
- volume: @mut 0,
- barks: @mut 0u
+ volume: 0,
+ barks: 0u
}
}
#[deriving(Clone)]
struct cat {
- priv meows : @mut uint,
+ priv meows: uint,
- how_hungry : @mut int,
- name : ~str,
+ how_hungry: int,
+ name: ~str,
}
impl noisy for cat {
- fn speak(&self) -> int { self.meow() as int }
-}
-
-impl cat {
- pub fn meow_count(&self) -> uint { *self.meows }
-}
-
-impl cat {
- fn meow(&self) -> uint {
- info!("Meow");
- *self.meows += 1u;
- if *self.meows % 5u == 0u {
- *self.how_hungry += 1;
- }
- *self.meows
+ fn speak(&mut self) -> int {
+ self.meow() as int
}
}
-fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
+impl cat {
+ pub fn meow_count(&self) -> uint {
+ self.meows
+ }
+}
+
+impl cat {
+ fn meow(&mut self) -> uint {
+ info!("Meow");
+ self.meows += 1u;
+ if self.meows % 5u == 0u {
+ self.how_hungry += 1;
+ }
+ self.meows
+ }
+}
+
+fn cat(in_x: uint, in_y: int, in_name: ~str) -> cat {
cat {
- meows: @mut in_x,
- how_hungry: @mut in_y,
+ meows: in_x,
+ how_hungry: in_y,
name: in_name
}
}
-fn annoy_neighbors(critter: @noisy) {
+fn annoy_neighbors(critter: &mut noisy) {
for _i in range(0u, 10) { critter.speak(); }
}
pub fn main() {
- let nyan : cat = cat(0u, 2, ~"nyan");
- let whitefang : dog = dog();
- annoy_neighbors(@nyan.clone() as @noisy);
- annoy_neighbors(@whitefang as @noisy);
+ let mut nyan: cat = cat(0u, 2, ~"nyan");
+ let mut whitefang: dog = dog();
+ annoy_neighbors(&mut nyan);
+ annoy_neighbors(&mut whitefang);
assert_eq!(nyan.meow_count(), 10u);
- assert_eq!(*whitefang.volume, 1);
+ assert_eq!(whitefang.volume, 1);
}
diff --git a/src/test/run-pass/class-cast-to-trait.rs b/src/test/run-pass/class-cast-to-trait.rs
index cc723f8037d..86764df6ae0 100644
--- a/src/test/run-pass/class-cast-to-trait.rs
+++ b/src/test/run-pass/class-cast-to-trait.rs
@@ -58,6 +58,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
pub fn main() {
- let nyan: @mut noisy = @mut cat(0u, 2, ~"nyan") as @mut noisy;
- nyan.speak();
+ let mut nyan = cat(0u, 2, ~"nyan");
+ let mut nyan: &mut noisy = &mut nyan;
+ nyan.speak();
}
diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs
index 29a972ae30e..ca1e18eb87b 100644
--- a/src/test/run-pass/cycle-collection.rs
+++ b/src/test/run-pass/cycle-collection.rs
@@ -10,14 +10,16 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
+
enum taggy {
- cons(@mut taggy),
+ cons(@RefCell),
nil,
}
fn f() {
- let a_box = @mut nil;
- *a_box = cons(a_box);
+ let a_box = @RefCell::new(nil);
+ a_box.set(cons(a_box));
}
pub fn main() {
diff --git a/src/test/run-pass/cycle-collection2.rs b/src/test/run-pass/cycle-collection2.rs
deleted file mode 100644
index f10592bf800..00000000000
--- a/src/test/run-pass/cycle-collection2.rs
+++ /dev/null
@@ -1,42 +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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-struct foo {
- z: Option<@Invokable>,
-}
-
-struct Thing {
- w: @mut foo,
-}
-
-trait Invokable {
- fn f(&self);
-}
-
-impl Invokable for Thing {
- fn f(&self) {
- nop_foo(self.w);
- }
-}
-
-fn nop() { }
-fn nop_foo(_x : @mut foo) { }
-
-pub fn main() {
- let w = @mut foo {
- z: None,
- };
- let x = @Thing {
- w: w,
- } as @Invokable;
- w.z = Some(x);
-}
diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs
index 997e2f03abd..914805c126f 100644
--- a/src/test/run-pass/deref-lval.rs
+++ b/src/test/run-pass/deref-lval.rs
@@ -10,4 +10,10 @@
#[feature(managed_boxes)];
-pub fn main() { let x = @mut 5; *x = 1000; info!("{:?}", *x); }
+use std::cell::Cell;
+
+pub fn main() {
+ let x = @Cell::new(5);
+ x.set(1000);
+ info!("{:?}", x.get());
+}
diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs
index 4f4e9c9ce00..9194304a376 100644
--- a/src/test/run-pass/deriving-encodable-decodable.rs
+++ b/src/test/run-pass/deriving-encodable-decodable.rs
@@ -58,8 +58,8 @@ struct G {
fn roundtrip<'a, T: Rand + Eq + Encodable +
Decodable>>() {
let obj: T = random();
- let w = @mut MemWriter::new();
- let mut e = Encoder(w);
+ let mut w = MemWriter::new();
+ let mut e = Encoder(&mut w);
obj.encode(&mut e);
let doc = ebml::reader::Doc(@w.inner_ref().to_owned());
let mut dec = Decoder(doc);
diff --git a/src/test/run-pass/deriving-zero.rs b/src/test/run-pass/deriving-zero.rs
index 0cff8e8a3f8..d28e54d57ad 100644
--- a/src/test/run-pass/deriving-zero.rs
+++ b/src/test/run-pass/deriving-zero.rs
@@ -30,7 +30,7 @@ struct Lots {
e: char,
f: f64,
g: (f32, char),
- h: @mut (int, int),
+ h: @(int, int),
i: bool,
j: (),
}
diff --git a/src/test/run-pass/explicit-self-closures.rs b/src/test/run-pass/explicit-self-closures.rs
index ce662bafd49..c7e5681c0c1 100644
--- a/src/test/run-pass/explicit-self-closures.rs
+++ b/src/test/run-pass/explicit-self-closures.rs
@@ -18,9 +18,6 @@ impl Box {
pub fn set_many(&mut self, xs: &[uint]) {
for x in xs.iter() { self.x = *x; }
}
- pub fn set_many2(@mut self, xs: &[uint]) {
- for x in xs.iter() { self.x = *x; }
- }
}
pub fn main() {}
diff --git a/src/test/run-pass/expr-repeat-vstore.rs b/src/test/run-pass/expr-repeat-vstore.rs
index 2831740deaf..e1be481099c 100644
--- a/src/test/run-pass/expr-repeat-vstore.rs
+++ b/src/test/run-pass/expr-repeat-vstore.rs
@@ -13,10 +13,4 @@ pub fn main() {
println(v[2].to_str());
println(v[3].to_str());
println(v[4].to_str());
- let v: @mut [int] = @mut [ 3, ..5 ];
- println((v[0]).to_str());
- println((v[1]).to_str());
- println((v[2]).to_str());
- println((v[3]).to_str());
- println((v[4]).to_str());
}
diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs
index 27f30fb8ba9..d9505e01de9 100644
--- a/src/test/run-pass/exterior.rs
+++ b/src/test/run-pass/exterior.rs
@@ -10,15 +10,21 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
struct Point {x: int, y: int, z: int}
-fn f(p: @mut Point) { assert!((p.z == 12)); p.z = 13; assert!((p.z == 13)); }
+fn f(p: @Cell) {
+ assert!((p.get().z == 12));
+ p.set(Point {x: 10, y: 11, z: 13});
+ assert!((p.get().z == 13));
+}
pub fn main() {
let a: Point = Point {x: 10, y: 11, z: 12};
- let b: @mut Point = @mut a;
- assert_eq!(b.z, 12);
+ let b: @Cell = @Cell::new(a);
+ assert_eq!(b.get().z, 12);
f(b);
assert_eq!(a.z, 12);
- assert_eq!(b.z, 13);
+ assert_eq!(b.get().z, 13);
}
diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs
index 49aa8d18e90..905fa42635b 100644
--- a/src/test/run-pass/hashmap-memory.rs
+++ b/src/test/run-pass/hashmap-memory.rs
@@ -40,7 +40,7 @@ mod map_reduce {
}
fn map_task(ctrl: SharedChan, input: ~str) {
- let intermediates = @mut HashMap::new();
+ let mut intermediates = HashMap::new();
fn emit(im: &mut HashMap<~str, int>,
ctrl: SharedChan, key: ~str,
@@ -58,7 +58,7 @@ mod map_reduce {
}
let ctrl_clone = ctrl.clone();
- ::map(input, |a,b| emit(intermediates, ctrl.clone(), a, b) );
+ ::map(input, |a,b| emit(&mut intermediates, ctrl.clone(), a, b) );
ctrl_clone.send(mapper_done);
}
diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs
index 5181ec6f71d..ede67275ba9 100644
--- a/src/test/run-pass/init-res-into-things.rs
+++ b/src/test/run-pass/init-res-into-things.rs
@@ -10,11 +10,13 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
// Resources can't be copied, but storing into data structures counts
// as a move unless the stored thing is used afterwards.
struct r {
- i: @mut int,
+ i: @Cell,
}
struct Box { x: r }
@@ -22,30 +24,30 @@ struct Box { x: r }
#[unsafe_destructor]
impl Drop for r {
fn drop(&mut self) {
- *(self.i) = *(self.i) + 1;
+ self.i.set(self.i.get() + 1)
}
}
-fn r(i: @mut int) -> r {
+fn r(i: @Cell) -> r {
r {
i: i
}
}
fn test_box() {
- let i = @mut 0;
+ let i = @Cell::new(0);
{
let _a = @r(i);
}
- assert_eq!(*i, 1);
+ assert_eq!(i.get(), 1);
}
fn test_rec() {
- let i = @mut 0;
+ let i = @Cell::new(0);
{
let _a = Box {x: r(i)};
}
- assert_eq!(*i, 1);
+ assert_eq!(i.get(), 1);
}
fn test_tag() {
@@ -53,37 +55,37 @@ fn test_tag() {
t0(r),
}
- let i = @mut 0;
+ let i = @Cell::new(0);
{
let _a = t0(r(i));
}
- assert_eq!(*i, 1);
+ assert_eq!(i.get(), 1);
}
fn test_tup() {
- let i = @mut 0;
+ let i = @Cell::new(0);
{
let _a = (r(i), 0);
}
- assert_eq!(*i, 1);
+ assert_eq!(i.get(), 1);
}
fn test_unique() {
- let i = @mut 0;
+ let i = @Cell::new(0);
{
let _a = ~r(i);
}
- assert_eq!(*i, 1);
+ assert_eq!(i.get(), 1);
}
fn test_box_rec() {
- let i = @mut 0;
+ let i = @Cell::new(0);
{
let _a = @Box {
x: r(i)
};
}
- assert_eq!(*i, 1);
+ assert_eq!(i.get(), 1);
}
pub fn main() {
diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs
index bc76fa74dbd..dc46bef4ed4 100644
--- a/src/test/run-pass/issue-2631-b.rs
+++ b/src/test/run-pass/issue-2631-b.rs
@@ -16,11 +16,12 @@
extern mod req;
use req::request;
+use std::cell::RefCell;
use std::hashmap::HashMap;
pub fn main() {
let v = ~[@~"hi"];
let mut m: req::header_map = HashMap::new();
- m.insert(~"METHOD", @mut v);
+ m.insert(~"METHOD", @RefCell::new(v));
request::(&m);
}
diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs
index 85b6e80be7c..44222315dcd 100644
--- a/src/test/run-pass/issue-2735-2.rs
+++ b/src/test/run-pass/issue-2735-2.rs
@@ -10,26 +10,28 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
// This test should behave exactly like issue-2735-3
struct defer {
- b: @mut bool,
+ b: @Cell,
}
#[unsafe_destructor]
impl Drop for defer {
fn drop(&mut self) {
- *self.b = true;
+ self.b.set(true);
}
}
-fn defer(b: @mut bool) -> defer {
+fn defer(b: @Cell) -> defer {
defer {
b: b
}
}
pub fn main() {
- let dtor_ran = @mut false;
+ let dtor_ran = @Cell::new(false);
let _ = defer(dtor_ran);
- assert!(*dtor_ran);
+ assert!(dtor_ran.get());
}
diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs
index 401a43f8b25..f48e763966b 100644
--- a/src/test/run-pass/issue-2735-3.rs
+++ b/src/test/run-pass/issue-2735-3.rs
@@ -10,26 +10,28 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
// This test should behave exactly like issue-2735-2
struct defer {
- b: @mut bool,
+ b: @Cell,
}
#[unsafe_destructor]
impl Drop for defer {
fn drop(&mut self) {
- *self.b = true;
+ self.b.set(true);
}
}
-fn defer(b: @mut bool) -> defer {
+fn defer(b: @Cell) -> defer {
defer {
b: b
}
}
pub fn main() {
- let dtor_ran = @mut false;
+ let dtor_ran = @Cell::new(false);
defer(dtor_ran);
- assert!(*dtor_ran);
+ assert!(dtor_ran.get());
}
diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs
index 5208995a0c7..dc2f59f1481 100644
--- a/src/test/run-pass/issue-2904.rs
+++ b/src/test/run-pass/issue-2904.rs
@@ -62,8 +62,8 @@ fn square_from_char(c: char) -> square {
}
}
-fn read_board_grid(input: rdr) -> ~[~[square]] {
- let input = @mut input as @mut io::Reader;
+fn read_board_grid(mut input: rdr) -> ~[~[square]] {
+ let mut input: &mut io::Reader = &mut input;
let mut grid = ~[];
let mut line = [0, ..10];
input.read(line);
diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs
index 7ae3e43c579..3d56abb3de6 100644
--- a/src/test/run-pass/issue-3447.rs
+++ b/src/test/run-pass/issue-3447.rs
@@ -10,11 +10,13 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
+
static S: &'static str = "str";
struct list {
element: T,
- next: Option<@mut list>
+ next: Option<@RefCell>>
}
impl list {
@@ -24,7 +26,7 @@ impl list {
next: None
};
- self.next = Some(@mut newList);
+ self.next = Some(@RefCell::new(newList));
}
}
diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs
deleted file mode 100644
index 8a30cc96748..00000000000
--- a/src/test/run-pass/issue-3860.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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-struct Foo { x: int }
-
-impl Foo {
- pub fn stuff<'a>(&'a mut self) -> &'a mut Foo {
- return self;
- }
-}
-
-pub fn main() {
- let x = @mut Foo { x: 3 };
- // Neither of the next two lines should cause an error
- let _ = x.stuff();
- x.stuff();
-}
diff --git a/src/test/run-pass/issue-5275.rs b/src/test/run-pass/issue-5275.rs
deleted file mode 100644
index 088376c1068..00000000000
--- a/src/test/run-pass/issue-5275.rs
+++ /dev/null
@@ -1,31 +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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-// Regression test for issue #5275
-
-fn foo(self_: &A) -> int {
- if true {
- fail!()
- } else {
- *bar(self_.bar)
- }
-}
-
-fn bar<'r>(_: &'r mut int) -> &'r int {
- fail!()
-}
-
-struct A {
- bar: @mut int,
-}
-
-pub fn main() {}
diff --git a/src/test/run-pass/issue-5517.rs b/src/test/run-pass/issue-5517.rs
deleted file mode 100644
index a5c318a20f4..00000000000
--- a/src/test/run-pass/issue-5517.rs
+++ /dev/null
@@ -1,16 +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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-pub fn main() {
- let box1 = @mut 42;
- let _x = *(&mut *box1) == 42 || *(&mut *box1) == 31337;
-}
diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs
index 08d8abc1d50..ca83e783268 100644
--- a/src/test/run-pass/issue-979.rs
+++ b/src/test/run-pass/issue-979.rs
@@ -10,28 +10,30 @@
#[feature(managed_boxes)];
+use std::cell::Cell;
+
struct r {
- b: @mut int,
+ b: @Cell,
}
#[unsafe_destructor]
impl Drop for r {
fn drop(&mut self) {
- *(self.b) += 1;
+ self.b.set(self.b.get() + 1);
}
}
-fn r(b: @mut int) -> r {
+fn r(b: @Cell) -> r {
r {
b: b
}
}
pub fn main() {
- let b = @mut 0;
+ let b = @Cell::new(0);
{
let _p = Some(r(b));
}
- assert_eq!(*b, 1);
+ assert_eq!(b.get(), 1);
}
diff --git a/src/test/run-pass/issue-980.rs b/src/test/run-pass/issue-980.rs
index 2f94dc77690..f6dc4adcf9b 100644
--- a/src/test/run-pass/issue-980.rs
+++ b/src/test/run-pass/issue-980.rs
@@ -10,16 +10,20 @@
#[feature(managed_boxes)];
+use std::cell::RefCell;
+
enum maybe_pointy {
no_pointy,
- yes_pointy(@mut Pointy),
+ yes_pointy(@RefCell),
}
struct Pointy {
- x : maybe_pointy
+ x: maybe_pointy
}
pub fn main() {
- let m = @mut Pointy { x : no_pointy };
- m.x = yes_pointy(m);
+ let m = @RefCell::new(Pointy { x : no_pointy });
+ m.set(Pointy {
+ x: yes_pointy(m)
+ });
}
diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs
index a499c148025..65f95f78ea8 100644
--- a/src/test/run-pass/lambda-infer-unresolved.rs
+++ b/src/test/run-pass/lambda-infer-unresolved.rs
@@ -11,12 +11,10 @@
// This should typecheck even though the type of e is not fully
// resolved when we finish typechecking the ||.
-#[feature(managed_boxes)];
-
struct Refs { refs: ~[int], n: int }
pub fn main() {
- let e = @mut Refs{refs: ~[], n: 0};
+ let mut e = Refs{refs: ~[], n: 0};
let _f: || = || error!("{}", e.n);
e.refs.push(1);
}
diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs
deleted file mode 100644
index e4dd3b56fca..00000000000
--- a/src/test/run-pass/log-linearized.rs
+++ /dev/null
@@ -1,36 +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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-// Tests that shapes respect linearize_ty_params().
-
-enum option {
- none,
- some(T),
-}
-
-struct Smallintmap {v: ~[option]}
-
-struct V { v: ~[option] }
-
-fn mk() -> @mut Smallintmap {
- let v: ~[option] = ~[];
- return @mut Smallintmap {v: v};
-}
-
-fn f() {
- let sim = mk::();
- error!("{:?}", sim);
-}
-
-pub fn main() {
- f::();
-}
diff --git a/src/test/run-pass/logging-only-prints-once.rs b/src/test/run-pass/logging-only-prints-once.rs
index 6a88b804c22..fb352ea0708 100644
--- a/src/test/run-pass/logging-only-prints-once.rs
+++ b/src/test/run-pass/logging-only-prints-once.rs
@@ -11,25 +11,24 @@
// xfail-fast
// exec-env:RUST_LOG=debug
-#[feature(managed_boxes)];
-
+use std::cell::Cell;
use std::fmt;
-struct Foo(@mut int);
+struct Foo(Cell);
impl fmt::Default for Foo {
fn fmt(f: &Foo, _fmt: &mut fmt::Formatter) {
- assert!(***f == 0);
- ***f = 1;
+ assert!(f.get() == 0);
+ f.set(1);
}
}
pub fn main() {
let (p,c) = Chan::new();
do spawn {
- let f = Foo(@mut 0);
+ let mut f = Foo(Cell::new(0));
debug!("{}", f);
- assert!(**f == 1);
+ assert!(f.get() == 1);
c.send(());
}
p.recv();
diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs
deleted file mode 100644
index 66e7fc4265b..00000000000
--- a/src/test/run-pass/mlist-cycle.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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-test
-extern mod std;
-use std::gc;
-use std::gc::rustrt;
-
-struct cell {c: @list}
-
-enum list { link(@mut cell), nil, }
-
-pub fn main() {
- let first: @cell = @mut cell{c: @nil()};
- let second: @cell = @mut cell{c: @link(first)};
- first._0 = @link(second);
- rustrt::gc();
- let third: @cell = @mut cell{c: @nil()};
-}
diff --git a/src/test/run-pass/new-vstore-mut-box-syntax.rs b/src/test/run-pass/new-vstore-mut-box-syntax.rs
deleted file mode 100644
index 4a2756f5446..00000000000
--- a/src/test/run-pass/new-vstore-mut-box-syntax.rs
+++ /dev/null
@@ -1,16 +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 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#[feature(managed_boxes)];
-
-pub fn main() {
- let _x: @mut [int] = @mut [ 1, 2, 3 ];
-
-}
diff --git a/src/test/run-pass/newtype-struct-drop-run.rs b/src/test/run-pass/newtype-struct-drop-run.rs
index 8d1333941f7..f190a5102d2 100644
--- a/src/test/run-pass/newtype-struct-drop-run.rs
+++ b/src/test/run-pass/newtype-struct-drop-run.rs
@@ -12,19 +12,21 @@
// Make sure the destructor is run for newtype structs.
-struct Foo(@mut int);
+use std::cell::Cell;
+
+struct Foo(@Cell);
#[unsafe_destructor]
impl Drop for Foo {
fn drop(&mut self) {
- ***self = 23;
+ self.set(23);
}
}
pub fn main() {
- let y = @mut 32;
+ let y = @Cell::new(32);
{
let _x = Foo(y);
}
- assert_eq!(*y, 23);
+ assert_eq!(y.get(), 23);
}
diff --git a/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs b/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs
index f0955ab8efa..52792c8c427 100644
--- a/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs
+++ b/src/test/run-pass/objects-coerce-from-managed-to-borrowed.rs
@@ -14,24 +14,12 @@
trait Foo {
fn foo(&self) -> uint;
- fn bar(&mut self) -> uint;
}
impl Foo for uint {
fn foo(&self) -> uint {
*self
}
-
- fn bar(&mut self) -> uint {
- *self += 1;
- *self
- }
-}
-
-fn do_it_mut(obj: &mut Foo) {
- let x = obj.bar();
- let y = obj.foo();
- assert_eq!(x, y);
}
fn do_it_imm(obj: &Foo, v: uint) {
@@ -40,7 +28,6 @@ fn do_it_imm(obj: &Foo, v: uint) {
}
pub fn main() {
- let x = @mut 22u as @mut Foo;
- do_it_mut(x);
- do_it_imm(x, 23u);
+ let x = @22u as @Foo;
+ do_it_imm(x, 22u);
}
diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs
index ab9d5b9d2bf..0806bcd185e 100644
--- a/src/test/run-pass/option-unwrap.rs
+++ b/src/test/run-pass/option-unwrap.rs
@@ -10,16 +10,17 @@
#[feature(managed_boxes)];
-struct dtor {
- x: @mut int,
+use std::cell::Cell;
+struct dtor {
+ x: @Cell,
}
#[unsafe_destructor]
impl Drop for dtor {
fn drop(&mut self) {
// abuse access to shared mutable state to write this code
- *self.x -= 1;
+ self.x.set(self.x.get() - 1);
}
}
@@ -31,12 +32,12 @@ fn unwrap(o: Option) -> T {
}
pub fn main() {
- let x = @mut 1;
+ let x = @Cell::new(1);
{
let b = Some(dtor { x:x });
let _c = unwrap(b);
}
- assert_eq!(*x, 0);
+ assert_eq!(x.get(), 0);
}
diff --git a/src/test/run-pass/packed-struct-generic-size.rs b/src/test/run-pass/packed-struct-generic-size.rs
index 1d3d8cf736f..cba923ef646 100644
--- a/src/test/run-pass/packed-struct-generic-size.rs
+++ b/src/test/run-pass/packed-struct-generic-size.rs
@@ -22,6 +22,6 @@ pub fn main() {
assert_eq!(mem::size_of::>(), 11);
- assert_eq!(mem::size_of::>(),
- 1 + mem::size_of::<~str>() + mem::size_of::<@mut [int]>());
+ assert_eq!(mem::size_of::>(),
+ 1 + mem::size_of::<~str>() + mem::size_of::<@[int]>());
}
diff --git a/src/test/run-pass/packed-struct-size.rs b/src/test/run-pass/packed-struct-size.rs
index c6550f24d5c..f694cc98ad3 100644
--- a/src/test/run-pass/packed-struct-size.rs
+++ b/src/test/run-pass/packed-struct-size.rs
@@ -49,7 +49,7 @@ struct S7_Option {
a: f32,
b: u8,
c: u16,
- d: Option<@mut f64>
+ d: Option<@f64>
}
// Placing packed structs in statics should work
@@ -63,5 +63,5 @@ pub fn main() {
assert_eq!(mem::size_of::(), 5);
assert_eq!(mem::size_of::(), 13 + mem::size_of::<~str>());
assert_eq!(mem::size_of::(), 3 + mem::size_of::());
- assert_eq!(mem::size_of::(), 7 + mem::size_of::