Skip to content

Commit e971bdc

Browse files
committed
---
yaml --- r: 143998 b: refs/heads/try2 c: cf4694e h: refs/heads/master v: v3
1 parent 6160bfe commit e971bdc

Some content is hidden

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

76 files changed

+798
-1461
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: 253337de825306a6080d65266eb2a5b101509e63
8+
refs/heads/try2: cf4694e73b5bcca81daf86093106e55bbe007599
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/po/tutorial-container.md.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ msgstr ""
481481
#, no-wrap
482482
msgid ""
483483
"~~~\n"
484-
"impl<A> FromIterator<A> for ~[A] {\n"
485-
" pub fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> ~[A] {\n"
484+
"impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {\n"
485+
" pub fn from_iterator(iterator: &mut T) -> ~[A] {\n"
486486
" let (lower, _) = iterator.size_hint();\n"
487487
" let mut xs = with_capacity(lower);\n"
488488
" for x in iterator {\n"

branches/try2/doc/tutorial-container.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ iterator object. For example, vector slices several iterators available:
112112
113113
* `iter()` and `rev_iter()`, for immutable references to the elements
114114
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
115-
* `move_iter()` and `move_rev_iter`, to move the elements out by-value
115+
* `consume_iter()` and `consume_rev_iter`, to move the elements out by-value
116116
117117
A typical mutable container will implement at least `iter()`, `mut_iter()` and
118-
`move_iter()` along with the reverse variants if it maintains an order.
118+
`consume_iter()` along with the reverse variants if it maintains an order.
119119
120120
### Freezing
121121
@@ -139,9 +139,9 @@ and `&mut`.
139139
140140
## Iterator adaptors
141141
142-
The `Iterator` trait provides many common algorithms as default methods. For
143-
example, the `fold` method will accumulate the items yielded by an `Iterator`
144-
into a single value:
142+
The `IteratorUtil` trait implements common algorithms as methods extending
143+
every `Iterator` implementation. For example, the `fold` method will accumulate
144+
the items yielded by an `Iterator` into a single value:
145145
146146
~~~
147147
let xs = [1, 9, 2, 3, 14, 12];
@@ -154,10 +154,14 @@ Some adaptors return an adaptor object implementing the `Iterator` trait itself:
154154
~~~
155155
let xs = [1, 9, 2, 3, 14, 12];
156156
let ys = [5, 2, 1, 8];
157-
let sum = xs.iter().chain(ys.iter()).fold(0, |a, b| a + *b);
157+
let sum = xs.iter().chain_(ys.iter()).fold(0, |a, b| a + *b);
158158
assert_eq!(sum, 57);
159159
~~~
160160
161+
Note that some adaptors like the `chain_` method above use a trailing
162+
underscore to work around an issue with method resolve. The underscores will be
163+
dropped when they become unnecessary.
164+
161165
## For loops
162166
163167
The `for` keyword can be used as sugar for iterating through any iterator:
@@ -208,7 +212,7 @@ Iterators offer generic conversion to containers with the `collect` adaptor:
208212
209213
~~~
210214
let xs = [0, 1, 1, 2, 3, 5, 8];
211-
let ys = xs.rev_iter().skip(1).map(|&x| x * 2).collect::<~[int]>();
215+
let ys = xs.rev_iter().skip(1).transform(|&x| x * 2).collect::<~[int]>();
212216
assert_eq!(ys, ~[10, 6, 4, 2, 2, 0]);
213217
~~~
214218
@@ -220,8 +224,8 @@ implementing the `FromIterator` trait. For example, the implementation for
220224
vectors is as follows:
221225
222226
~~~
223-
impl<A> FromIterator<A> for ~[A] {
224-
pub fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> ~[A] {
227+
impl<A, T: Iterator<A>> FromIterator<A, T> for ~[A] {
228+
pub fn from_iterator(iterator: &mut T) -> ~[A] {
225229
let (lower, _) = iterator.size_hint();
226230
let mut xs = with_capacity(lower);
227231
for x in iterator {
@@ -303,13 +307,13 @@ for &x in it.invert() {
303307
The `rev_iter` and `mut_rev_iter` methods on vectors just return an inverted
304308
version of the standard immutable and mutable vector iterators.
305309
306-
The `chain`, `map`, `filter`, `filter_map` and `inspect` adaptors are
310+
The `chain_`, `transform`, `filter`, `filter_map` and `peek` adaptors are
307311
`DoubleEndedIterator` implementations if the underlying iterators are.
308312
309313
~~~
310314
let xs = [1, 2, 3, 4];
311315
let ys = [5, 6, 7, 8];
312-
let mut it = xs.iter().chain(ys.iter()).map(|&x| x * 2);
316+
let mut it = xs.iter().chain_(ys.iter()).transform(|&x| x * 2);
313317

314318
printfln!("%?", it.next()); // prints `Some(2)`
315319

@@ -325,13 +329,13 @@ The `RandomAccessIterator` trait represents an iterator offering random access
325329
to the whole range. The `indexable` method retrieves the number of elements
326330
accessible with the `idx` method.
327331
328-
The `chain` adaptor is an implementation of `RandomAccessIterator` if the
332+
The `chain_` adaptor is an implementation of `RandomAccessIterator` if the
329333
underlying iterators are.
330334
331335
~~~
332336
let xs = [1, 2, 3, 4, 5];
333337
let ys = ~[7, 9, 11];
334-
let mut it = xs.iter().chain(ys.iter());
338+
let mut it = xs.iter().chain_(ys.iter());
335339
printfln!("%?", it.idx(0)); // prints `Some(&1)`
336340
printfln!("%?", it.idx(5)); // prints `Some(&7)`
337341
printfln!("%?", it.idx(7)); // prints `Some(&11)`

branches/try2/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ control reaches the end of the block:
436436
fn signum(x: int) -> int {
437437
if x < 0 { -1 }
438438
else if x > 0 { 1 }
439-
else { 0 }
439+
else { return 0 }
440440
}
441441
~~~~
442442

branches/try2/src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn run(lib_path: &str,
4949

5050
let env = env + target_env(lib_path, prog);
5151
let mut proc = run::Process::new(prog, args, run::ProcessOptions {
52-
env: Some(env.slice(0, env.len())),
52+
env: Some(env),
5353
dir: None,
5454
in_fd: None,
5555
out_fd: None,

branches/try2/src/libextra/dlist.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,16 @@ impl<A> DoubleEndedIterator<A> for MoveIterator<A> {
573573
fn next_back(&mut self) -> Option<A> { self.list.pop_back() }
574574
}
575575

576-
impl<A> FromIterator<A> for DList<A> {
577-
fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> DList<A> {
576+
impl<A, T: Iterator<A>> FromIterator<A, T> for DList<A> {
577+
fn from_iterator(iterator: &mut T) -> DList<A> {
578578
let mut ret = DList::new();
579579
ret.extend(iterator);
580580
ret
581581
}
582582
}
583583

584-
impl<A> Extendable<A> for DList<A> {
585-
fn extend<T: Iterator<A>>(&mut self, iterator: &mut T) {
584+
impl<A, T: Iterator<A>> Extendable<A, T> for DList<A> {
585+
fn extend(&mut self, iterator: &mut T) {
586586
for elt in *iterator { self.push_back(elt); }
587587
}
588588
}
@@ -1163,3 +1163,4 @@ mod tests {
11631163
}
11641164
}
11651165
}
1166+

branches/try2/src/libextra/priority_queue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,17 @@ impl<'self, T> Iterator<&'self T> for PriorityQueueIterator<'self, T> {
190190
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
191191
}
192192

193-
impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
194-
fn from_iterator<Iter: Iterator<T>>(iter: &mut Iter) -> PriorityQueue<T> {
193+
impl<T: Ord, Iter: Iterator<T>> FromIterator<T, Iter> for PriorityQueue<T> {
194+
fn from_iterator(iter: &mut Iter) -> PriorityQueue<T> {
195195
let mut q = PriorityQueue::new();
196196
q.extend(iter);
197197

198198
q
199199
}
200200
}
201201

202-
impl<T: Ord> Extendable<T> for PriorityQueue<T> {
203-
fn extend<Iter: Iterator<T>>(&mut self, iter: &mut Iter) {
202+
impl<T: Ord, Iter: Iterator<T>> Extendable<T, Iter> for PriorityQueue<T> {
203+
fn extend(&mut self, iter: &mut Iter) {
204204
let (lower, _) = iter.size_hint();
205205

206206
let len = self.capacity();

branches/try2/src/libextra/ringbuf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,17 @@ impl<A: Eq> Eq for RingBuf<A> {
322322
}
323323
}
324324

325-
impl<A> FromIterator<A> for RingBuf<A> {
326-
fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> RingBuf<A> {
325+
impl<A, T: Iterator<A>> FromIterator<A, T> for RingBuf<A> {
326+
fn from_iterator(iterator: &mut T) -> RingBuf<A> {
327327
let (lower, _) = iterator.size_hint();
328328
let mut deq = RingBuf::with_capacity(lower);
329329
deq.extend(iterator);
330330
deq
331331
}
332332
}
333333

334-
impl<A> Extendable<A> for RingBuf<A> {
335-
fn extend<T: Iterator<A>>(&mut self, iterator: &mut T) {
334+
impl<A, T: Iterator<A>> Extendable<A, T> for RingBuf<A> {
335+
fn extend(&mut self, iterator: &mut T) {
336336
for elt in *iterator {
337337
self.push_back(elt);
338338
}

branches/try2/src/libextra/sort.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,11 @@ mod test_qsort3 {
782782

783783
#[cfg(test)]
784784
mod test_qsort {
785+
785786
use sort::*;
786787

788+
use std::vec;
789+
787790
fn check_sort(v1: &mut [int], v2: &mut [int]) {
788791
let len = v1.len();
789792
fn leual(a: &int, b: &int) -> bool { *a <= *b }
@@ -832,7 +835,9 @@ mod test_qsort {
832835

833836
let immut_names = names;
834837

835-
for (&a, &b) in expected.iter().zip(immut_names.iter()) {
838+
let pairs = vec::zip_slice(expected, immut_names);
839+
for p in pairs.iter() {
840+
let (a, b) = *p;
836841
debug!("%d %d", a, b);
837842
assert_eq!(a, b);
838843
}

branches/try2/src/libextra/test.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ mod tests {
11211121

11221122
use std::either;
11231123
use std::comm::{stream, SharedChan};
1124+
use std::vec;
11241125
use tempfile;
11251126
use std::os;
11261127

@@ -1308,8 +1309,14 @@ mod tests {
13081309
~"test::parse_ignored_flag",
13091310
~"test::sort_tests"];
13101311
1311-
for (a, b) in expected.iter().zip(filtered.iter()) {
1312-
assert!(*a == b.desc.name.to_str());
1312+
let pairs = vec::zip(expected, filtered);
1313+
1314+
for p in pairs.iter() {
1315+
match *p {
1316+
(ref a, ref b) => {
1317+
assert!(*a == b.desc.name.to_str());
1318+
}
1319+
}
13131320
}
13141321
}
13151322

branches/try2/src/libextra/treemap.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -835,34 +835,34 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
835835
};
836836
}
837837

838-
impl<K: TotalOrd, V> FromIterator<(K, V)> for TreeMap<K, V> {
839-
fn from_iterator<T: Iterator<(K, V)>>(iter: &mut T) -> TreeMap<K, V> {
838+
impl<K: TotalOrd, V, T: Iterator<(K, V)>> FromIterator<(K, V), T> for TreeMap<K, V> {
839+
fn from_iterator(iter: &mut T) -> TreeMap<K, V> {
840840
let mut map = TreeMap::new();
841841
map.extend(iter);
842842
map
843843
}
844844
}
845845

846-
impl<K: TotalOrd, V> Extendable<(K, V)> for TreeMap<K, V> {
846+
impl<K: TotalOrd, V, T: Iterator<(K, V)>> Extendable<(K, V), T> for TreeMap<K, V> {
847847
#[inline]
848-
fn extend<T: Iterator<(K, V)>>(&mut self, iter: &mut T) {
848+
fn extend(&mut self, iter: &mut T) {
849849
for (k, v) in *iter {
850850
self.insert(k, v);
851851
}
852852
}
853853
}
854854

855-
impl<T: TotalOrd> FromIterator<T> for TreeSet<T> {
856-
fn from_iterator<Iter: Iterator<T>>(iter: &mut Iter) -> TreeSet<T> {
855+
impl<T: TotalOrd, Iter: Iterator<T>> FromIterator<T, Iter> for TreeSet<T> {
856+
fn from_iterator(iter: &mut Iter) -> TreeSet<T> {
857857
let mut set = TreeSet::new();
858858
set.extend(iter);
859859
set
860860
}
861861
}
862862

863-
impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
863+
impl<T: TotalOrd, Iter: Iterator<T>> Extendable<T, Iter> for TreeSet<T> {
864864
#[inline]
865-
fn extend<Iter: Iterator<T>>(&mut self, iter: &mut Iter) {
865+
fn extend(&mut self, iter: &mut Iter) {
866866
for elem in *iter {
867867
self.insert(elem);
868868
}

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ pub fn source_name(input: &input) -> @str {
6565
}
6666
}
6767
68-
pub fn default_configuration(sess: Session) ->
68+
pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
6969
ast::CrateConfig {
70-
let tos = match sess.targ_cfg.os {
71-
session::os_win32 => @"win32",
72-
session::os_macos => @"macos",
73-
session::os_linux => @"linux",
74-
session::os_android => @"android",
75-
session::os_freebsd => @"freebsd"
70+
let (libc, tos) = match sess.targ_cfg.os {
71+
session::os_win32 => (@"msvcrt.dll", @"win32"),
72+
session::os_macos => (@"libc.dylib", @"macos"),
73+
session::os_linux => (@"libc.so.6", @"linux"),
74+
session::os_android => (@"libc.so", @"android"),
75+
session::os_freebsd => (@"libc.so.7", @"freebsd")
7676
};
7777

7878
// ARM is bi-endian, however using NDK seems to default
@@ -92,7 +92,10 @@ pub fn default_configuration(sess: Session) ->
9292
mk(@"target_arch", arch),
9393
mk(@"target_endian", end),
9494
mk(@"target_word_size", wordsz),
95-
];
95+
mk(@"target_libc", libc),
96+
// Build bindings.
97+
mk(@"build_compiler", argv0),
98+
mk(@"build_input", source_name(input))];
9699
}
97100

98101
pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
@@ -101,11 +104,11 @@ pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
101104
}
102105
}
103106

104-
pub fn build_configuration(sess: Session) ->
107+
pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
105108
ast::CrateConfig {
106109
// Combine the configuration requested by the session (command line) with
107110
// some default and generated configuration items
108-
let default_cfg = default_configuration(sess);
111+
let default_cfg = default_configuration(sess, argv0, input);
109112
let mut user_cfg = sess.opts.cfg.clone();
110113
// If the user wants a test runner, then add the test cfg
111114
if sess.opts.test { append_configuration(&mut user_cfg, @"test") }
@@ -977,7 +980,7 @@ pub fn list_metadata(sess: Session, path: &Path, out: @io::Writer) {
977980
mod test {
978981

979982
use driver::driver::{build_configuration, build_session};
980-
use driver::driver::{build_session_options, optgroups};
983+
use driver::driver::{build_session_options, optgroups, str_input};
981984

982985
use extra::getopts::groups::getopts;
983986
use extra::getopts;
@@ -995,7 +998,7 @@ mod test {
995998
let sessopts = build_session_options(
996999
@"rustc", matches, diagnostic::emit);
9971000
let sess = build_session(sessopts, diagnostic::emit);
998-
let cfg = build_configuration(sess);
1001+
let cfg = build_configuration(sess, @"whatever", &str_input(@""));
9991002
assert!((attr::contains_name(cfg, "test")));
10001003
}
10011004

@@ -1013,7 +1016,7 @@ mod test {
10131016
let sessopts = build_session_options(
10141017
@"rustc", matches, diagnostic::emit);
10151018
let sess = build_session(sessopts, diagnostic::emit);
1016-
let cfg = build_configuration(sess);
1019+
let cfg = build_configuration(sess, @"whatever", &str_input(@""));
10171020
let mut test_items = cfg.iter().filter(|m| "test" == m.name());
10181021
assert!(test_items.next().is_some());
10191022
assert!(test_items.next().is_none());

0 commit comments

Comments
 (0)