Skip to content

Commit 0f82453

Browse files
committed
---
yaml --- r: 145063 b: refs/heads/try2 c: 5d905f1 h: refs/heads/master i: 145061: 33c4c98 145059: 8736065 145055: d70ca1f v: v3
1 parent 8322438 commit 0f82453

Some content is hidden

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

73 files changed

+1323
-434
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 462dcc8e7a44972b57cb3060a48970c0499d5dee
8+
refs/heads/try2: 5d905f1314d243eb1572588f7e7e98768f8bb711
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,8 @@ Supported traits for `deriving` are:
17171717
* `Clone` and `DeepClone`, to perform (deep) copies.
17181718
* `IterBytes`, to iterate over the bytes in a data type.
17191719
* `Rand`, to create a random instance of a data type.
1720-
* `Zero`, to create an zero (or empty) instance of a data type.
1720+
* `Default`, to create an empty instance of a data type.
1721+
* `Zero`, to create an zero instance of a numeric data type.
17211722
* `ToStr`, to convert to a string. For a type with this instance,
17221723
`obj.to_str()` has similar output as `fmt!("%?", obj)`, but it differs in that
17231724
each constituent field of the type must also implement `ToStr` and will have

branches/try2/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ enum ABC { A, B, C }
22492249

22502250
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
22512251
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `DeepClone`,
2252-
`IterBytes`, `Rand`, `Zero`, and `ToStr`.
2252+
`IterBytes`, `Rand`, `Default`, `Zero`, and `ToStr`.
22532253

22542254
# Crates and the module system
22552255

branches/try2/src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
309309
let filename = path.filename();
310310
let p = path.pop();
311311
let dir = p.filename();
312-
fmt!("%s/%s", dir.unwrap_or_default(""), filename.unwrap_or_default(""))
312+
fmt!("%s/%s", dir.unwrap_or(""), filename.unwrap_or(""))
313313
}
314314

315315
test::DynTestName(fmt!("[%s] %s",

branches/try2/src/libextra/glob.rs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,17 @@ fn list_dir_sorted(path: &Path) -> ~[Path] {
137137
/**
138138
* A compiled Unix shell style pattern.
139139
*/
140-
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes, Zero)]
140+
#[cfg(stage0)]
141+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes)]
142+
pub struct Pattern {
143+
priv tokens: ~[PatternToken]
144+
}
145+
146+
/**
147+
* A compiled Unix shell style pattern.
148+
*/
149+
#[cfg(not(stage0))]
150+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes, Default)]
141151
pub struct Pattern {
142152
priv tokens: ~[PatternToken]
143153
}
@@ -312,7 +322,7 @@ impl Pattern {
312322
let require_literal = |c| {
313323
(options.require_literal_separator && is_sep(c)) ||
314324
(options.require_literal_leading_dot && c == '.'
315-
&& is_sep(prev_char.unwrap_or_default('/')))
325+
&& is_sep(prev_char.unwrap_or('/')))
316326
};
317327
318328
for (ti, token) in self.tokens.slice_from(i).iter().enumerate() {
@@ -458,7 +468,37 @@ fn is_sep(c: char) -> bool {
458468
/**
459469
* Configuration options to modify the behaviour of `Pattern::matches_with(..)`
460470
*/
461-
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes, Zero)]
471+
#[cfg(stage0)]
472+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes)]
473+
pub struct MatchOptions {
474+
475+
/**
476+
* Whether or not patterns should be matched in a case-sensitive manner. This
477+
* currently only considers upper/lower case relationships between ASCII characters,
478+
* but in future this might be extended to work with Unicode.
479+
*/
480+
case_sensitive: bool,
481+
482+
/**
483+
* If this is true then path-component separator characters (e.g. `/` on Posix)
484+
* must be matched by a literal `/`, rather than by `*` or `?` or `[...]`
485+
*/
486+
require_literal_separator: bool,
487+
488+
/**
489+
* If this is true then paths that contain components that start with a `.` will
490+
* not match unless the `.` appears literally in the pattern: `*`, `?` or `[...]`
491+
* will not match. This is useful because such files are conventionally considered
492+
* hidden on Unix systems and it might be desirable to skip them when listing files.
493+
*/
494+
require_literal_leading_dot: bool
495+
}
496+
497+
/**
498+
* Configuration options to modify the behaviour of `Pattern::matches_with(..)`
499+
*/
500+
#[cfg(not(stage0))]
501+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes, Default)]
462502
pub struct MatchOptions {
463503
464504
/**

branches/try2/src/libextra/num/bigint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ impl BigUint {
635635

636636
// Converts this BigUint into an int, unless it would overflow.
637637
pub fn to_int_opt(&self) -> Option<int> {
638-
self.to_uint_opt().chain(|n| {
638+
self.to_uint_opt().and_then(|n| {
639639
// If top bit of uint is set, it's too large to convert to
640640
// int.
641641
if (n >> (2*BigDigit::bits - 1) != 0) {
@@ -1221,7 +1221,7 @@ impl BigInt {
12211221
match self.sign {
12221222
Plus => self.data.to_int_opt(),
12231223
Zero => Some(0),
1224-
Minus => self.data.to_uint_opt().chain(|n| {
1224+
Minus => self.data.to_uint_opt().and_then(|n| {
12251225
let m: uint = 1 << (2*BigDigit::bits-1);
12261226
if (n > m) {
12271227
None

branches/try2/src/libextra/num/rational.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ impl<T: FromStr + Clone + Integer + Ord>
273273
return None
274274
}
275275
let a_option: Option<T> = FromStr::from_str(split[0]);
276-
do a_option.chain |a| {
276+
do a_option.and_then |a| {
277277
let b_option: Option<T> = FromStr::from_str(split[1]);
278-
do b_option.chain |b| {
278+
do b_option.and_then |b| {
279279
Some(Ratio::new(a.clone(), b.clone()))
280280
}
281281
}
@@ -291,10 +291,10 @@ impl<T: FromStrRadix + Clone + Integer + Ord>
291291
} else {
292292
let a_option: Option<T> = FromStrRadix::from_str_radix(split[0],
293293
radix);
294-
do a_option.chain |a| {
294+
do a_option.and_then |a| {
295295
let b_option: Option<T> =
296296
FromStrRadix::from_str_radix(split[1], radix);
297-
do b_option.chain |b| {
297+
do b_option.and_then |b| {
298298
Some(Ratio::new(a.clone(), b.clone()))
299299
}
300300
}

branches/try2/src/libextra/tempfile.rs

Lines changed: 3 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -28,97 +28,6 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
2828
None
2929
}
3030

31-
#[cfg(test)]
32-
mod tests {
33-
34-
use tempfile::mkdtemp;
35-
36-
use std::os;
37-
38-
#[test]
39-
fn test_mkdtemp() {
40-
let p = mkdtemp(&Path("."), "foobar").unwrap();
41-
os::remove_dir(&p);
42-
assert!(p.to_str().ends_with("foobar"));
43-
}
44-
45-
// Ideally these would be in std::os but then core would need
46-
// to depend on std
47-
#[test]
48-
fn recursive_mkdir_rel() {
49-
use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
50-
use std::os;
51-
use std::unstable::change_dir_locked;
52-
53-
let root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel").
54-
expect("recursive_mkdir_rel");
55-
assert!(do change_dir_locked(&root) {
56-
let path = Path("frob");
57-
debug!("recursive_mkdir_rel: Making: %s in cwd %s [%?]", path.to_str(),
58-
os::getcwd().to_str(),
59-
os::path_exists(&path));
60-
assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
61-
assert!(os::path_is_dir(&path));
62-
assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
63-
assert!(os::path_is_dir(&path));
64-
});
65-
}
66-
67-
#[test]
68-
fn recursive_mkdir_dot() {
69-
use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
70-
use std::os;
71-
72-
let dot = Path(".");
73-
assert!(os::mkdir_recursive(&dot, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
74-
let dotdot = Path("..");
75-
assert!(os::mkdir_recursive(&dotdot, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
76-
}
77-
78-
#[test]
79-
fn recursive_mkdir_rel_2() {
80-
use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
81-
use std::os;
82-
use std::unstable::change_dir_locked;
83-
84-
let root = mkdtemp(&os::tmpdir(), "recursive_mkdir_rel_2").
85-
expect("recursive_mkdir_rel_2");
86-
assert!(do change_dir_locked(&root) {
87-
let path = Path("./frob/baz");
88-
debug!("recursive_mkdir_rel_2: Making: %s in cwd %s [%?]", path.to_str(),
89-
os::getcwd().to_str(), os::path_exists(&path));
90-
assert!(os::mkdir_recursive(&path, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
91-
assert!(os::path_is_dir(&path));
92-
assert!(os::path_is_dir(&path.pop()));
93-
let path2 = Path("quux/blat");
94-
debug!("recursive_mkdir_rel_2: Making: %s in cwd %s", path2.to_str(),
95-
os::getcwd().to_str());
96-
assert!(os::mkdir_recursive(&path2, (S_IRUSR | S_IWUSR | S_IXUSR) as i32));
97-
assert!(os::path_is_dir(&path2));
98-
assert!(os::path_is_dir(&path2.pop()));
99-
});
100-
}
101-
102-
// Ideally this would be in core, but needs mkdtemp
103-
#[test]
104-
pub fn test_rmdir_recursive_ok() {
105-
use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
106-
use std::os;
107-
108-
let rwx = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
109-
110-
let tmpdir = mkdtemp(&os::tmpdir(), "test").expect("test_rmdir_recursive_ok: \
111-
couldn't create temp dir");
112-
let root = tmpdir.push("foo");
113-
114-
debug!("making %s", root.to_str());
115-
assert!(os::make_dir(&root, rwx));
116-
assert!(os::make_dir(&root.push("foo"), rwx));
117-
assert!(os::make_dir(&root.push("foo").push("bar"), rwx));
118-
assert!(os::make_dir(&root.push("foo").push("bar").push("blat"), rwx));
119-
assert!(os::remove_dir_recursive(&root));
120-
assert!(!os::path_exists(&root));
121-
assert!(!os::path_exists(&root.push("bar")));
122-
assert!(!os::path_exists(&root.push("bar").push("blat")));
123-
}
124-
}
31+
// the tests for this module need to change the path using change_dir,
32+
// and this doesn't play nicely with other tests so these unit tests are located
33+
// in src/test/run-pass/tempfile.rs

branches/try2/src/libextra/time.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -442,21 +442,21 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
442442
},
443443
'c' => {
444444
parse_type(s, pos, 'a', &mut *tm)
445-
.chain(|pos| parse_char(s, pos, ' '))
446-
.chain(|pos| parse_type(s, pos, 'b', &mut *tm))
447-
.chain(|pos| parse_char(s, pos, ' '))
448-
.chain(|pos| parse_type(s, pos, 'e', &mut *tm))
449-
.chain(|pos| parse_char(s, pos, ' '))
450-
.chain(|pos| parse_type(s, pos, 'T', &mut *tm))
451-
.chain(|pos| parse_char(s, pos, ' '))
452-
.chain(|pos| parse_type(s, pos, 'Y', &mut *tm))
445+
.and_then(|pos| parse_char(s, pos, ' '))
446+
.and_then(|pos| parse_type(s, pos, 'b', &mut *tm))
447+
.and_then(|pos| parse_char(s, pos, ' '))
448+
.and_then(|pos| parse_type(s, pos, 'e', &mut *tm))
449+
.and_then(|pos| parse_char(s, pos, ' '))
450+
.and_then(|pos| parse_type(s, pos, 'T', &mut *tm))
451+
.and_then(|pos| parse_char(s, pos, ' '))
452+
.and_then(|pos| parse_type(s, pos, 'Y', &mut *tm))
453453
}
454454
'D' | 'x' => {
455455
parse_type(s, pos, 'm', &mut *tm)
456-
.chain(|pos| parse_char(s, pos, '/'))
457-
.chain(|pos| parse_type(s, pos, 'd', &mut *tm))
458-
.chain(|pos| parse_char(s, pos, '/'))
459-
.chain(|pos| parse_type(s, pos, 'y', &mut *tm))
456+
.and_then(|pos| parse_char(s, pos, '/'))
457+
.and_then(|pos| parse_type(s, pos, 'd', &mut *tm))
458+
.and_then(|pos| parse_char(s, pos, '/'))
459+
.and_then(|pos| parse_type(s, pos, 'y', &mut *tm))
460460
}
461461
'd' => match match_digits_in_range(s, pos, 2u, false, 1_i32,
462462
31_i32) {
@@ -475,10 +475,10 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
475475
}
476476
'F' => {
477477
parse_type(s, pos, 'Y', &mut *tm)
478-
.chain(|pos| parse_char(s, pos, '-'))
479-
.chain(|pos| parse_type(s, pos, 'm', &mut *tm))
480-
.chain(|pos| parse_char(s, pos, '-'))
481-
.chain(|pos| parse_type(s, pos, 'd', &mut *tm))
478+
.and_then(|pos| parse_char(s, pos, '-'))
479+
.and_then(|pos| parse_type(s, pos, 'm', &mut *tm))
480+
.and_then(|pos| parse_char(s, pos, '-'))
481+
.and_then(|pos| parse_type(s, pos, 'd', &mut *tm))
482482
}
483483
'H' => {
484484
match match_digits_in_range(s, pos, 2u, false, 0_i32, 23_i32) {
@@ -553,17 +553,17 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
553553
},
554554
'R' => {
555555
parse_type(s, pos, 'H', &mut *tm)
556-
.chain(|pos| parse_char(s, pos, ':'))
557-
.chain(|pos| parse_type(s, pos, 'M', &mut *tm))
556+
.and_then(|pos| parse_char(s, pos, ':'))
557+
.and_then(|pos| parse_type(s, pos, 'M', &mut *tm))
558558
}
559559
'r' => {
560560
parse_type(s, pos, 'I', &mut *tm)
561-
.chain(|pos| parse_char(s, pos, ':'))
562-
.chain(|pos| parse_type(s, pos, 'M', &mut *tm))
563-
.chain(|pos| parse_char(s, pos, ':'))
564-
.chain(|pos| parse_type(s, pos, 'S', &mut *tm))
565-
.chain(|pos| parse_char(s, pos, ' '))
566-
.chain(|pos| parse_type(s, pos, 'p', &mut *tm))
561+
.and_then(|pos| parse_char(s, pos, ':'))
562+
.and_then(|pos| parse_type(s, pos, 'M', &mut *tm))
563+
.and_then(|pos| parse_char(s, pos, ':'))
564+
.and_then(|pos| parse_type(s, pos, 'S', &mut *tm))
565+
.and_then(|pos| parse_char(s, pos, ' '))
566+
.and_then(|pos| parse_type(s, pos, 'p', &mut *tm))
567567
}
568568
'S' => {
569569
match match_digits_in_range(s, pos, 2u, false, 0_i32, 60_i32) {
@@ -578,10 +578,10 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
578578
//'s' {}
579579
'T' | 'X' => {
580580
parse_type(s, pos, 'H', &mut *tm)
581-
.chain(|pos| parse_char(s, pos, ':'))
582-
.chain(|pos| parse_type(s, pos, 'M', &mut *tm))
583-
.chain(|pos| parse_char(s, pos, ':'))
584-
.chain(|pos| parse_type(s, pos, 'S', &mut *tm))
581+
.and_then(|pos| parse_char(s, pos, ':'))
582+
.and_then(|pos| parse_type(s, pos, 'M', &mut *tm))
583+
.and_then(|pos| parse_char(s, pos, ':'))
584+
.and_then(|pos| parse_type(s, pos, 'S', &mut *tm))
585585
}
586586
't' => parse_char(s, pos, '\t'),
587587
'u' => {
@@ -596,10 +596,10 @@ fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
596596
}
597597
'v' => {
598598
parse_type(s, pos, 'e', &mut *tm)
599-
.chain(|pos| parse_char(s, pos, '-'))
600-
.chain(|pos| parse_type(s, pos, 'b', &mut *tm))
601-
.chain(|pos| parse_char(s, pos, '-'))
602-
.chain(|pos| parse_type(s, pos, 'Y', &mut *tm))
599+
.and_then(|pos| parse_char(s, pos, '-'))
600+
.and_then(|pos| parse_type(s, pos, 'b', &mut *tm))
601+
.and_then(|pos| parse_char(s, pos, '-'))
602+
.and_then(|pos| parse_type(s, pos, 'Y', &mut *tm))
603603
}
604604
//'W' {}
605605
'w' => {

branches/try2/src/libextra/uuid.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,13 @@ impl Uuid {
417417
}
418418
}
419419

420+
impl Default for Uuid {
421+
/// Returns the nil UUID, which is all zeroes
422+
fn default() -> Uuid {
423+
Uuid::new_nil()
424+
}
425+
}
426+
420427
impl Zero for Uuid {
421428
/// Returns the nil UUID, which is all zeroes
422429
fn zero() -> Uuid {

branches/try2/src/librustc/driver/driver.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,9 @@ pub fn build_session_options(binary: @str,
681681
link::output_type_bitcode
682682
} else { link::output_type_exe };
683683
let sysroot_opt = getopts::opt_maybe_str(matches, "sysroot").map_move(|m| @Path(m));
684-
let target = getopts::opt_maybe_str(matches, "target").unwrap_or_default(host_triple());
685-
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or_default(~"generic");
686-
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or_default(~"");
684+
let target = getopts::opt_maybe_str(matches, "target").unwrap_or(host_triple());
685+
let target_cpu = getopts::opt_maybe_str(matches, "target-cpu").unwrap_or(~"generic");
686+
let target_feature = getopts::opt_maybe_str(matches, "target-feature").unwrap_or(~"");
687687
let save_temps = getopts::opt_present(matches, "save-temps");
688688
let opt_level = {
689689
if (debugging_opts & session::no_opt) != 0 {
@@ -961,7 +961,7 @@ pub fn build_output_filenames(input: &input,
961961
if !linkage_metas.is_empty() {
962962
// But if a linkage meta is present, that overrides
963963
let maybe_name = linkage_metas.iter().find(|m| "name" == m.name());
964-
match maybe_name.chain(|m| m.value_str()) {
964+
match maybe_name.and_then(|m| m.value_str()) {
965965
Some(s) => stem = s,
966966
_ => ()
967967
}

0 commit comments

Comments
 (0)