Skip to content

Commit 82062a6

Browse files
committed
test: De-mut the test suite. rs=demuting
1 parent 1144fdd commit 82062a6

Some content is hidden

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

65 files changed

+311
-450
lines changed

src/test/auxiliary/issue_3882.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
mod issue_3882 {
1212
struct Completions {
13-
mut len: libc::size_t,
13+
len: libc::size_t,
1414
}
1515

1616
extern mod c {
17-
fn linenoiseAddCompletion(lc: *Completions);
17+
fn linenoiseAddCompletion(lc: *mut Completions);
1818
}
1919
}

src/test/bench/shootout-fasta.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ use io::WriterUtil;
2121
fn LINE_LENGTH() -> uint { return 60u; }
2222

2323
struct MyRandom {
24-
mut last: u32
24+
last: u32
2525
}
2626

27-
fn myrandom_next(r: @MyRandom, mx: u32) -> u32 {
27+
fn myrandom_next(r: @mut MyRandom, mx: u32) -> u32 {
2828
r.last = (r.last * 3877u32 + 29573u32) % 139968u32;
2929
mx * r.last / 139968u32
3030
}
@@ -59,7 +59,7 @@ fn select_random(r: u32, genelist: ~[AminoAcids]) -> char {
5959

6060
fn make_random_fasta(wr: io::Writer, id: ~str, desc: ~str, genelist: ~[AminoAcids], n: int) {
6161
wr.write_line(~">" + id + ~" " + desc);
62-
let rng = @MyRandom {mut last: rand::Rng().next()};
62+
let rng = @mut MyRandom {last: rand::Rng().next()};
6363
let mut op: ~str = ~"";
6464
for uint::range(0u, n as uint) |_i| {
6565
str::push_char(&mut op, select_random(myrandom_next(rng, 100u32),

src/test/bench/shootout-nbody.rs

+57-44
Original file line numberDiff line numberDiff line change
@@ -170,67 +170,80 @@ mod Body {
170170
// was 4 * PI * PI originally
171171
pub const DAYS_PER_YEAR: float = 365.24;
172172

173-
pub struct Props
174-
{mut x: float,
175-
mut y: float,
176-
mut z: float,
177-
mut vx: float,
178-
mut vy: float,
179-
mut vz: float,
180-
mass: float}
173+
pub struct Props {
174+
x: float,
175+
y: float,
176+
z: float,
177+
vx: float,
178+
vy: float,
179+
vz: float,
180+
mass: float
181+
}
181182

182183
pub fn jupiter() -> Body::Props {
183-
return Props {mut x: 4.84143144246472090e+00,
184-
mut y: -1.16032004402742839e+00,
185-
mut z: -1.03622044471123109e-01,
186-
mut vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
187-
mut vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
188-
mut vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
189-
mass: 9.54791938424326609e-04 * SOLAR_MASS};
184+
return Props {
185+
x: 4.84143144246472090e+00,
186+
y: -1.16032004402742839e+00,
187+
z: -1.03622044471123109e-01,
188+
vx: 1.66007664274403694e-03 * DAYS_PER_YEAR,
189+
vy: 7.69901118419740425e-03 * DAYS_PER_YEAR,
190+
vz: -6.90460016972063023e-05 * DAYS_PER_YEAR,
191+
mass: 9.54791938424326609e-04 * SOLAR_MASS
192+
};
190193
}
191194

192195
pub fn saturn() -> Body::Props {
193-
return Props {mut x: 8.34336671824457987e+00,
194-
mut y: 4.12479856412430479e+00,
195-
mut z: -4.03523417114321381e-01,
196-
mut vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
197-
mut vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
198-
mut vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
199-
mass: 2.85885980666130812e-04 * SOLAR_MASS};
196+
return Props {
197+
x: 8.34336671824457987e+00,
198+
y: 4.12479856412430479e+00,
199+
z: -4.03523417114321381e-01,
200+
vx: -2.76742510726862411e-03 * DAYS_PER_YEAR,
201+
vy: 4.99852801234917238e-03 * DAYS_PER_YEAR,
202+
vz: 2.30417297573763929e-05 * DAYS_PER_YEAR,
203+
mass: 2.85885980666130812e-04 * SOLAR_MASS
204+
};
200205
}
201206

202207
pub fn uranus() -> Body::Props {
203-
return Props {mut x: 1.28943695621391310e+01,
204-
mut y: -1.51111514016986312e+01,
205-
mut z: -2.23307578892655734e-01,
206-
mut vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
207-
mut vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
208-
mut vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
209-
mass: 4.36624404335156298e-05 * SOLAR_MASS};
208+
return Props {
209+
x: 1.28943695621391310e+01,
210+
y: -1.51111514016986312e+01,
211+
z: -2.23307578892655734e-01,
212+
vx: 2.96460137564761618e-03 * DAYS_PER_YEAR,
213+
vy: 2.37847173959480950e-03 * DAYS_PER_YEAR,
214+
vz: -2.96589568540237556e-05 * DAYS_PER_YEAR,
215+
mass: 4.36624404335156298e-05 * SOLAR_MASS
216+
};
210217
}
211218

212219
pub fn neptune() -> Body::Props {
213-
return Props {mut x: 1.53796971148509165e+01,
214-
mut y: -2.59193146099879641e+01,
215-
mut z: 1.79258772950371181e-01,
216-
mut vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
217-
mut vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
218-
mut vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
219-
mass: 5.15138902046611451e-05 * SOLAR_MASS};
220+
return Props {
221+
x: 1.53796971148509165e+01,
222+
y: -2.59193146099879641e+01,
223+
z: 1.79258772950371181e-01,
224+
vx: 2.68067772490389322e-03 * DAYS_PER_YEAR,
225+
vy: 1.62824170038242295e-03 * DAYS_PER_YEAR,
226+
vz: -9.51592254519715870e-05 * DAYS_PER_YEAR,
227+
mass: 5.15138902046611451e-05 * SOLAR_MASS
228+
};
220229
}
221230

222231
pub fn sun() -> Body::Props {
223-
return Props {mut x: 0.0,
224-
mut y: 0.0,
225-
mut z: 0.0,
226-
mut vx: 0.0,
227-
mut vy: 0.0,
228-
mut vz: 0.0,
229-
mass: SOLAR_MASS};
232+
return Props {
233+
x: 0.0,
234+
y: 0.0,
235+
z: 0.0,
236+
vx: 0.0,
237+
vy: 0.0,
238+
vz: 0.0,
239+
mass: SOLAR_MASS
240+
};
230241
}
231242

232243
pub fn offset_momentum(props: &mut Body::Props,
233-
px: float, py: float, pz: float) {
244+
px: float,
245+
py: float,
246+
pz: float) {
234247
props.vx = -px / SOLAR_MASS;
235248
props.vy = -py / SOLAR_MASS;
236249
props.vz = -pz / SOLAR_MASS;

src/test/compile-fail/borrowck-assign-comp.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
struct point {x: int, mut y: int }
11+
struct point { x: int, y: int }
1212

1313
fn a() {
1414
let mut p = point {x: 3, y: 4};
@@ -20,30 +20,21 @@ fn a() {
2020
p.x = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
2121
}
2222

23-
fn b() {
24-
let mut p = point {x: 3, mut y: 4};
25-
// This assignment is legal because `y` is inherently mutable (and
26-
// hence &_q.y is &mut int).
27-
let _q = &p;
28-
29-
p.y = 5;
30-
}
31-
3223
fn c() {
3324
// this is sort of the opposite. We take a loan to the interior of `p`
3425
// and then try to overwrite `p` as a whole.
3526

36-
let mut p = point {x: 3, mut y: 4};
27+
let mut p = point {x: 3, y: 4};
3728
let _q = &p.y; //~ NOTE loan of mutable local variable granted here
38-
p = point {x: 5, mut y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
29+
p = point {x: 5, y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
3930
copy p;
4031
}
4132

4233
fn d() {
4334
// just for completeness's sake, the easy case, where we take the
4435
// address of a subcomponent and then modify that subcomponent:
4536

46-
let mut p = point {x: 3, mut y: 4};
37+
let mut p = point {x: 3, y: 4};
4738
let _q = &p.y; //~ NOTE loan of mutable field granted here
4839
p.y = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
4940
copy p;

src/test/compile-fail/borrowck-call-sendfn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// xfail-test #2978
1212

13-
fn call(x: @{mut f: fn~()}) {
13+
fn call(x: @{f: fn~()}) {
1414
x.f(); //~ ERROR foo
1515
//~^ NOTE bar
1616
}

src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162-b.rs

-26
This file was deleted.

src/test/compile-fail/borrowck-imm-ref-to-mut-rec-field-issue-3162.rs

-25
This file was deleted.

src/test/compile-fail/borrowck-mut-field-imm-base.rs

-30
This file was deleted.

src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
// except according to those terms.
1010

1111
struct node_ {
12-
mut a: ~cycle
12+
a: ~cycle
1313
}
1414

1515
enum cycle {
1616
node(node_),
1717
empty
1818
}
1919
fn main() {
20-
let x = ~node(node_ {mut a: ~empty});
20+
let mut x = ~node(node_ {a: ~empty});
2121
// Create a cycle!
22-
match *x { //~ NOTE loan of immutable local variable granted here
23-
node(ref y) => {
24-
y.a = x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
22+
match *x { //~ NOTE loan of mutable local variable granted here
23+
node(ref mut y) => {
24+
y.a = x; //~ ERROR moving out of mutable local variable prohibited due to outstanding loan
2525
}
2626
empty => {}
2727
};

src/test/compile-fail/borrowck-uniq-via-box.rs

-12
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ fn box_mut(v: @mut ~int) {
1414
borrow(*v); //~ ERROR illegal borrow unless pure
1515
}
1616

17-
fn box_rec_mut(v: @{mut f: ~int}) {
18-
borrow(v.f); //~ ERROR illegal borrow unless pure
19-
}
20-
2117
fn box_mut_rec(v: @mut {f: ~int}) {
2218
borrow(v.f); //~ ERROR illegal borrow unless pure
2319
}
@@ -42,14 +38,6 @@ fn box_const(v: @const ~int) {
4238
borrow(*v); //~ ERROR illegal borrow unless pure
4339
}
4440

45-
fn box_rec_const(v: @{const f: ~int}) {
46-
borrow(v.f); //~ ERROR illegal borrow unless pure
47-
}
48-
49-
fn box_recs_const(v: @{f: {g: {const h: ~int}}}) {
50-
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
51-
}
52-
5341
fn box_const_rec(v: @const {f: ~int}) {
5442
borrow(v.f); //~ ERROR illegal borrow unless pure
5543
}

src/test/compile-fail/borrowck-uniq-via-ref.rs

-12
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ fn box_mut(v: &mut ~int) {
1414
borrow(*v); // OK: &mut -> &imm
1515
}
1616

17-
fn box_rec_mut(v: &{mut f: ~int}) {
18-
borrow(v.f); //~ ERROR illegal borrow unless pure
19-
}
20-
2117
fn box_mut_rec(v: &mut {f: ~int}) {
2218
borrow(v.f); // OK: &mut -> &imm
2319
}
@@ -42,14 +38,6 @@ fn box_const(v: &const ~int) {
4238
borrow(*v); //~ ERROR illegal borrow unless pure
4339
}
4440

45-
fn box_rec_const(v: &{const f: ~int}) {
46-
borrow(v.f); //~ ERROR illegal borrow unless pure
47-
}
48-
49-
fn box_recs_const(v: &{f: {g: {const h: ~int}}}) {
50-
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure
51-
}
52-
5341
fn box_const_rec(v: &const {f: ~int}) {
5442
borrow(v.f); //~ ERROR illegal borrow unless pure
5543
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
// xfail-test
12-
type T = { mut f: fn@() };
13-
type S = { f: fn@() };
12+
struct T { f: fn@() };
13+
struct S { f: fn@() };
1414

1515
fn fooS(t: S) {
1616
}
@@ -23,11 +23,11 @@ fn bar() {
2323

2424
fn main() {
2525
let x: fn@() = bar;
26-
fooS({f: x});
27-
fooS({f: bar});
26+
fooS(S {f: x});
27+
fooS(S {f: bar});
2828

2929
let x: fn@() = bar;
30-
fooT({mut f: x});
31-
fooT({mut f: bar});
30+
fooT(T {f: x});
31+
fooT(T {f: bar});
3232
}
3333

0 commit comments

Comments
 (0)