Skip to content

Commit 1a46dc4

Browse files
committed
---
yaml --- r: 41977 b: refs/heads/master c: e4d4a14 h: refs/heads/master i: 41975: 738b910 v: v3
1 parent c061020 commit 1a46dc4

File tree

8 files changed

+106
-87
lines changed

8 files changed

+106
-87
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6e2ae2c2c131bfbf2d8ab1b8ff9874e23abb7003
2+
refs/heads/master: e4d4a1499bfa1d09f15b6d10a0bd063b25574ce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libcore/gc.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ unsafe fn get_safe_point_count() -> uint {
8787
return *module_meta;
8888
}
8989

90-
type SafePoint = { sp_meta: *Word, fn_meta: *Word };
90+
struct SafePoint {
91+
sp_meta: *Word,
92+
fn_meta: *Word,
93+
}
9194

9295
// Returns the safe point metadata for the given program counter, if
9396
// any.
@@ -106,7 +109,10 @@ unsafe fn is_safe_point(pc: *Word) -> Option<SafePoint> {
106109
let sp: **Word = bump(safe_points, spi*3);
107110
let sp_loc = *sp;
108111
if sp_loc == pc {
109-
return Some({sp_meta: *bump(sp, 1), fn_meta: *bump(sp, 2)});
112+
return Some(SafePoint {
113+
sp_meta: *bump(sp, 1),
114+
fn_meta: *bump(sp, 2),
115+
});
110116
}
111117
spi += 1;
112118
}

trunk/src/libcore/io.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,9 @@ pub fn read_whole_file(file: &Path) -> Result<~[u8], ~str> {
10861086
// fsync related
10871087

10881088
pub mod fsync {
1089+
use prelude::*;
10891090
use io::{FILERes, FdRes, fd_t};
1090-
use kinds::Copy;
10911091
use libc;
1092-
use option::Option;
1093-
use option;
10941092
use os;
10951093

10961094
pub enum Level {
@@ -1127,19 +1125,19 @@ pub mod fsync {
11271125
}
11281126
}
11291127

1130-
pub type Arg<t> = {
1128+
pub struct Arg<t> {
11311129
val: t,
11321130
opt_level: Option<Level>,
1133-
fsync_fn: fn@(f: t, Level) -> int
1134-
};
1131+
fsync_fn: fn@(f: t, Level) -> int,
1132+
}
11351133

11361134
// fsync file after executing blk
11371135
// FIXME (#2004) find better way to create resources within lifetime of
11381136
// outer res
11391137
pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>,
11401138
blk: fn(v: Res<*libc::FILE>)) {
11411139
unsafe {
1142-
blk(move Res({
1140+
blk(Res(Arg {
11431141
val: file.f, opt_level: opt_level,
11441142
fsync_fn: fn@(file: *libc::FILE, l: Level) -> int {
11451143
unsafe {
@@ -1153,7 +1151,7 @@ pub mod fsync {
11531151
// fsync fd after executing blk
11541152
pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>,
11551153
blk: fn(v: Res<fd_t>)) {
1156-
blk(move Res({
1154+
blk(Res(Arg {
11571155
val: fd.fd, opt_level: opt_level,
11581156
fsync_fn: fn@(fd: fd_t, l: Level) -> int {
11591157
return os::fsync_fd(fd, l) as int;
@@ -1167,7 +1165,7 @@ pub mod fsync {
11671165
// Call o.fsync after executing blk
11681166
pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
11691167
blk: fn(v: Res<FSyncable>)) {
1170-
blk(Res({
1168+
blk(Res(Arg {
11711169
val: o, opt_level: opt_level,
11721170
fsync_fn: fn@(o: FSyncable, l: Level) -> int {
11731171
return o.fsync(l);

trunk/src/libcore/rand.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ pub trait Rng {
4242
}
4343

4444
/// A value with a particular weight compared to other values
45-
pub type Weighted<T> = { weight: uint, item: T };
45+
pub struct Weighted<T> {
46+
weight: uint,
47+
item: T,
48+
}
4649

4750
/// Extension methods for random number generators
4851
impl Rng {
@@ -312,12 +315,12 @@ pub fn seeded_rng(seed: &~[u8]) -> Rng {
312315
}
313316
}
314317

315-
type XorShiftState = {
318+
struct XorShiftState {
316319
mut x: u32,
317320
mut y: u32,
318321
mut z: u32,
319-
mut w: u32
320-
};
322+
mut w: u32,
323+
}
321324

322325
impl XorShiftState: Rng {
323326
fn next() -> u32 {
@@ -338,7 +341,7 @@ pub pure fn xorshift() -> Rng {
338341
}
339342

340343
pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> Rng {
341-
{mut x: x, mut y: y, mut z: z, mut w: w} as Rng
344+
XorShiftState { x: x, y: y, z: z, w: w } as Rng
342345
}
343346

344347

@@ -492,21 +495,24 @@ pub mod tests {
492495
#[test]
493496
pub fn choose_weighted() {
494497
let r = rand::Rng();
495-
assert r.choose_weighted(~[{weight: 1u, item: 42}]) == 42;
496498
assert r.choose_weighted(~[
497-
{weight: 0u, item: 42},
498-
{weight: 1u, item: 43}
499+
rand::Weighted { weight: 1u, item: 42 },
500+
]) == 42;
501+
assert r.choose_weighted(~[
502+
rand::Weighted { weight: 0u, item: 42 },
503+
rand::Weighted { weight: 1u, item: 43 },
499504
]) == 43;
500505
}
501506

502507
#[test]
503508
pub fn choose_weighted_option() {
504509
let r = rand::Rng();
505-
assert r.choose_weighted_option(~[{weight: 1u, item: 42}]) ==
506-
Some(42);
507510
assert r.choose_weighted_option(~[
508-
{weight: 0u, item: 42},
509-
{weight: 1u, item: 43}
511+
rand::Weighted { weight: 1u, item: 42 },
512+
]) == Some(42);
513+
assert r.choose_weighted_option(~[
514+
rand::Weighted { weight: 0u, item: 42 },
515+
rand::Weighted { weight: 1u, item: 43 },
510516
]) == Some(43);
511517
let v: Option<int> = r.choose_weighted_option([]);
512518
assert v.is_none();
@@ -518,9 +524,9 @@ pub mod tests {
518524
let empty: ~[int] = ~[];
519525
assert r.weighted_vec(~[]) == empty;
520526
assert r.weighted_vec(~[
521-
{weight: 0u, item: 3u},
522-
{weight: 1u, item: 2u},
523-
{weight: 2u, item: 1u}
527+
rand::Weighted { weight: 0u, item: 3u },
528+
rand::Weighted { weight: 1u, item: 2u },
529+
rand::Weighted { weight: 2u, item: 1u },
524530
]) == ~[2u, 1u, 1u];
525531
}
526532

trunk/src/libcore/run.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
220220
libc::close(pipe_err.out);
221221
}
222222

223-
type ProgRepr = {pid: pid_t,
224-
mut in_fd: c_int,
225-
out_file: *libc::FILE,
226-
err_file: *libc::FILE,
227-
mut finished: bool};
223+
struct ProgRepr {
224+
pid: pid_t,
225+
mut in_fd: c_int,
226+
out_file: *libc::FILE,
227+
err_file: *libc::FILE,
228+
mut finished: bool,
229+
}
228230

229231
fn close_repr_input(r: &ProgRepr) {
230232
let invalid_fd = -1i32;
@@ -274,12 +276,15 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
274276
fn finish() -> int { finish_repr(&self.r) }
275277
fn destroy() { destroy_repr(&self.r); }
276278
}
277-
let repr = {pid: pid,
278-
mut in_fd: pipe_input.out,
279-
out_file: os::fdopen(pipe_output.in),
280-
err_file: os::fdopen(pipe_err.in),
281-
mut finished: false};
282-
return ProgRes(move repr) as Program;
279+
let repr = ProgRepr {
280+
pid: pid,
281+
in_fd: pipe_input.out,
282+
out_file: os::fdopen(pipe_output.in),
283+
err_file: os::fdopen(pipe_err.in),
284+
finished: false,
285+
};
286+
287+
ProgRes(repr) as Program
283288
}
284289
}
285290

trunk/src/libcore/task/mod.rs

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ impl SchedMode : cmp::Eq {
168168
* default these foreign stacks have unspecified size, but with this
169169
* option their size can be precisely specified.
170170
*/
171-
pub type SchedOpts = {
171+
pub struct SchedOpts {
172172
mode: SchedMode,
173-
foreign_stack_size: Option<uint>
174-
};
173+
foreign_stack_size: Option<uint>,
174+
}
175175

176176
/**
177177
* Task configuration options
@@ -200,12 +200,12 @@ pub type SchedOpts = {
200200
* into foreign code that blocks. Without doing so in a different
201201
* scheduler other tasks will be impeded or even blocked indefinitely.
202202
*/
203-
pub type TaskOpts = {
203+
pub struct TaskOpts {
204204
linked: bool,
205205
supervised: bool,
206206
mut notify_chan: Option<Chan<TaskResult>>,
207207
sched: Option<SchedOpts>,
208-
};
208+
}
209209

210210
/**
211211
* The task builder type.
@@ -251,15 +251,15 @@ priv impl TaskBuilder {
251251
self.consumed = true;
252252
let notify_chan = replace(&mut self.opts.notify_chan, None);
253253
TaskBuilder {
254-
opts: {
254+
opts: TaskOpts {
255255
linked: self.opts.linked,
256256
supervised: self.opts.supervised,
257-
mut notify_chan: move notify_chan,
257+
notify_chan: notify_chan,
258258
sched: self.opts.sched
259259
},
260260
gen_body: self.gen_body,
261261
can_not_copy: None,
262-
mut consumed: false
262+
consumed: false
263263
}
264264
}
265265
}
@@ -272,10 +272,10 @@ impl TaskBuilder {
272272
fn unlinked() -> TaskBuilder {
273273
let notify_chan = replace(&mut self.opts.notify_chan, None);
274274
TaskBuilder {
275-
opts: {
275+
opts: TaskOpts {
276276
linked: false,
277277
supervised: self.opts.supervised,
278-
mut notify_chan: move notify_chan,
278+
notify_chan: notify_chan,
279279
sched: self.opts.sched
280280
},
281281
can_not_copy: None,
@@ -290,10 +290,10 @@ impl TaskBuilder {
290290
fn supervised() -> TaskBuilder {
291291
let notify_chan = replace(&mut self.opts.notify_chan, None);
292292
TaskBuilder {
293-
opts: {
293+
opts: TaskOpts {
294294
linked: false,
295295
supervised: true,
296-
mut notify_chan: move notify_chan,
296+
notify_chan: notify_chan,
297297
sched: self.opts.sched
298298
},
299299
can_not_copy: None,
@@ -307,10 +307,10 @@ impl TaskBuilder {
307307
fn linked() -> TaskBuilder {
308308
let notify_chan = replace(&mut self.opts.notify_chan, None);
309309
TaskBuilder {
310-
opts: {
310+
opts: TaskOpts {
311311
linked: true,
312312
supervised: false,
313-
mut notify_chan: move notify_chan,
313+
notify_chan: notify_chan,
314314
sched: self.opts.sched
315315
},
316316
can_not_copy: None,
@@ -352,10 +352,10 @@ impl TaskBuilder {
352352
353353
// Reconfigure self to use a notify channel.
354354
TaskBuilder {
355-
opts: {
355+
opts: TaskOpts {
356356
linked: self.opts.linked,
357357
supervised: self.opts.supervised,
358-
mut notify_chan: Some(move notify_pipe_ch),
358+
notify_chan: Some(notify_pipe_ch),
359359
sched: self.opts.sched
360360
},
361361
can_not_copy: None,
@@ -366,11 +366,14 @@ impl TaskBuilder {
366366
fn sched_mode(mode: SchedMode) -> TaskBuilder {
367367
let notify_chan = replace(&mut self.opts.notify_chan, None);
368368
TaskBuilder {
369-
opts: {
369+
opts: TaskOpts {
370370
linked: self.opts.linked,
371371
supervised: self.opts.supervised,
372-
mut notify_chan: move notify_chan,
373-
sched: Some({ mode: mode, foreign_stack_size: None})
372+
notify_chan: notify_chan,
373+
sched: Some(SchedOpts {
374+
mode: mode,
375+
foreign_stack_size: None,
376+
})
374377
},
375378
can_not_copy: None,
376379
.. self.consume()
@@ -393,10 +396,10 @@ impl TaskBuilder {
393396
let prev_gen_body = self.gen_body;
394397
let notify_chan = replace(&mut self.opts.notify_chan, None);
395398
TaskBuilder {
396-
opts: {
399+
opts: TaskOpts {
397400
linked: self.opts.linked,
398401
supervised: self.opts.supervised,
399-
mut notify_chan: move notify_chan,
402+
notify_chan: notify_chan,
400403
sched: self.opts.sched
401404
},
402405
// tjc: I think this is the line that gets miscompiled
@@ -424,10 +427,10 @@ impl TaskBuilder {
424427
fn spawn(f: fn~()) {
425428
let notify_chan = replace(&mut self.opts.notify_chan, None);
426429
let x = self.consume();
427-
let opts = {
430+
let opts = TaskOpts {
428431
linked: x.opts.linked,
429432
supervised: x.opts.supervised,
430-
mut notify_chan: move notify_chan,
433+
notify_chan: notify_chan,
431434
sched: x.opts.sched
432435
};
433436
spawn::spawn_raw(move opts, (x.gen_body)(move f));
@@ -482,10 +485,10 @@ pub fn default_task_opts() -> TaskOpts {
482485
* into the same scheduler, and do not post lifecycle notifications.
483486
*/
484487
485-
{
488+
TaskOpts {
486489
linked: true,
487490
supervised: false,
488-
mut notify_chan: None,
491+
notify_chan: None,
489492
sched: None
490493
}
491494
}

0 commit comments

Comments
 (0)