Skip to content

Commit 9f4f664

Browse files
committed
---
yaml --- r: 42390 b: refs/heads/master c: 3b8f1fa h: refs/heads/master v: v3
1 parent 39b9cab commit 9f4f664

35 files changed

+168
-465
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: 9b4fa844d83dff2100e682f572109326be6194cb
2+
refs/heads/master: 3b8f1fa2b6369c40cdd3d3030e37ce3308d63caf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/libcargo/cargo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ pub fn try_parse_sources(filename: &Path,
495495
let c = io::read_whole_file_str(filename);
496496
match json::from_str(c.get()) {
497497
Ok(json::Object(j)) => {
498-
for j.each |&(k, v)| {
498+
for j.each |k, v| {
499499
sources.insert(copy *k, parse_source(*k, v));
500500
debug!("source: %s", *k);
501501
}

trunk/src/libcargo/pgp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use core::os;
1212
use core::path::Path;
1313
use core::run;
1414

15-
pub fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {
15+
pub fn gpgv(args: ~[~str]) -> run::ProgramOutput {
1616
return run::program_output(~"gpgv", args);
1717
}
1818

trunk/src/libcore/container.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub trait Map<K, V>: Mutable {
2929
/// Return true if the map contains a value for the specified key
3030
pure fn contains_key(&self, key: &K) -> bool;
3131

32+
/// Visit all key-value pairs
33+
pure fn each(&self, f: fn(&K, &V) -> bool);
34+
3235
/// Visit all keys
3336
pure fn each_key(&self, f: fn(&K) -> bool);
3437

trunk/src/libcore/extfmt.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
//! * s - str (any flavor)
5252
//! * ? - arbitrary type (does not use the to_str trait)
5353
54-
// Transitional
55-
#[allow(structural_records)]; // Macros -- needs a snapshot
56-
5754
/*
5855
Syntax Extension: fmt
5956
@@ -619,11 +616,11 @@ pub mod rt {
619616
let padstr = str::from_chars(vec::from_elem(diff, padchar));
620617
return s + padstr;
621618
}
622-
let {might_zero_pad, signed} = match mode {
623-
PadNozero => {might_zero_pad:false, signed:false},
624-
PadSigned => {might_zero_pad:true, signed:true },
625-
PadFloat => {might_zero_pad:true, signed:true},
626-
PadUnsigned => {might_zero_pad:true, signed:false}
619+
let (might_zero_pad, signed) = match mode {
620+
PadNozero => (false, true),
621+
PadSigned => (true, true),
622+
PadFloat => (true, true),
623+
PadUnsigned => (true, false)
627624
};
628625
pure fn have_precision(cv: Conv) -> bool {
629626
return match cv.precision { CountImplied => false, _ => true };

trunk/src/libcore/gc.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ with destructors.
3535
3636
*/
3737

38-
// Transitional
39-
#[allow(structural_records)];
40-
4138
use cast;
4239
use container::{Container, Mutable, Map, Set};
4340
use io;
@@ -172,12 +169,14 @@ unsafe fn is_frame_in_segment(fp: *Word, segment: *StackSegment) -> bool {
172169
return begin <= frame && frame <= end;
173170
}
174171

172+
struct Segment { segment: *StackSegment, boundary: bool }
173+
175174
// Find and return the segment containing the given frame pointer. At
176175
// stack segment boundaries, returns true for boundary, so that the
177176
// caller can do any special handling to identify where the correct
178177
// return address is in the stack frame.
179178
unsafe fn find_segment_for_frame(fp: *Word, segment: *StackSegment)
180-
-> {segment: *StackSegment, boundary: bool} {
179+
-> Segment {
181180
// Check if frame is in either current frame or previous frame.
182181
let in_segment = is_frame_in_segment(fp, segment);
183182
let in_prev_segment = ptr::is_not_null((*segment).prev) &&
@@ -191,16 +190,16 @@ unsafe fn find_segment_for_frame(fp: *Word, segment: *StackSegment)
191190
is_frame_in_segment(fp, (*segment).next) {
192191
segment = (*segment).next;
193192
}
194-
return {segment: segment, boundary: false};
193+
return Segment {segment: segment, boundary: false};
195194
}
196195

197196
// If frame is in previous frame, then we're at a boundary.
198197
if !in_segment && in_prev_segment {
199-
return {segment: (*segment).prev, boundary: true};
198+
return Segment {segment: (*segment).prev, boundary: true};
200199
}
201200

202201
// Otherwise, we're somewhere on the inside of the frame.
203-
return {segment: segment, boundary: false};
202+
return Segment {segment: segment, boundary: false};
204203
}
205204

206205
type Memory = uint;
@@ -224,7 +223,7 @@ unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
224223
for stackwalk::walk_stack |frame| {
225224
unsafe {
226225
let pc = last_ret;
227-
let {segment: next_segment, boundary: boundary} =
226+
let Segment {segment: next_segment, boundary: boundary} =
228227
find_segment_for_frame(frame.fp, segment);
229228
segment = next_segment;
230229
// Each stack segment is bounded by a morestack frame. The

trunk/src/libcore/hashmap.rs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -235,23 +235,6 @@ pub mod linear {
235235
}
236236
}
237237
238-
impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: BaseIter<(&K, &V)> {
239-
/// Visit all key-value pairs
240-
pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) {
241-
for uint::range(0, self.buckets.len()) |i| {
242-
let mut broke = false;
243-
do self.buckets[i].map |bucket| {
244-
if !blk(&(&bucket.key, &bucket.value)) {
245-
broke = true; // FIXME(#3064) just write "break;"
246-
}
247-
};
248-
if broke { break; }
249-
}
250-
}
251-
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
252-
}
253-
254-
255238
impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Container {
256239
/// Return the number of elements in the map
257240
pure fn len(&self) -> uint { self.size }
@@ -279,14 +262,27 @@ pub mod linear {
279262
}
280263
}
281264
265+
/// Visit all key-value pairs
266+
pure fn each(&self, blk: fn(k: &K, v: &V) -> bool) {
267+
for self.buckets.each |slot| {
268+
let mut broke = false;
269+
do slot.iter |bucket| {
270+
if !blk(&bucket.key, &bucket.value) {
271+
broke = true; // FIXME(#3064) just write "break;"
272+
}
273+
}
274+
if broke { break; }
275+
}
276+
}
277+
282278
/// Visit all keys
283279
pure fn each_key(&self, blk: fn(k: &K) -> bool) {
284-
self.each(|&(k, _)| blk(k))
280+
self.each(|k, _| blk(k))
285281
}
286282
287283
/// Visit all values
288284
pure fn each_value(&self, blk: fn(v: &V) -> bool) {
289-
self.each(|&(_, v)| blk(v))
285+
self.each(|_, v| blk(v))
290286
}
291287
292288
/// Return the value corresponding to the key in the map
@@ -392,7 +388,7 @@ pub mod linear {
392388
pure fn eq(&self, other: &LinearMap<K, V>) -> bool {
393389
if self.len() != other.len() { return false; }
394390

395-
for self.each |&(key, value)| {
391+
for self.each |key, value| {
396392
match other.find(key) {
397393
None => return false,
398394
Some(v) => if value != v { return false },
@@ -607,7 +603,7 @@ mod test_map {
607603
assert m.insert(i, i*2);
608604
}
609605
let mut observed = 0;
610-
for m.each |&(k, v)| {
606+
for m.each |k, v| {
611607
assert *v == *k * 2;
612608
observed |= (1 << *k);
613609
}

trunk/src/libcore/iter.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ pub trait BaseIter<A> {
2727
pure fn size_hint(&self) -> Option<uint>;
2828
}
2929

30-
pub trait ReverseIter<A>: BaseIter<A> {
31-
pure fn each_reverse(&self, blk: fn(&A) -> bool);
32-
}
33-
3430
pub trait ExtendedIter<A> {
3531
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool);
3632
pure fn all(&self, blk: fn(&A) -> bool) -> bool;

trunk/src/libcore/option.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
102102
}
103103
104104
#[inline(always)]
105-
pub pure fn map<T, U>(opt: &r/Option<T>, f: fn(x: &r/T) -> U) -> Option<U> {
105+
pub pure fn map<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
106106
//! Maps a `some` value by reference from one type to another
107107
108108
match *opt { Some(ref x) => Some(f(x)), None => None }
@@ -193,8 +193,8 @@ pub pure fn get_or_default<T: Copy>(opt: Option<T>, def: T) -> T {
193193
}
194194
195195
#[inline(always)]
196-
pub pure fn map_default<T, U>(opt: &r/Option<T>, def: U,
197-
f: fn(&r/T) -> U) -> U {
196+
pub pure fn map_default<T, U>(opt: &Option<T>, def: U,
197+
f: fn(x: &T) -> U) -> U {
198198
//! Applies a function to the contained value or returns a default
199199
200200
match *opt { None => move def, Some(ref t) => f(t) }
@@ -273,7 +273,7 @@ impl<T> Option<T> {
273273
274274
/// Maps a `some` value from one type to another by reference
275275
#[inline(always)]
276-
pure fn map<U>(&self, f: fn(&self/T) -> U) -> Option<U> { map(self, f) }
276+
pure fn map<U>(&self, f: fn(x: &T) -> U) -> Option<U> { map(self, f) }
277277
278278
/// As `map`, but consumes the option and gives `f` ownership to avoid
279279
/// copying.
@@ -284,7 +284,7 @@ impl<T> Option<T> {
284284
285285
/// Applies a function to the contained value or returns a default
286286
#[inline(always)]
287-
pure fn map_default<U>(&self, def: U, f: fn(&self/T) -> U) -> U {
287+
pure fn map_default<U>(&self, def: U, f: fn(x: &T) -> U) -> U {
288288
map_default(self, move def, f)
289289
}
290290

trunk/src/libcore/os.rs

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

11-
#[allow(structural_records)];
12-
1311
/*!
1412
* Higher-level interfaces to libc::* functions and operating system services.
1513
*
@@ -318,33 +316,37 @@ pub fn waitpid(pid: pid_t) -> c_int {
318316
}
319317

320318

319+
pub struct Pipe { mut in: c_int, mut out: c_int }
320+
321321
#[cfg(unix)]
322-
pub fn pipe() -> {in: c_int, out: c_int} {
322+
pub fn pipe() -> Pipe {
323323
unsafe {
324-
let mut fds = {in: 0 as c_int, out: 0 as c_int};
324+
let mut fds = Pipe {mut in: 0 as c_int,
325+
mut out: 0 as c_int };
325326
assert (libc::pipe(ptr::mut_addr_of(&(fds.in))) == (0 as c_int));
326-
return {in: fds.in, out: fds.out};
327+
return Pipe {in: fds.in, out: fds.out};
327328
}
328329
}
329330

330331

331332

332333
#[cfg(windows)]
333-
pub fn pipe() -> {in: c_int, out: c_int} {
334+
pub fn pipe() -> Pipe {
334335
unsafe {
335336
// Windows pipes work subtly differently than unix pipes, and their
336337
// inheritance has to be handled in a different way that I do not
337338
// fully understand. Here we explicitly make the pipe non-inheritable,
338339
// which means to pass it to a subprocess they need to be duplicated
339340
// first, as in rust_run_program.
340-
let mut fds = { in: 0 as c_int, out: 0 as c_int };
341+
let mut fds = Pipe { mut in: 0 as c_int,
342+
mut out: 0 as c_int };
341343
let res = libc::pipe(ptr::mut_addr_of(&(fds.in)),
342344
1024 as c_uint,
343345
(libc::O_BINARY | libc::O_NOINHERIT) as c_int);
344346
assert (res == 0 as c_int);
345347
assert (fds.in != -1 as c_int && fds.in != 0 as c_int);
346348
assert (fds.out != -1 as c_int && fds.in != 0 as c_int);
347-
return {in: fds.in, out: fds.out};
349+
return Pipe {in: fds.in, out: fds.out};
348350
}
349351
}
350352

trunk/src/libcore/pipes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ bounded and unbounded protocols allows for less code duplication.
8282
8383
*/
8484

85-
// Transitional -- needs snapshot
86-
#[allow(structural_records)];
85+
#[allow(structural_records)]; // Macros -- needs another snapshot
8786

8887
use cmp::Eq;
8988
use cast::{forget, reinterpret_cast, transmute};

trunk/src/libcore/ptr.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,7 @@ pub trait Ptr<T> {
187187
pure fn offset(count: uint) -> Self;
188188
}
189189

190-
#[cfg(stage0)]
191-
unsafe fn memmove32(dst: *mut u8, src: *const u8, count: u32) {
192-
libc::memmove(dst as *c_void, src as *c_void, count as size_t);
193-
}
194-
#[cfg(stage0)]
195-
unsafe fn memmove64(dst: *mut u8, src: *const u8, count: u64) {
196-
libc::memmove(dst as *c_void, src as *c_void, count as size_t);
197-
}
198-
199190
#[abi="rust-intrinsic"]
200-
#[cfg(stage1)]
201-
#[cfg(stage2)]
202191
pub extern {
203192
fn memmove32(dst: *mut u8, src: *u8, size: u32);
204193
fn memmove64(dst: *mut u8, src: *u8, size: u64);

trunk/src/libcore/run.rs

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

11-
#[allow(structural_records)];
12-
1311
//! Process spawning
1412
use cast;
1513
use io;
@@ -301,6 +299,8 @@ fn read_all(rd: io::Reader) -> ~str {
301299
str::from_bytes(buf)
302300
}
303301

302+
pub struct ProgramOutput {status: int, out: ~str, err: ~str}
303+
304304
/**
305305
* Spawns a process, waits for it to exit, and returns the exit code, and
306306
* contents of stdout and stderr.
@@ -315,8 +315,7 @@ fn read_all(rd: io::Reader) -> ~str {
315315
* A record, {status: int, out: str, err: str} containing the exit code,
316316
* the contents of stdout and the contents of stderr.
317317
*/
318-
pub fn program_output(prog: &str, args: &[~str]) ->
319-
{status: int, out: ~str, err: ~str} {
318+
pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
320319
unsafe {
321320
let pipe_in = os::pipe();
322321
let pipe_out = os::pipe();
@@ -371,7 +370,9 @@ pub fn program_output(prog: &str, args: &[~str]) ->
371370
};
372371
count -= 1;
373372
};
374-
return {status: status, out: move outs, err: move errs};
373+
return ProgramOutput {status: status,
374+
out: move outs,
375+
err: move errs};
375376
}
376377
}
377378

0 commit comments

Comments
 (0)