Skip to content

Commit 9ef4332

Browse files
committed
---
yaml --- r: 42398 b: refs/heads/master c: ee93fb2 h: refs/heads/master v: v3
1 parent 1edb9b7 commit 9ef4332

Some content is hidden

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

66 files changed

+1005
-784
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: a380df809c8eb874540a123780612f14cfc7303e
2+
refs/heads/master: ee93fb2ad586a98ab1e5766cfd74b3bba6529b14
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/doc/tutorial-macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ pattern we want is clear:
281281
However, it's not possible to directly expand to nested match statements. But
282282
there is a solution.
283283

284-
## The recusive approach to macro writing
284+
## The recursive approach to macro writing
285285

286286
A macro may accept multiple different input grammars. The first one to
287287
successfully match the actual argument to a macro invocation is the one that

trunk/src/libcargo/cargo.rc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
457457
}
458458

459459
match *j {
460-
json::Object(ref j) => {
460+
json::Object(j) => {
461461
let mut url = match j.find(&~"url") {
462462
Some(&json::String(u)) => copy u,
463463
_ => die!(~"needed 'url' field in source")
@@ -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
}
@@ -563,7 +563,7 @@ pub fn load_one_source_package(src: @Source, p: &json::Object) {
563563

564564
let mut tags = ~[];
565565
match p.find(&~"tags") {
566-
Some(&json::List(ref js)) => {
566+
Some(&json::List(js)) => {
567567
for js.each |j| {
568568
match *j {
569569
json::String(ref j) => tags.grow(1u, j),
@@ -635,11 +635,11 @@ pub fn load_source_packages(c: &Cargo, src: @Source) {
635635
if !os::path_exists(&pkgfile) { return; }
636636
let pkgstr = io::read_whole_file_str(&pkgfile);
637637
match json::from_str(pkgstr.get()) {
638-
Ok(json::List(ref js)) => {
638+
Ok(json::List(js)) => {
639639
for js.each |j| {
640640
match *j {
641-
json::Object(ref p) => {
642-
load_one_source_package(src, *p);
641+
json::Object(p) => {
642+
load_one_source_package(src, p);
643643
}
644644
_ => {
645645
warn(~"malformed source json: " + src.name +

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: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ 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-
3532
/// Visit all keys
3633
pure fn each_key(&self, f: fn(&K) -> bool);
3734

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: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,23 @@ 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+
238255
impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Container {
239256
/// Return the number of elements in the map
240257
pure fn len(&self) -> uint { self.size }
@@ -262,27 +279,14 @@ pub mod linear {
262279
}
263280
}
264281
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-
278282
/// Visit all keys
279283
pure fn each_key(&self, blk: fn(k: &K) -> bool) {
280-
self.each(|k, _| blk(k))
284+
self.each(|&(k, _)| blk(k))
281285
}
282286
283287
/// Visit all values
284288
pure fn each_value(&self, blk: fn(v: &V) -> bool) {
285-
self.each(|_, v| blk(v))
289+
self.each(|&(_, v)| blk(v))
286290
}
287291
288292
/// Return the value corresponding to the key in the map
@@ -388,7 +392,7 @@ pub mod linear {
388392
pure fn eq(&self, other: &LinearMap<K, V>) -> bool {
389393
if self.len() != other.len() { return false; }
390394

391-
for self.each |key, value| {
395+
for self.each |&(key, value)| {
392396
match other.find(key) {
393397
None => return false,
394398
Some(v) => if value != v { return false },
@@ -603,7 +607,7 @@ mod test_map {
603607
assert m.insert(i, i*2);
604608
}
605609
let mut observed = 0;
606-
for m.each |k, v| {
610+
for m.each |&(k, v)| {
607611
assert *v == *k * 2;
608612
observed |= (1 << *k);
609613
}

trunk/src/libcore/iter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ 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+
3034
pub trait ExtendedIter<A> {
3135
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool);
3236
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: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
105+
pub pure fn map<T, U>(opt: &r/Option<T>, f: fn(x: &r/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: &Option<T>, def: U,
197-
f: fn(x: &T) -> U) -> U {
196+
pub pure fn map_default<T, U>(opt: &r/Option<T>, def: U,
197+
f: fn(&r/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(x: &T) -> U) -> Option<U> { map(self, f) }
276+
pure fn map<U>(&self, f: fn(&self/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(x: &T) -> U) -> U {
287+
pure fn map_default<U>(&self, def: U, f: fn(&self/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);

0 commit comments

Comments
 (0)