Skip to content

Commit adf2af2

Browse files
committed
---
yaml --- r: 144013 b: refs/heads/try2 c: 3ad2355 h: refs/heads/master i: 144011: d869725 v: v3
1 parent 95d816c commit adf2af2

Some content is hidden

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

93 files changed

+1015
-1594
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: 680eb71564ebba5e76ce1e1a8287b30042332cc5
8+
refs/heads/try2: 3ad23552fbd463d97a3e26c900655b9d134516e4
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial-container.md

Lines changed: 15 additions & 11 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
@@ -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/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),
52+
env: Some(env.slice(0, env.len())),
5353
dir: None,
5454
in_fd: None,
5555
out_fd: None,

branches/try2/src/libextra/rl.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod rustrt {
3232

3333
/// Add a line to history
3434
pub unsafe fn add_history(line: &str) -> bool {
35-
do line.with_c_str |buf| {
35+
do line.to_c_str().with_ref |buf| {
3636
rustrt::linenoiseHistoryAdd(buf) == 1 as c_int
3737
}
3838
}
@@ -44,21 +44,21 @@ pub unsafe fn set_history_max_len(len: int) -> bool {
4444

4545
/// Save line history to a file
4646
pub unsafe fn save_history(file: &str) -> bool {
47-
do file.with_c_str |buf| {
47+
do file.to_c_str().with_ref |buf| {
4848
rustrt::linenoiseHistorySave(buf) == 1 as c_int
4949
}
5050
}
5151

5252
/// Load line history from a file
5353
pub unsafe fn load_history(file: &str) -> bool {
54-
do file.with_c_str |buf| {
54+
do file.to_c_str().with_ref |buf| {
5555
rustrt::linenoiseHistoryLoad(buf) == 1 as c_int
5656
}
5757
}
5858

5959
/// Print out a prompt and then wait for input and return it
6060
pub unsafe fn read(prompt: &str) -> Option<~str> {
61-
do prompt.with_c_str |buf| {
61+
do prompt.to_c_str().with_ref |buf| {
6262
let line = rustrt::linenoise(buf);
6363

6464
if line.is_null() { None }
@@ -80,7 +80,7 @@ pub unsafe fn complete(cb: CompletionCb) {
8080

8181
unsafe {
8282
do cb(str::raw::from_c_str(line)) |suggestion| {
83-
do suggestion.with_c_str |buf| {
83+
do suggestion.to_c_str().with_ref |buf| {
8484
rustrt::linenoiseAddCompletion(completions, buf);
8585
}
8686
}

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/librustc/back/link.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ pub fn WriteOutputFile(sess: Session,
7878
OptLevel: c_int,
7979
EnableSegmentedStacks: bool) {
8080
unsafe {
81-
do Triple.with_c_str |Triple| {
82-
do Cpu.with_c_str |Cpu| {
83-
do Feature.with_c_str |Feature| {
84-
do Output.with_c_str |Output| {
81+
do Triple.to_c_str().with_ref |Triple| {
82+
do Cpu.to_c_str().with_ref |Cpu| {
83+
do Feature.to_c_str().with_ref |Feature| {
84+
do Output.to_c_str().with_ref |Output| {
8585
let result = llvm::LLVMRustWriteOutputFile(
8686
PM,
8787
M,
@@ -152,7 +152,7 @@ pub mod jit {
152152

153153
debug!("linking: %s", path);
154154

155-
do path.with_c_str |buf_t| {
155+
do path.to_c_str().with_ref |buf_t| {
156156
if !llvm::LLVMRustLoadCrate(manager, buf_t) {
157157
llvm_err(sess, ~"Could not link");
158158
}
@@ -171,7 +171,7 @@ pub mod jit {
171171
// Next, we need to get a handle on the _rust_main function by
172172
// looking up it's corresponding ValueRef and then requesting that
173173
// the execution engine compiles the function.
174-
let fun = do "_rust_main".with_c_str |entry| {
174+
let fun = do "_rust_main".to_c_str().with_ref |entry| {
175175
llvm::LLVMGetNamedFunction(m, entry)
176176
};
177177
if fun.is_null() {
@@ -270,14 +270,14 @@ pub mod write {
270270
output_type_bitcode => {
271271
if opts.optimize != session::No {
272272
let filename = output.with_filetype("no-opt.bc");
273-
do filename.with_c_str |buf| {
273+
do filename.to_c_str().with_ref |buf| {
274274
llvm::LLVMWriteBitcodeToFile(llmod, buf);
275275
}
276276
}
277277
}
278278
_ => {
279279
let filename = output.with_filetype("bc");
280-
do filename.with_c_str |buf| {
280+
do filename.to_c_str().with_ref |buf| {
281281
llvm::LLVMWriteBitcodeToFile(llmod, buf);
282282
}
283283
}
@@ -340,7 +340,7 @@ pub mod write {
340340
// Always output the bitcode file with --save-temps
341341

342342
let filename = output.with_filetype("opt.bc");
343-
do filename.with_c_str |buf| {
343+
do filename.to_c_str().with_ref |buf| {
344344
llvm::LLVMWriteBitcodeToFile(llmod, buf)
345345
};
346346
// Save the assembly file if -S is used
@@ -401,13 +401,13 @@ pub mod write {
401401

402402
if output_type == output_type_llvm_assembly {
403403
// Given options "-S --emit-llvm": output LLVM assembly
404-
do output.with_c_str |buf_o| {
404+
do output.to_c_str().with_ref |buf_o| {
405405
llvm::LLVMRustAddPrintModulePass(pm.llpm, llmod, buf_o);
406406
}
407407
} else {
408408
// If only a bitcode file is asked for by using the
409409
// '--emit-llvm' flag, then output it here
410-
do output.with_c_str |buf| {
410+
do output.to_c_str().with_ref |buf| {
411411
llvm::LLVMWriteBitcodeToFile(llmod, buf);
412412
}
413413
}

branches/try2/src/librustc/back/passes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn populate_pass_manager(sess: Session, pm: &mut PassManager, pass_list:&[~s
173173
}
174174

175175
pub fn create_pass(name:&str) -> Option<PassRef> {
176-
do name.with_c_str |s| {
176+
do name.to_c_str().with_ref |s| {
177177
unsafe {
178178
let p = llvm::LLVMCreatePass(s);
179179
if p.is_null() {

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());

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ pub struct TargetData {
22712271
}
22722272

22732273
pub fn mk_target_data(string_rep: &str) -> TargetData {
2274-
let lltd = do string_rep.with_c_str |buf| {
2274+
let lltd = do string_rep.to_c_str().with_ref |buf| {
22752275
unsafe { llvm::LLVMCreateTargetData(buf) }
22762276
};
22772277

branches/try2/src/librustc/metadata/creader.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ pub fn read_crates(diag: @mut span_handler,
5757
warn_if_multiple_versions(e, diag, *e.crate_cache);
5858
}
5959

60-
#[deriving(Clone)]
6160
struct cache_entry {
6261
cnum: int,
6362
span: span,
@@ -77,13 +76,22 @@ fn dump_crates(crate_cache: &[cache_entry]) {
7776
fn warn_if_multiple_versions(e: @mut Env,
7877
diag: @mut span_handler,
7978
crate_cache: &[cache_entry]) {
79+
use std::either::*;
80+
8081
if crate_cache.len() != 0u {
8182
let name = loader::crate_name_from_metas(
8283
*crate_cache[crate_cache.len() - 1].metas
8384
);
8485

85-
let (matches, non_matches) = crate_cache.partitioned(|entry|
86-
name == loader::crate_name_from_metas(*entry.metas));
86+
let vec: ~[Either<cache_entry, cache_entry>] = crate_cache.iter().map(|&entry| {
87+
let othername = loader::crate_name_from_metas(*entry.metas);
88+
if name == othername {
89+
Left(entry)
90+
} else {
91+
Right(entry)
92+
}
93+
}).collect();
94+
let (matches, non_matches) = partition(vec);
8795

8896
assert!(!matches.is_empty());
8997

0 commit comments

Comments
 (0)