Skip to content

Commit aa641b2

Browse files
committed
---
yaml --- r: 145071 b: refs/heads/try2 c: ec8f884 h: refs/heads/master i: 145069: 3bc5877 145067: e0917ca 145063: 0f82453 145055: d70ca1f v: v3
1 parent e54e051 commit aa641b2

Some content is hidden

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

81 files changed

+801
-1412
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: 5f2f952dbcc1a0e2b57539ae7000710453fa3fb0
8+
refs/heads/try2: ec8f88417c2ced5bed685c6bc94d11a7c0840f96
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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,8 +1717,7 @@ 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-
* `Default`, to create an empty instance of a data type.
1721-
* `Zero`, to create an zero instance of a numeric data type.
1720+
* `Zero`, to create an zero (or empty) instance of a data type.
17221721
* `ToStr`, to convert to a string. For a type with this instance,
17231722
`obj.to_str()` has similar output as `fmt!("%?", obj)`, but it differs in that
17241723
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`, `Default`, `Zero`, and `ToStr`.
2252+
`IterBytes`, `Rand`, `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(""), filename.unwrap_or(""))
312+
fmt!("%s/%s", dir.unwrap_or_default(""), filename.unwrap_or_default(""))
313313
}
314314

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

branches/try2/src/etc/emacs/README.md

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
`rust-mode`: A major Emacs mode for editing Rust source code
2-
============================================================
1+
rust-mode: A major emacs mode for editing Rust source code
2+
==========================================================
33

4-
`rust-mode` makes editing [Rust](http://rust-lang.org) code with Emacs
4+
`rust-mode` makes editing [Rust](http://rust-lang.org) code with emacs
55
enjoyable.
66

77

88
### Manual Installation
99

10-
To install manually, check out this repository and add this to your
11-
`.emacs` file:
10+
To install manually, check out this repository and add this to your .emacs
11+
file:
1212

13-
```lisp
14-
(add-to-list 'load-path "/path/to/rust-mode/")
15-
(require 'rust-mode)
16-
```
13+
(add-to-list 'load-path "/path/to/rust-mode/")
14+
(require 'rust-mode)
1715

18-
`rust-mode` will automatically be associated with `.rs` files. To enable it
19-
explicitly, do <kbd>M-x rust-mode</kbd>.
16+
Rust mode will automatically be associated with .rs files. To enable it
17+
explicitly, do `M-x rust-mode`.
2018

21-
### `package.el` installation via Marmalade or MELPA
19+
### package.el installation via Marmalade or MELPA
2220

2321
It can be more convenient to use Emacs's package manager to handle
2422
installation for you if you use many elisp libraries. If you have
25-
`package.el` but haven't added Marmalade or MELPA, the community
26-
package source, yet, add this to `~/.emacs.d/init.el`:
23+
package.el but haven't added Marmalade or MELPA, the community package source,
24+
yet, add this to ~/.emacs.d/init.el:
2725

2826
Using Marmalade:
2927

@@ -49,33 +47,32 @@ Then do this to load the package listing:
4947
* <kbd>M-x package-refresh-contents</kbd>
5048

5149
If you use a version of Emacs prior to 24 that doesn't include
52-
`package.el`, you can get it from [here](http://bit.ly/pkg-el23).
50+
package.el, you can get it from http://bit.ly/pkg-el23.
5351

54-
If you have an older ELPA `package.el` installed from tromey.com, you
52+
If you have an older ELPA package.el installed from tromey.com, you
5553
should upgrade in order to support installation from multiple sources.
5654
The ELPA archive is deprecated and no longer accepting new packages,
5755
so the version there (1.7.1) is very outdated.
5856

59-
#### Install `rust-mode`
57+
#### Install rust-mode
6058

61-
One you have `package.el`, you can install `rust-mode` or any other
62-
modes by choosing them from a list:
59+
From there you can install rust-mode or any other modes by choosing
60+
them from a list:
6361

6462
* <kbd>M-x package-list-packages</kbd>
6563

66-
Now, to install packages, move your cursor to them and press
67-
<kbd>i</kbd>. This will mark the packages for installation. When
68-
you're done with marking, press <kbd>x</kbd>, and ELPA will install
69-
the packages for you (under `~/.emacs.d/elpa/`).
64+
Now, to install packages, move your cursor to them and press i. This
65+
will mark the packages for installation. When you're done with
66+
marking, press x, and ELPA will install the packages for you (under
67+
~/.emacs.d/elpa/).
7068

71-
* or using <kbd>M-x package-install rust-mode</kbd>
69+
* or using <kbd>M-x package-install rust-mode
7270

7371
### Tests via ERT
7472

75-
The file `rust-mode-tests.el` contains tests that can be run via
76-
[ERT](http://www.gnu.org/software/emacs/manual/html_node/ert/index.html).
77-
You can use `run_rust_emacs_tests.sh` to run them in batch mode, if
78-
Emacs is somewhere in your `$PATH`.
73+
The file `rust-mode-tests.el` contains tests that can be run via ERT. You can
74+
use `run_rust_emacs_tests.sh` to run them in batch mode, if emacs is somewhere
75+
in your `$PATH`.
7976

8077
### Known bugs
8178

branches/try2/src/libextra/glob.rs

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,7 @@ fn list_dir_sorted(path: &Path) -> ~[Path] {
137137
/**
138138
* A compiled Unix shell style pattern.
139139
*/
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)]
140+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes, Zero)]
151141
pub struct Pattern {
152142
priv tokens: ~[PatternToken]
153143
}
@@ -322,7 +312,7 @@ impl Pattern {
322312
let require_literal = |c| {
323313
(options.require_literal_separator && is_sep(c)) ||
324314
(options.require_literal_leading_dot && c == '.'
325-
&& is_sep(prev_char.unwrap_or('/')))
315+
&& is_sep(prev_char.unwrap_or_default('/')))
326316
};
327317
328318
for (ti, token) in self.tokens.slice_from(i).iter().enumerate() {
@@ -468,37 +458,7 @@ fn is_sep(c: char) -> bool {
468458
/**
469459
* Configuration options to modify the behaviour of `Pattern::matches_with(..)`
470460
*/
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)]
461+
#[deriving(Clone, Eq, TotalEq, Ord, TotalOrd, IterBytes, Zero)]
502462
pub struct MatchOptions {
503463
504464
/**

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().and_then(|n| {
638+
self.to_uint_opt().chain(|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().and_then(|n| {
1224+
Minus => self.data.to_uint_opt().chain(|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.and_then |a| {
276+
do a_option.chain |a| {
277277
let b_option: Option<T> = FromStr::from_str(split[1]);
278-
do b_option.and_then |b| {
278+
do b_option.chain |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.and_then |a| {
294+
do a_option.chain |a| {
295295
let b_option: Option<T> =
296296
FromStrRadix::from_str_radix(split[1], radix);
297-
do b_option.and_then |b| {
297+
do b_option.chain |b| {
298298
Some(Ratio::new(a.clone(), b.clone()))
299299
}
300300
}

branches/try2/src/libextra/tempfile.rs

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

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
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+
}

0 commit comments

Comments
 (0)