Skip to content

Commit c3694d7

Browse files
committed
test: De-@mut the test suite
1 parent df13c64 commit c3694d7

File tree

72 files changed

+351
-837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+351
-837
lines changed

src/test/auxiliary/cci_nested_lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010

1111
#[feature(managed_boxes)];
1212

13+
use std::cell::RefCell;
14+
1315
pub struct Entry<A,B> {
1416
key: A,
1517
value: B
1618
}
1719

1820
pub struct alist<A,B> {
1921
eq_fn: extern "Rust" fn(A,A) -> bool,
20-
data: @mut ~[Entry<A,B>]
22+
data: @RefCell<~[Entry<A,B>]>,
2123
}
2224

2325
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
24-
lst.data.push(Entry{key:k, value:v});
26+
let mut data = lst.data.borrow_mut();
27+
data.get().push(Entry{key:k, value:v});
2528
}
2629

2730
pub fn alist_get<A:Clone + 'static,
@@ -30,7 +33,8 @@ pub fn alist_get<A:Clone + 'static,
3033
k: A)
3134
-> B {
3235
let eq_fn = lst.eq_fn;
33-
for entry in lst.data.iter() {
36+
let data = lst.data.borrow();
37+
for entry in data.get().iter() {
3438
if eq_fn(entry.key.clone(), k.clone()) {
3539
return entry.value.clone();
3640
}
@@ -41,12 +45,18 @@ pub fn alist_get<A:Clone + 'static,
4145
#[inline]
4246
pub fn new_int_alist<B:'static>() -> alist<int, B> {
4347
fn eq_int(a: int, b: int) -> bool { a == b }
44-
return alist {eq_fn: eq_int, data: @mut ~[]};
48+
return alist {
49+
eq_fn: eq_int,
50+
data: @RefCell::new(~[]),
51+
};
4552
}
4653

4754
#[inline]
4855
pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
4956
#[inline]
5057
fn eq_int(a: int, b: int) -> bool { a == b }
51-
return alist {eq_fn: eq_int, data: @mut ~[]};
58+
return alist {
59+
eq_fn: eq_int,
60+
data: @RefCell::new(~[]),
61+
};
5262
}

src/test/auxiliary/issue-2631-a.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414

1515
extern mod extra;
1616

17+
use std::cell::RefCell;
1718
use std::hashmap::HashMap;
1819

19-
pub type header_map = HashMap<~str, @mut ~[@~str]>;
20+
pub type header_map = HashMap<~str, @RefCell<~[@~str]>>;
2021

2122
// the unused ty param is necessary so this gets monomorphized
2223
pub fn request<T>(req: &header_map) {
23-
let _x = (*((**req.get(&~"METHOD")).clone())[0u]).clone();
24+
let _x = (*((**req.get(&~"METHOD")).clone()).get()[0u]).clone();
2425
}

src/test/bench/sudoku.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Sudoku {
8686
return Sudoku::new(g)
8787
}
8888
89-
pub fn write(&self, writer: @mut io::Writer) {
89+
pub fn write(&self, writer: &mut io::Writer) {
9090
for row in range(0u8, 9u8) {
9191
write!(writer, "{}", self.grid[row][0]);
9292
for col in range(1u8, 9u8) {
@@ -280,5 +280,5 @@ fn main() {
280280
Sudoku::read(BufferedReader::new(io::stdin()))
281281
};
282282
sudoku.solve();
283-
sudoku.write(@mut io::stdout() as @mut io::Writer);
283+
sudoku.write(&mut io::stdout());
284284
}

src/test/compile-fail/cast-immutable-mutable-trait.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/test/compile-fail/fn-variance-1.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[feature(managed_boxes)];
11+
fn takes_imm(x: &int) { }
1212

13-
fn takes_mut(x: @mut int) { }
14-
fn takes_imm(x: @int) { }
13+
fn takes_mut(x: &mut int) { }
1514

1615
fn apply<T>(t: T, f: |T|) {
1716
f(t)
1817
}
1918

2019
fn main() {
21-
apply(@3, takes_mut); //~ ERROR (values differ in mutability)
22-
apply(@3, takes_imm);
20+
apply(&3, takes_mut); //~ ERROR (values differ in mutability)
21+
apply(&3, takes_imm);
2322

24-
apply(@mut 3, takes_mut);
25-
apply(@mut 3, takes_imm); //~ ERROR (values differ in mutability)
23+
apply(&mut 3, takes_mut);
24+
apply(&mut 3, takes_imm); //~ ERROR (values differ in mutability)
2625
}

src/test/compile-fail/issue-10487.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212

1313
static x: ~[int] = ~[123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
1414
static y: @[int] = @[123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
15-
static z: @mut [int] = @mut [123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
1615

1716
fn main() {}

src/test/compile-fail/issue-2548.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@
1212

1313
// A test case for #2548.
1414

15-
struct foo {
16-
x: @mut int,
17-
15+
use std::cell::Cell;
1816

17+
struct foo {
18+
x: @Cell<int>,
1919
}
2020

2121
#[unsafe_destructor]
2222
impl Drop for foo {
2323
fn drop(&mut self) {
2424
unsafe {
2525
println("Goodbye, World!");
26-
*self.x += 1;
26+
self.x.set(self.x.get() + 1);
2727
}
2828
}
2929
}
3030

31-
fn foo(x: @mut int) -> foo {
31+
fn foo(x: @Cell<int>) -> foo {
3232
foo { x: x }
3333
}
3434

3535
fn main() {
36-
let x = @mut 0;
36+
let x = @Cell::new(0);
3737

3838
{
3939
let mut res = foo(x);
@@ -43,5 +43,5 @@ fn main() {
4343
assert_eq!(v.len(), 2);
4444
}
4545

46-
assert_eq!(*x, 1);
46+
assert_eq!(x.get(), 1);
4747
}

src/test/compile-fail/issue-3668.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#[feature(managed_boxes)];
1212

13-
struct P { child: Option<@mut P> }
13+
struct P { child: Option<@P> }
1414
trait PTrait {
1515
fn getChildOption(&self) -> Option<@P>;
1616
}

src/test/compile-fail/kindck-destructor-owned.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#[feature(managed_boxes)];
22

33
struct Foo {
4-
f: @mut int,
4+
f: @int,
55
}
66

77
impl Drop for Foo { //~ ERROR cannot implement a destructor on a structure that does not satisfy Send
88
fn drop(&mut self) {
9-
*self.f = 10;
109
}
1110
}
1211

src/test/compile-fail/lub-in-args.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)