Skip to content

Commit e956a3e

Browse files
committed
---
yaml --- r: 63155 b: refs/heads/snap-stage3 c: 1e8982b h: refs/heads/master i: 63153: 7777316 63151: 994b31c v: v3
1 parent 742e568 commit e956a3e

File tree

20 files changed

+270
-516
lines changed

20 files changed

+270
-516
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 2ff6b298c5f23f48aa993fced41b6e29e446b7ce
4+
refs/heads/snap-stage3: 1e8982bdb26208d9d9ed4cdcbcd21cc9ef35bd46
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ fn parse_check_line(line: &str) -> Option<~str> {
141141
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
142142
do parse_name_value_directive(line, ~"exec-env").map |nv| {
143143
// nv is either FOO or FOO=BAR
144-
let mut strs = ~[];
145-
for str::each_splitn_char(*nv, '=', 1u) |s| { strs.push(s.to_owned()); }
144+
let mut strs: ~[~str] = nv.splitn_iter('=', 1).transform(|s| s.to_owned()).collect();
145+
146146
match strs.len() {
147147
1u => (strs.pop(), ~""),
148148
2u => {

branches/snap-stage3/src/compiletest/runtest.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
278278
// check if each line in props.check_lines appears in the
279279
// output (in order)
280280
let mut i = 0u;
281-
for str::each_line(ProcRes.stdout) |line| {
281+
for ProcRes.stdout.line_iter().advance |line| {
282282
if check_lines[i].trim() == line.trim() {
283283
i += 1u;
284284
}
@@ -308,7 +308,7 @@ fn check_error_patterns(props: &TestProps,
308308
let mut next_err_idx = 0u;
309309
let mut next_err_pat = &props.error_patterns[next_err_idx];
310310
let mut done = false;
311-
for str::each_line(ProcRes.stderr) |line| {
311+
for ProcRes.stderr.line_iter().advance |line| {
312312
if str::contains(line, *next_err_pat) {
313313
debug!("found error pattern %s", *next_err_pat);
314314
next_err_idx += 1u;
@@ -358,7 +358,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
358358
// filename:line1:col1: line2:col2: *warning:* msg
359359
// where line1:col1: is the starting point, line2:col2:
360360
// is the ending point, and * represents ANSI color codes.
361-
for str::each_line(ProcRes.stderr) |line| {
361+
for ProcRes.stderr.line_iter().advance |line| {
362362
let mut was_expected = false;
363363
for vec::eachi(expected_errors) |i, ee| {
364364
if !found_flags[i] {
@@ -612,15 +612,11 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
612612
}
613613

614614
fn split_maybe_args(argstr: &Option<~str>) -> ~[~str] {
615-
fn rm_whitespace(v: ~[~str]) -> ~[~str] {
616-
v.filtered(|s| !str::is_whitespace(*s))
617-
}
618-
619615
match *argstr {
620616
Some(ref s) => {
621-
let mut ss = ~[];
622-
for str::each_split_char(*s, ' ') |s| { ss.push(s.to_owned()) }
623-
rm_whitespace(ss)
617+
s.split_iter(' ')
618+
.filter_map(|s| if s.is_whitespace() {None} else {Some(s.to_owned())})
619+
.collect()
624620
}
625621
None => ~[]
626622
}
@@ -739,8 +735,7 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
739735
let cmdline = make_cmdline("", args.prog, args.args);
740736

741737
// get bare program string
742-
let mut tvec = ~[];
743-
for str::each_split_char(args.prog, '/') |ts| { tvec.push(ts.to_owned()) }
738+
let tvec: ~[~str] = args.prog.split_iter('/').transform(|ts| ts.to_owned()).collect();
744739
let prog_short = tvec.pop();
745740

746741
// copy to target

branches/snap-stage3/src/libextra/fileinput.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ mod test {
416416
417417
use core::iterator::IteratorUtil;
418418
use core::io;
419-
use core::str;
420419
use core::uint;
421420
use core::vec;
422421
@@ -527,9 +526,7 @@ mod test {
527526
}
528527

529528
for input_vec_state(filenames) |line, state| {
530-
let nums = do vec::build |p| {
531-
for str::each_split_char(line, ' ') |s| { p(s.to_owned()); }
532-
};
529+
let nums: ~[&str] = line.split_iter(' ').collect();
533530
let file_num = uint::from_str(nums[0]).get();
534531
let line_num = uint::from_str(nums[1]).get();
535532
assert_eq!(line_num, state.line_num_file);

branches/snap-stage3/src/libextra/getopts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282

8383
use core::prelude::*;
8484

85+
use core::iterator::IteratorUtil;
8586
use core::cmp::Eq;
8687
use core::result::{Err, Ok};
8788
use core::result;
@@ -247,14 +248,13 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
247248
let mut i_arg = None;
248249
if cur[1] == '-' as u8 {
249250
let tail = str::slice(cur, 2, curlen);
250-
let mut tail_eq = ~[];
251-
for str::each_splitn_char(tail, '=', 1) |s| { tail_eq.push(s.to_owned()) }
251+
let tail_eq: ~[&str] = tail.split_iter('=').collect();
252252
if tail_eq.len() <= 1 {
253253
names = ~[Long(tail.to_owned())];
254254
} else {
255255
names =
256-
~[Long(copy tail_eq[0])];
257-
i_arg = Some(copy tail_eq[1]);
256+
~[Long(tail_eq[0].to_owned())];
257+
i_arg = Some(tail_eq[1].to_owned());
258258
}
259259
} else {
260260
let mut j = 1;
@@ -635,7 +635,7 @@ pub mod groups {
635635

636636
// Normalize desc to contain words separated by one space character
637637
let mut desc_normalized_whitespace = ~"";
638-
for str::each_word(desc) |word| {
638+
for desc.word_iter().advance |word| {
639639
desc_normalized_whitespace.push_str(word);
640640
desc_normalized_whitespace.push_char(' ');
641641
}

branches/snap-stage3/src/libextra/net_ip.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use core::prelude::*;
1616

17+
use core::iterator::IteratorUtil;
1718
use core::libc;
1819
use core::comm::{stream, SharedChan};
1920
use core::ptr;
@@ -158,9 +159,7 @@ pub mod v4 {
158159

159160
use core::cast::transmute;
160161
use core::result;
161-
use core::str;
162162
use core::uint;
163-
use core::vec;
164163

165164
/**
166165
* Convert a str to `ip_addr`
@@ -199,14 +198,12 @@ pub mod v4 {
199198
}
200199
}
201200
pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
202-
let mut parts = ~[];
203-
for str::each_split_char(ip, '.') |s| { parts.push(s.to_owned()) }
204-
let parts = vec::map(parts, |s| {
205-
match uint::from_str(*s) {
206-
Some(n) if n <= 255 => n,
207-
_ => 256
201+
let parts: ~[uint] = ip.split_iter('.').transform(|s| {
202+
match uint::from_str(s) {
203+
Some(n) if n <= 255 => n,
204+
_ => 256
208205
}
209-
});
206+
}).collect();
210207
if parts.len() != 4 {
211208
Err(fmt!("'%s' doesn't have 4 parts", ip))
212209
} else if parts.contains(&256) {

branches/snap-stage3/src/libextra/net_url.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ fn userinfo_to_str(userinfo: &UserInfo) -> ~str {
334334
fn query_from_str(rawquery: &str) -> Query {
335335
let mut query: Query = ~[];
336336
if str::len(rawquery) != 0 {
337-
for str::each_split_char(rawquery, '&') |p| {
337+
for rawquery.split_iter('&').advance |p| {
338338
let (k, v) = split_char_first(p, '=');
339339
query.push((decode_component(k), decode_component(v)));
340340
};

branches/snap-stage3/src/libextra/num/rational.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
1313
use core::prelude::*;
1414

15+
use core::iterator::IteratorUtil;
1516
use core::cmp;
1617
use core::from_str::FromStr;
1718
use core::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
18-
use core::str;
19-
use core::vec;
2019
use super::bigint::BigInt;
2120

2221
/// Represents the ratio between 2 numbers.
@@ -252,11 +251,7 @@ impl<T: FromStr + Clone + Integer + Ord>
252251
FromStr for Ratio<T> {
253252
/// Parses `numer/denom`.
254253
fn from_str(s: &str) -> Option<Ratio<T>> {
255-
let split = vec::build(|push| {
256-
for str::each_splitn_char(s, '/', 1) |s| {
257-
push(s.to_owned());
258-
}
259-
});
254+
let split: ~[&str] = s.splitn_iter('/', 1).collect();
260255
if split.len() < 2 { return None; }
261256
do FromStr::from_str::<T>(split[0]).chain |a| {
262257
do FromStr::from_str::<T>(split[1]).chain |b| {
@@ -269,11 +264,7 @@ impl<T: FromStrRadix + Clone + Integer + Ord>
269264
FromStrRadix for Ratio<T> {
270265
/// Parses `numer/denom` where the numbers are in base `radix`.
271266
fn from_str_radix(s: &str, radix: uint) -> Option<Ratio<T>> {
272-
let split = vec::build(|push| {
273-
for str::each_splitn_char(s, '/', 1) |s| {
274-
push(s.to_owned());
275-
}
276-
});
267+
let split: ~[&str] = s.splitn_iter('/', 1).collect();
277268
if split.len() < 2 { None }
278269
else {
279270
do FromStrRadix::from_str_radix::<T>(split[0], radix).chain |a| {

branches/snap-stage3/src/libextra/terminfo/parser/compiled.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use core::prelude::*;
1414

1515
use core::{vec, int, str};
1616
use core::io::Reader;
17+
use core::iterator::IteratorUtil;
1718
use core::hashmap::HashMap;
1819
use super::super::TermInfo;
1920

@@ -212,11 +213,8 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
212213
return Err(~"incompatible file: more string offsets than expected");
213214
}
214215

215-
let mut term_names: ~[~str] = vec::with_capacity(2);
216216
let names_str = str::from_bytes(file.read_bytes(names_bytes as uint - 1)); // don't read NUL
217-
for names_str.each_split_char('|') |s| {
218-
term_names.push(s.to_owned());
219-
}
217+
let term_names: ~[~str] = names_str.split_iter('|').transform(|s| s.to_owned()).collect();
220218

221219
file.read_byte(); // consume NUL
222220

branches/snap-stage3/src/libextra/terminfo/searcher.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
/// Does not support hashed database, only filesystem!
1313
1414
use core::prelude::*;
15-
use core::{os, str};
15+
use core::{os};
1616
use core::os::getenv;
1717
use core::io::{file_reader, Reader};
18+
use core::iterator::IteratorUtil;
1819
use path = core::path::Path;
1920

2021
/// Return path to database entry for `term`
@@ -36,7 +37,7 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~path> {
3637
dirs_to_search.push(homedir.unwrap().push(".terminfo")); // ncurses compatability
3738
}
3839
match getenv("TERMINFO_DIRS") {
39-
Some(dirs) => for str::each_split_char(dirs, ':') |i| {
40+
Some(dirs) => for dirs.split_iter(':').advance |i| {
4041
if i == "" {
4142
dirs_to_search.push(path("/usr/share/terminfo"));
4243
} else {

branches/snap-stage3/src/librustc/driver/driver.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use middle;
2424
use util::common::time;
2525
use util::ppaux;
2626

27+
use core::iterator::IteratorUtil;
2728
use core::hashmap::HashMap;
2829
use core::int;
2930
use core::io;
@@ -684,11 +685,7 @@ pub fn build_session_options(binary: @~str,
684685
let addl_lib_search_paths = getopts::opt_strs(matches, "L").map(|s| Path(*s));
685686
let linker = getopts::opt_maybe_str(matches, "linker");
686687
let linker_args = getopts::opt_strs(matches, "link-args").flat_map( |a| {
687-
let mut args = ~[];
688-
for str::each_split_char(*a, ' ') |arg| {
689-
args.push(str::to_owned(arg));
690-
}
691-
args
688+
a.split_iter(' ').transform(|arg| arg.to_owned()).collect()
692689
});
693690

694691
let cfg = parse_cfgspecs(getopts::opt_strs(matches, "cfg"), demitter);
@@ -699,12 +696,9 @@ pub fn build_session_options(binary: @~str,
699696
let custom_passes = match getopts::opt_maybe_str(matches, "passes") {
700697
None => ~[],
701698
Some(s) => {
702-
let mut o = ~[];
703-
for s.each_split(|c| c == ' ' || c == ',') |s| {
704-
let s = s.trim().to_owned();
705-
o.push(s);
706-
}
707-
o
699+
s.split_iter(|c: char| c == ' ' || c == ',').transform(|s| {
700+
s.trim().to_owned()
701+
}).collect()
708702
}
709703
};
710704

branches/snap-stage3/src/librustc/metadata/cstore.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use core::prelude::*;
1717
use metadata::cstore;
1818
use metadata::decoder;
1919

20+
use core::iterator::IteratorUtil;
2021
use core::hashmap::HashMap;
2122
use core::vec;
2223
use extra;
@@ -114,7 +115,7 @@ pub fn get_used_libraries(cstore: &CStore) -> ~[~str] {
114115
}
115116

116117
pub fn add_used_link_args(cstore: &mut CStore, args: &str) {
117-
for args.each_split_char(' ') |s| {
118+
for args.split_iter(' ').advance |s| {
118119
cstore.used_link_args.push(s.to_owned());
119120
}
120121
}

branches/snap-stage3/src/librusti/rusti.rc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,11 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
339339
use_rl: bool)
340340
-> Option<Repl> {
341341
if line.starts_with(":") {
342+
// FIXME #5898: conflicts with Cell.take(), so can't be at the top level
343+
use core::iterator::IteratorUtil;
344+
342345
let full = line.substr(1, line.len() - 1);
343-
let mut split = ~[];
344-
for str::each_word(full) |word| { split.push(word.to_owned()) }
346+
let split: ~[~str] = full.word_iter().transform(|s| s.to_owned()).collect();
345347
let len = split.len();
346348

347349
if len > 0 {

branches/snap-stage3/src/librustpkg/path_util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install};
1717
use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
1818
use core::os::mkdir_recursive;
1919
use core::os;
20+
use core::iterator::IteratorUtil;
2021

2122
/// Returns the value of RUST_PATH, as a list
2223
/// of Paths. In general this should be read from the
@@ -166,7 +167,7 @@ fn library_in_workspace(full_name: &str, short_name: &str, where: Target,
166167
let f_name = match p_path.filename() {
167168
Some(s) => s, None => loop
168169
};
169-
for f_name.each_split_char('-') |piece| {
170+
for f_name.split_iter('-').advance |piece| {
170171
debug!("a piece = %s", piece);
171172
if which == 0 && piece != lib_prefix {
172173
break;

branches/snap-stage3/src/librustpkg/rustpkg.rc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern mod syntax;
2929

3030
use core::prelude::*;
3131
use core::*;
32+
use core::iterator::IteratorUtil;
3233
pub use core::path::Path;
3334
use core::hashmap::HashMap;
3435
use rustc::driver::{driver, session};
@@ -161,10 +162,8 @@ impl<'self> PkgScript<'self> {
161162
exe.to_str(), root.to_str(), "configs");
162163
let output = run::process_output(exe.to_str(), [root.to_str(), ~"configs"]);
163164
// Run the configs() function to get the configs
164-
let mut cfgs = ~[];
165-
for str::each_word(str::from_bytes(output.output)) |w| {
166-
cfgs.push(w.to_owned());
167-
}
165+
let cfgs = str::from_bytes_slice(output.output).word_iter()
166+
.transform(|w| w.to_owned()).collect();
168167
(cfgs, output.status)
169168
}
170169
}

branches/snap-stage3/src/libstd/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
use cast;
3232
use io;
33+
use iterator::IteratorUtil;
3334
use libc;
3435
use libc::{c_char, c_void, c_int, size_t};
3536
use libc::{mode_t, FILE};
@@ -224,12 +225,11 @@ pub fn env() -> ~[(~str,~str)] {
224225
fn env_convert(input: ~[~str]) -> ~[(~str, ~str)] {
225226
let mut pairs = ~[];
226227
for input.each |p| {
227-
let mut vs = ~[];
228-
for str::each_splitn_char(*p, '=', 1) |s| { vs.push(s.to_owned()) }
228+
let vs: ~[&str] = p.splitn_iter('=', 1).collect();
229229
debug!("splitting: len: %u",
230230
vs.len());
231231
assert_eq!(vs.len(), 2);
232-
pairs.push((copy vs[0], copy vs[1]));
232+
pairs.push((vs[0].to_owned(), vs[1].to_owned()));
233233
}
234234
pairs
235235
}

0 commit comments

Comments
 (0)