replace explicit calls to vec::each with vec::each_ref, partially demode str
This commit is contained in:
parent
e17a3b3194
commit
1be24f0758
@ -425,8 +425,8 @@ fn compose_and_run_compiler(
|
||||
let extra_link_args = ~[~"-L",
|
||||
aux_output_dir_name(config, testfile).to_str()];
|
||||
|
||||
do vec::iter(props.aux_builds) |rel_ab| {
|
||||
let abs_ab = config.aux_base.push_rel(&Path(rel_ab));
|
||||
for vec::each_ref(props.aux_builds) |rel_ab| {
|
||||
let abs_ab = config.aux_base.push_rel(&Path(*rel_ab));
|
||||
let aux_args =
|
||||
make_compile_args(config, props, ~[~"--lib"] + extra_link_args,
|
||||
|a,b| make_lib_name(a, b, testfile), &abs_ab);
|
||||
|
@ -91,7 +91,7 @@ pure fn build_sized_opt<A>(size: Option<uint>,
|
||||
#[inline(always)]
|
||||
pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
|
||||
do build_sized(lhs.len() + rhs.len()) |push| {
|
||||
for vec::each(lhs) |x| { push(x); }
|
||||
for vec::each_ref(lhs) |x| { push(*x); }
|
||||
for uint::range(0, rhs.len()) |i| { push(rhs[i]); }
|
||||
}
|
||||
}
|
||||
@ -100,8 +100,8 @@ pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
|
||||
/// Apply a function to each element of a vector and return the results
|
||||
pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> @[U] {
|
||||
do build_sized(v.len()) |push| {
|
||||
for vec::each(v) |elem| {
|
||||
push(f(elem));
|
||||
for vec::each_ref(v) |elem| {
|
||||
push(f(*elem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ fn lefts<T: Copy, U>(eithers: &[Either<T, U>]) -> ~[T] {
|
||||
//! Extracts from a vector of either all the left values
|
||||
|
||||
let mut result: ~[T] = ~[];
|
||||
for vec::each(eithers) |elt| {
|
||||
match elt {
|
||||
for vec::each_ref(eithers) |elt| {
|
||||
match *elt {
|
||||
Left(l) => vec::push(result, l),
|
||||
_ => { /* fallthrough */ }
|
||||
}
|
||||
@ -46,8 +46,8 @@ fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
|
||||
//! Extracts from a vector of either all the right values
|
||||
|
||||
let mut result: ~[U] = ~[];
|
||||
for vec::each(eithers) |elt| {
|
||||
match elt {
|
||||
for vec::each_ref(eithers) |elt| {
|
||||
match *elt {
|
||||
Right(r) => vec::push(result, r),
|
||||
_ => { /* fallthrough */ }
|
||||
}
|
||||
@ -66,8 +66,8 @@ fn partition<T: Copy, U: Copy>(eithers: &[Either<T, U>])
|
||||
|
||||
let mut lefts: ~[T] = ~[];
|
||||
let mut rights: ~[U] = ~[];
|
||||
for vec::each(eithers) |elt| {
|
||||
match elt {
|
||||
for vec::each_ref(eithers) |elt| {
|
||||
match *elt {
|
||||
Left(l) => vec::push(lefts, l),
|
||||
Right(r) => vec::push(rights, r)
|
||||
}
|
||||
|
@ -390,7 +390,9 @@ impl &SipState : Streaming {
|
||||
fn result_str() -> ~str {
|
||||
let r = self.result_bytes();
|
||||
let mut s = ~"";
|
||||
for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); }
|
||||
for vec::each_ref(r) |b| {
|
||||
s += uint::to_str(*b as uint, 16u);
|
||||
}
|
||||
move s
|
||||
}
|
||||
|
||||
@ -483,7 +485,9 @@ fn test_siphash() {
|
||||
|
||||
fn to_hex_str(r: &[u8]/8) -> ~str {
|
||||
let mut s = ~"";
|
||||
for vec::each(*r) |b| { s += uint::to_str(b as uint, 16u); }
|
||||
for vec::each_ref(*r) |b| {
|
||||
s += uint::to_str(*b as uint, 16u);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -450,8 +450,8 @@ fn mk_file_writer(path: &Path, flags: ~[FileFlag])
|
||||
fn wb() -> c_int { O_WRONLY as c_int }
|
||||
|
||||
let mut fflags: c_int = wb();
|
||||
for vec::each(flags) |f| {
|
||||
match f {
|
||||
for vec::each_ref(flags) |f| {
|
||||
match *f {
|
||||
Append => fflags |= O_APPEND as c_int,
|
||||
Create => fflags |= O_CREAT as c_int,
|
||||
Truncate => fflags |= O_TRUNC as c_int,
|
||||
|
@ -7,7 +7,12 @@ type IMPL_T<A> = dvec::DVec<A>;
|
||||
* Attempts to access this dvec during iteration will fail.
|
||||
*/
|
||||
pure fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) {
|
||||
unsafe { self.swap(|v| { vec::each(v, f); move v }) }
|
||||
unsafe {
|
||||
do self.swap |v| {
|
||||
vec::each(v, f);
|
||||
move v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pure fn SIZE_HINT<A>(self: IMPL_T<A>) -> Option<uint> {
|
||||
|
@ -210,8 +210,8 @@ mod global_env {
|
||||
|
||||
fn env() -> ~[(~str,~str)] {
|
||||
let mut pairs = ~[];
|
||||
for vec::each(rustrt::rust_env_pairs()) |p| {
|
||||
let vs = str::splitn_char(p, '=', 1u);
|
||||
for vec::each_ref(rustrt::rust_env_pairs()) |p| {
|
||||
let vs = str::splitn_char(*p, '=', 1u);
|
||||
assert vec::len(vs) == 2u;
|
||||
vec::push(pairs, (copy vs[0], copy vs[1]));
|
||||
}
|
||||
@ -892,8 +892,8 @@ mod tests {
|
||||
fn test_env_getenv() {
|
||||
let e = env();
|
||||
assert vec::len(e) > 0u;
|
||||
for vec::each(e) |p| {
|
||||
let (n, v) = copy p;
|
||||
for vec::each_ref(e) |p| {
|
||||
let (n, v) = copy *p;
|
||||
log(debug, n);
|
||||
let v2 = getenv(n);
|
||||
// MingW seems to set some funky environment variables like
|
||||
@ -985,7 +985,9 @@ mod tests {
|
||||
// Just assuming that we've got some contents in the current directory
|
||||
assert (vec::len(dirs) > 0u);
|
||||
|
||||
for vec::each(dirs) |dir| { log(debug, dir); }
|
||||
for vec::each_ref(dirs) |dir| {
|
||||
log(debug, *dir);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1099,7 +1099,7 @@ impl<T: Send> PortSet<T> : Recv<T> {
|
||||
pure fn peek() -> bool {
|
||||
// It'd be nice to use self.port.each, but that version isn't
|
||||
// pure.
|
||||
for vec::each(self.ports) |p| {
|
||||
for vec::each_ref(self.ports) |p| {
|
||||
if p.peek() { return true }
|
||||
}
|
||||
false
|
||||
|
@ -158,7 +158,7 @@ impl ReprVisitor {
|
||||
|
||||
fn write_escaped_slice(slice: &str) {
|
||||
self.writer.write_char('"');
|
||||
do str::chars_iter(slice) |ch| {
|
||||
for str::chars_each(slice) |ch| {
|
||||
self.writer.write_escaped_char(ch);
|
||||
}
|
||||
self.writer.write_char('"');
|
||||
@ -563,7 +563,7 @@ impl ReprPrinterWrapper {
|
||||
let vec_repr = *vec_repr_ptr;
|
||||
let data_ptr = ptr::to_unsafe_ptr(&(*vec_repr).unboxed.data);
|
||||
let slice: &str = transmute((data_ptr, (*vec_repr).unboxed.fill));
|
||||
do str::chars_iter(slice) |ch| {
|
||||
for str::chars_each(slice) |ch| {
|
||||
self.printer.writer.write_escaped_char(ch);
|
||||
}
|
||||
self.printer.writer.write_char('"');
|
||||
@ -686,7 +686,7 @@ impl ReprPrinterWrapper : TyVisitor {
|
||||
self.printer.writer.write_char('"');
|
||||
let slice_ptr: *&str = transmute(copy self.printer.ptr);
|
||||
let slice = *slice_ptr;
|
||||
do str::chars_iter(slice) |ch| {
|
||||
for str::chars_each(slice) |ch| {
|
||||
self.printer.writer.write_escaped_char(ch);
|
||||
}
|
||||
self.printer.writer.write_char('"');
|
||||
|
@ -267,11 +267,11 @@ impl<T: Copy, E: Copy> Result<T, E> {
|
||||
* }
|
||||
*/
|
||||
fn map_vec<T,U:Copy,V:Copy>(
|
||||
ts: &[T], op: fn(T) -> Result<V,U>) -> Result<~[V],U> {
|
||||
ts: &[T], op: fn((&T)) -> Result<V,U>) -> Result<~[V],U> {
|
||||
|
||||
let mut vs: ~[V] = ~[];
|
||||
vec::reserve(vs, vec::len(ts));
|
||||
for vec::each(ts) |t| {
|
||||
for vec::each_ref(ts) |t| {
|
||||
match op(t) {
|
||||
Ok(v) => vec::push(vs, v),
|
||||
Err(u) => return Err(u)
|
||||
|
@ -86,8 +86,8 @@ fn with_argv<T>(prog: &str, args: &[~str],
|
||||
cb: fn(**libc::c_char) -> T) -> T {
|
||||
let mut argptrs = str::as_c_str(prog, |b| ~[b]);
|
||||
let mut tmps = ~[];
|
||||
for vec::each(args) |arg| {
|
||||
let t = @copy arg;
|
||||
for vec::each_ref(args) |arg| {
|
||||
let t = @copy *arg;
|
||||
vec::push(tmps, t);
|
||||
vec::push_all(argptrs, str::as_c_str(*t, |b| ~[b]));
|
||||
}
|
||||
@ -105,8 +105,8 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
|
||||
let mut tmps = ~[];
|
||||
let mut ptrs = ~[];
|
||||
|
||||
for vec::each(es) |e| {
|
||||
let (k,v) = copy e;
|
||||
for vec::each_ref(es) |e| {
|
||||
let (k,v) = copy *e;
|
||||
let t = @(fmt!("%s=%s", k, v));
|
||||
vec::push(tmps, t);
|
||||
vec::push_all(ptrs, str::as_c_str(*t, |b| ~[b]));
|
||||
@ -130,8 +130,8 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>,
|
||||
match *env {
|
||||
Some(es) if !vec::is_empty(es) => {
|
||||
let mut blk : ~[u8] = ~[];
|
||||
for vec::each(es) |e| {
|
||||
let (k,v) = e;
|
||||
for vec::each_ref(es) |e| {
|
||||
let (k,v) = *e;
|
||||
let t = fmt!("%s=%s", k, v);
|
||||
let mut v : ~[u8] = ::unsafe::reinterpret_cast(&t);
|
||||
blk += v;
|
||||
|
@ -312,7 +312,7 @@ mod linear {
|
||||
}
|
||||
|
||||
pure fn each_ref(&self, blk: fn(k: &K, v: &V) -> bool) {
|
||||
for vec::each(self.buckets) |slot| {
|
||||
for vec::each_ref(self.buckets) |slot| {
|
||||
let mut broke = false;
|
||||
do slot.iter |bucket| {
|
||||
if !blk(&bucket.key, &bucket.value) {
|
||||
|
@ -72,12 +72,12 @@ export
|
||||
map,
|
||||
each, eachi,
|
||||
each_char, each_chari,
|
||||
bytes_iter,
|
||||
chars_iter,
|
||||
split_char_iter,
|
||||
splitn_char_iter,
|
||||
words_iter,
|
||||
lines_iter,
|
||||
bytes_each,
|
||||
chars_each,
|
||||
split_char_each,
|
||||
splitn_char_each,
|
||||
words_each,
|
||||
lines_each,
|
||||
|
||||
// Searching
|
||||
find, find_from, find_between,
|
||||
@ -235,7 +235,9 @@ pure fn from_chars(chs: &[char]) -> ~str {
|
||||
let mut buf = ~"";
|
||||
unsafe {
|
||||
reserve(buf, chs.len());
|
||||
for vec::each(chs) |ch| { push_char(buf, ch); }
|
||||
for vec::each_ref(chs) |ch| {
|
||||
push_char(buf, *ch);
|
||||
}
|
||||
}
|
||||
move buf
|
||||
}
|
||||
@ -289,16 +291,18 @@ pure fn append(+lhs: ~str, rhs: &str) -> ~str {
|
||||
/// Concatenate a vector of strings
|
||||
pure fn concat(v: &[~str]) -> ~str {
|
||||
let mut s: ~str = ~"";
|
||||
for vec::each(v) |ss| { unsafe { push_str(s, ss) }; }
|
||||
for vec::each_ref(v) |ss| {
|
||||
unsafe { push_str(s, *ss) };
|
||||
}
|
||||
move s
|
||||
}
|
||||
|
||||
/// Concatenate a vector of strings, placing a given separator between each
|
||||
pure fn connect(v: &[~str], sep: &str) -> ~str {
|
||||
let mut s = ~"", first = true;
|
||||
for vec::each(v) |ss| {
|
||||
for vec::each_ref(v) |ss| {
|
||||
if first { first = false; } else { unsafe { push_str(s, sep); } }
|
||||
unsafe { push_str(s, ss) };
|
||||
unsafe { push_str(s, *ss) };
|
||||
}
|
||||
move s
|
||||
}
|
||||
@ -879,7 +883,7 @@ pure fn map(ss: &str, ff: fn(char) -> char) -> ~str {
|
||||
let mut result = ~"";
|
||||
unsafe {
|
||||
reserve(result, len(ss));
|
||||
do chars_iter(ss) |cc| {
|
||||
for chars_each(ss) |cc| {
|
||||
str::push_char(result, ff(cc));
|
||||
}
|
||||
}
|
||||
@ -887,12 +891,12 @@ pure fn map(ss: &str, ff: fn(char) -> char) -> ~str {
|
||||
}
|
||||
|
||||
/// Iterate over the bytes in a string
|
||||
pure fn bytes_iter(ss: &str, it: fn(u8)) {
|
||||
pure fn bytes_each(ss: &str, it: fn(u8) -> bool) {
|
||||
let mut pos = 0u;
|
||||
let len = len(ss);
|
||||
|
||||
while (pos < len) {
|
||||
it(ss[pos]);
|
||||
if !it(ss[pos]) { return; }
|
||||
pos += 1u;
|
||||
}
|
||||
}
|
||||
@ -933,40 +937,40 @@ pure fn each_chari(s: &str, it: fn(uint, char) -> bool) {
|
||||
}
|
||||
|
||||
/// Iterate over the characters in a string
|
||||
pure fn chars_iter(s: &str, it: fn(char)) {
|
||||
pure fn chars_each(s: &str, it: fn(char) -> bool) {
|
||||
let mut pos = 0u;
|
||||
let len = len(s);
|
||||
while (pos < len) {
|
||||
let {ch, next} = char_range_at(s, pos);
|
||||
pos = next;
|
||||
it(ch);
|
||||
if !it(ch) { return; }
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a function to each substring after splitting by character
|
||||
pure fn split_char_iter(ss: &str, cc: char, ff: fn(&&~str)) {
|
||||
vec::iter(split_char(ss, cc), ff)
|
||||
pure fn split_char_each(ss: &str, cc: char, ff: fn(v: &str) -> bool) {
|
||||
vec::each_ref(split_char(ss, cc), |s| ff(*s))
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a function to each substring after splitting by character, up to
|
||||
* `count` times
|
||||
*/
|
||||
pure fn splitn_char_iter(ss: &str, sep: char, count: uint,
|
||||
ff: fn(&&~str)) {
|
||||
vec::iter(splitn_char(ss, sep, count), ff)
|
||||
pure fn splitn_char_each(ss: &str, sep: char, count: uint,
|
||||
ff: fn(v: &str) -> bool) {
|
||||
vec::each_ref(splitn_char(ss, sep, count), |s| ff(*s))
|
||||
}
|
||||
|
||||
/// Apply a function to each word
|
||||
pure fn words_iter(ss: &str, ff: fn(&&~str)) {
|
||||
vec::iter(words(ss), ff)
|
||||
pure fn words_each(ss: &str, ff: fn(v: &str) -> bool) {
|
||||
vec::each_ref(words(ss), |s| ff(*s))
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a function to each line (by '\n')
|
||||
*/
|
||||
pure fn lines_iter(ss: &str, ff: fn(&&~str)) {
|
||||
vec::iter(lines(ss), ff)
|
||||
pure fn lines_each(ss: &str, ff: fn(v: &str) -> bool) {
|
||||
vec::each_ref(lines(ss), |s| ff(*s))
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1518,7 +1522,7 @@ pure fn is_utf16(v: &[u16]) -> bool {
|
||||
/// Converts to a vector of `u16` encoded as UTF-16
|
||||
pure fn to_utf16(s: &str) -> ~[u16] {
|
||||
let mut u = ~[];
|
||||
do chars_iter(s) |cch| {
|
||||
for chars_each(s) |cch| {
|
||||
// Arithmetic with u32 literals is easier on the eyes than chars.
|
||||
let mut ch = cch as u32;
|
||||
|
||||
@ -1947,7 +1951,9 @@ pure fn escape_default(s: &str) -> ~str {
|
||||
let mut out: ~str = ~"";
|
||||
unsafe {
|
||||
reserve_at_least(out, str::len(s));
|
||||
chars_iter(s, |c| push_str(out, char::escape_default(c)));
|
||||
for chars_each(s) |c| {
|
||||
push_str(out, char::escape_default(c));
|
||||
}
|
||||
}
|
||||
move out
|
||||
}
|
||||
@ -1957,7 +1963,9 @@ pure fn escape_unicode(s: &str) -> ~str {
|
||||
let mut out: ~str = ~"";
|
||||
unsafe {
|
||||
reserve_at_least(out, str::len(s));
|
||||
chars_iter(s, |c| push_str(out, char::escape_unicode(c)));
|
||||
for chars_each(s) |c| {
|
||||
push_str(out, char::escape_unicode(c));
|
||||
}
|
||||
}
|
||||
move out
|
||||
}
|
||||
@ -2094,7 +2102,7 @@ mod raw {
|
||||
/// Appends a vector of bytes to a string. (Not UTF-8 safe).
|
||||
unsafe fn push_bytes(&s: ~str, bytes: ~[u8]) {
|
||||
reserve_at_least(s, s.len() + bytes.len());
|
||||
for vec::each(bytes) |byte| { push_byte(s, byte); }
|
||||
for vec::each_ref(bytes) |byte| { push_byte(s, *byte); }
|
||||
}
|
||||
|
||||
/// Removes the last byte from a string and returns it. (Not UTF-8 safe).
|
||||
@ -3044,50 +3052,52 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chars_iter() {
|
||||
fn test_chars_each() {
|
||||
let mut i = 0;
|
||||
do chars_iter(~"x\u03c0y") |ch| {
|
||||
for chars_each(~"x\u03c0y") |ch| {
|
||||
match i {
|
||||
0 => assert ch == 'x',
|
||||
1 => assert ch == '\u03c0',
|
||||
2 => assert ch == 'y',
|
||||
_ => fail ~"test_chars_iter failed"
|
||||
_ => fail ~"test_chars_each failed"
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
chars_iter(~"", |_ch| fail ); // should not fail
|
||||
chars_each(~"", |_ch| fail ); // should not fail
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bytes_iter() {
|
||||
fn test_bytes_each() {
|
||||
let mut i = 0;
|
||||
|
||||
do bytes_iter(~"xyz") |bb| {
|
||||
for bytes_each(~"xyz") |bb| {
|
||||
match i {
|
||||
0 => assert bb == 'x' as u8,
|
||||
1 => assert bb == 'y' as u8,
|
||||
2 => assert bb == 'z' as u8,
|
||||
_ => fail ~"test_bytes_iter failed"
|
||||
_ => fail ~"test_bytes_each failed"
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
bytes_iter(~"", |bb| assert bb == 0u8);
|
||||
for bytes_each(~"") |bb| {
|
||||
assert bb == 0u8;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_char_iter() {
|
||||
fn test_split_char_each() {
|
||||
let data = ~"\nMary had a little lamb\nLittle lamb\n";
|
||||
|
||||
let mut ii = 0;
|
||||
|
||||
do split_char_iter(data, ' ') |xx| {
|
||||
for split_char_each(data, ' ') |xx| {
|
||||
match ii {
|
||||
0 => assert ~"\nMary" == xx,
|
||||
1 => assert ~"had" == xx,
|
||||
2 => assert ~"a" == xx,
|
||||
3 => assert ~"little" == xx,
|
||||
0 => assert "\nMary" == xx,
|
||||
1 => assert "had" == xx,
|
||||
2 => assert "a" == xx,
|
||||
3 => assert "little" == xx,
|
||||
_ => ()
|
||||
}
|
||||
ii += 1;
|
||||
@ -3095,16 +3105,16 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_splitn_char_iter() {
|
||||
fn test_splitn_char_each() {
|
||||
let data = ~"\nMary had a little lamb\nLittle lamb\n";
|
||||
|
||||
let mut ii = 0;
|
||||
|
||||
do splitn_char_iter(data, ' ', 2u) |xx| {
|
||||
for splitn_char_each(data, ' ', 2u) |xx| {
|
||||
match ii {
|
||||
0 => assert ~"\nMary" == xx,
|
||||
1 => assert ~"had" == xx,
|
||||
2 => assert ~"a little lamb\nLittle lamb\n" == xx,
|
||||
0 => assert "\nMary" == xx,
|
||||
1 => assert "had" == xx,
|
||||
2 => assert "a little lamb\nLittle lamb\n" == xx,
|
||||
_ => ()
|
||||
}
|
||||
ii += 1;
|
||||
@ -3112,37 +3122,37 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_words_iter() {
|
||||
fn test_words_each() {
|
||||
let data = ~"\nMary had a little lamb\nLittle lamb\n";
|
||||
|
||||
let mut ii = 0;
|
||||
|
||||
do words_iter(data) |ww| {
|
||||
for words_each(data) |ww| {
|
||||
match ii {
|
||||
0 => assert ~"Mary" == ww,
|
||||
1 => assert ~"had" == ww,
|
||||
2 => assert ~"a" == ww,
|
||||
3 => assert ~"little" == ww,
|
||||
0 => assert "Mary" == ww,
|
||||
1 => assert "had" == ww,
|
||||
2 => assert "a" == ww,
|
||||
3 => assert "little" == ww,
|
||||
_ => ()
|
||||
}
|
||||
ii += 1;
|
||||
}
|
||||
|
||||
words_iter(~"", |_x| fail); // should not fail
|
||||
words_each(~"", |_x| fail); // should not fail
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lines_iter () {
|
||||
fn test_lines_each () {
|
||||
let lf = ~"\nMary had a little lamb\nLittle lamb\n";
|
||||
|
||||
let mut ii = 0;
|
||||
|
||||
do lines_iter(lf) |x| {
|
||||
for lines_each(lf) |x| {
|
||||
match ii {
|
||||
0 => assert ~"" == x,
|
||||
1 => assert ~"Mary had a little lamb" == x,
|
||||
2 => assert ~"Little lamb" == x,
|
||||
3 => assert ~"" == x,
|
||||
0 => assert "" == x,
|
||||
1 => assert "Mary had a little lamb" == x,
|
||||
2 => assert "Little lamb" == x,
|
||||
3 => assert "" == x,
|
||||
_ => ()
|
||||
}
|
||||
ii += 1;
|
||||
@ -3220,8 +3230,8 @@ mod tests {
|
||||
0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
|
||||
0x000a_u16 ]) ];
|
||||
|
||||
for vec::each(pairs) |p| {
|
||||
let (s, u) = copy p;
|
||||
for vec::each_ref(pairs) |p| {
|
||||
let (s, u) = copy *p;
|
||||
assert to_utf16(s) == u;
|
||||
assert from_utf16(u) == s;
|
||||
assert from_utf16(to_utf16(s)) == s;
|
||||
|
@ -75,7 +75,7 @@ impl<A: ToStr Copy, B: ToStr Copy, C: ToStr Copy> (A, B, C): ToStr {
|
||||
impl<A: ToStr> ~[A]: ToStr {
|
||||
fn to_str() -> ~str {
|
||||
let mut acc = ~"[", first = true;
|
||||
for vec::each(self) |elt| {
|
||||
for vec::each_ref(self) |elt| {
|
||||
if first { first = false; }
|
||||
else { str::push_str(acc, ~", "); }
|
||||
str::push_str(acc, elt.to_str());
|
||||
|
@ -76,12 +76,9 @@ export zip, zip_slice;
|
||||
export swap;
|
||||
export reverse;
|
||||
export reversed;
|
||||
export iter, iter_between, each, eachi, reach, reachi;
|
||||
export each, eachi, reach, reachi;
|
||||
export each_ref, each_mut_ref, each_const_ref;
|
||||
export iter2;
|
||||
export iteri;
|
||||
export riter;
|
||||
export riteri;
|
||||
export permute;
|
||||
export windowed;
|
||||
export as_imm_buf;
|
||||
@ -857,8 +854,8 @@ pure fn connect<T: Copy>(v: &[~[T]], sep: T) -> ~[T] {
|
||||
/// Reduce a vector from left to right
|
||||
pure fn foldl<T: Copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
|
||||
let mut accum = z;
|
||||
do iter(v) |elt| {
|
||||
accum = p(accum, elt);
|
||||
for each_ref(v) |elt| {
|
||||
accum = p(accum, *elt);
|
||||
}
|
||||
return accum;
|
||||
}
|
||||
@ -866,7 +863,7 @@ pure fn foldl<T: Copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T {
|
||||
/// Reduce a vector from right to left
|
||||
pure fn foldr<T, U: Copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U {
|
||||
let mut accum = z;
|
||||
do riter(v) |elt| {
|
||||
for reach(v) |elt| {
|
||||
accum = p(elt, accum);
|
||||
}
|
||||
return accum;
|
||||
@ -1150,7 +1147,6 @@ fn reverse<T>(v: &[mut T]) {
|
||||
while i < ln / 2u { v[i] <-> v[ln - i - 1u]; i += 1u; }
|
||||
}
|
||||
|
||||
|
||||
/// Returns a vector with the order of elements reversed
|
||||
pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] {
|
||||
let mut rs: ~[T] = ~[];
|
||||
@ -1163,43 +1159,6 @@ pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] {
|
||||
move rs
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over a slice
|
||||
*
|
||||
* Iterates over slice `v` and, for each element, calls function `f` with the
|
||||
* element's value.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn iter<T>(v: &[T], f: fn(T)) {
|
||||
iter_between(v, 0u, vec::len(v), f)
|
||||
}
|
||||
|
||||
/*
|
||||
Function: iter_between
|
||||
|
||||
Iterates over a slice
|
||||
|
||||
Iterates over slice `v` and, for each element, calls function `f` with the
|
||||
element's value.
|
||||
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn iter_between<T>(v: &[T], start: uint, end: uint, f: fn(T)) {
|
||||
do as_imm_buf(v) |base_ptr, len| {
|
||||
assert start <= end;
|
||||
assert end <= len;
|
||||
unsafe {
|
||||
let mut n = end;
|
||||
let mut p = ptr::offset(base_ptr, start);
|
||||
while n > start {
|
||||
f(*p);
|
||||
p = ptr::offset(p, 1u);
|
||||
n -= 1u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over a vector, with option to break
|
||||
*
|
||||
@ -1344,43 +1303,6 @@ fn iter2<U, T>(v1: &[U], v2: &[T], f: fn(U, T)) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over a vector's elements and indexes
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with the
|
||||
* element's value and index.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn iteri<T>(v: &[T], f: fn(uint, T)) {
|
||||
let mut i = 0u;
|
||||
let l = len(v);
|
||||
while i < l { f(i, v[i]); i += 1u; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over a vector in reverse
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with the
|
||||
* element's value.
|
||||
*/
|
||||
pure fn riter<T>(v: &[T], f: fn(T)) {
|
||||
riteri(v, |_i, v| f(v))
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates over a vector's elements and indexes in reverse
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with the
|
||||
* element's value and index.
|
||||
*/
|
||||
pure fn riteri<T>(v: &[T], f: fn(uint, T)) {
|
||||
let mut i = len(v);
|
||||
while 0u < i {
|
||||
i -= 1u;
|
||||
f(i, v[i]);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over all permutations of vector `v`.
|
||||
*
|
||||
@ -1414,12 +1336,12 @@ pure fn permute<T: Copy>(v: &[const T], put: fn(~[T])) {
|
||||
pure fn windowed<TT: Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] {
|
||||
let mut ww = ~[];
|
||||
assert 1u <= nn;
|
||||
vec::iteri (xx, |ii, _x| {
|
||||
for vec::eachi (xx) |ii, _x| {
|
||||
let len = vec::len(xx);
|
||||
if ii+nn <= len unsafe {
|
||||
vec::push(ww, vec::slice(xx, ii, ii+nn));
|
||||
}
|
||||
});
|
||||
}
|
||||
move ww
|
||||
}
|
||||
|
||||
@ -1626,10 +1548,6 @@ impl<T: Copy> &[const T]: CopyableVector<T> {
|
||||
|
||||
trait ImmutableVector<T> {
|
||||
pure fn foldr<U: Copy>(z: U, p: fn(T, U) -> U) -> U;
|
||||
pure fn iter(f: fn(T));
|
||||
pure fn iteri(f: fn(uint, T));
|
||||
pure fn riter(f: fn(T));
|
||||
pure fn riteri(f: fn(uint, T));
|
||||
pure fn map<U>(f: fn(T) -> U) -> ~[U];
|
||||
pure fn mapi<U>(f: fn(uint, T) -> U) -> ~[U];
|
||||
fn map_r<U>(f: fn(x: &T) -> U) -> ~[U];
|
||||
@ -1650,38 +1568,6 @@ impl<T> &[T]: ImmutableVector<T> {
|
||||
/// Reduce a vector from right to left
|
||||
#[inline]
|
||||
pure fn foldr<U: Copy>(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) }
|
||||
/**
|
||||
* Iterates over a vector
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with
|
||||
* the element's value.
|
||||
*/
|
||||
#[inline]
|
||||
pure fn iter(f: fn(T)) { iter(self, f) }
|
||||
/**
|
||||
* Iterates over a vector's elements and indexes
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with
|
||||
* the element's value and index.
|
||||
*/
|
||||
#[inline]
|
||||
pure fn iteri(f: fn(uint, T)) { iteri(self, f) }
|
||||
/**
|
||||
* Iterates over a vector in reverse
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with
|
||||
* the element's value.
|
||||
*/
|
||||
#[inline]
|
||||
pure fn riter(f: fn(T)) { riter(self, f) }
|
||||
/**
|
||||
* Iterates over a vector's elements and indexes in reverse
|
||||
*
|
||||
* Iterates over vector `v` and, for each element, calls function `f` with
|
||||
* the element's value and index.
|
||||
*/
|
||||
#[inline]
|
||||
pure fn riteri(f: fn(uint, T)) { riteri(self, f) }
|
||||
/// Apply a function to each element of a vector and return the results
|
||||
#[inline]
|
||||
pure fn map<U>(f: fn(T) -> U) -> ~[U] { map(self, f) }
|
||||
@ -2465,55 +2351,57 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iter_empty() {
|
||||
let mut i = 0;
|
||||
iter::<int>(~[], |_v| i += 1);
|
||||
assert i == 0;
|
||||
fn test_each_empty() {
|
||||
for each_ref::<int>(~[]) |_v| {
|
||||
fail; // should never be executed
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iter_nonempty() {
|
||||
let mut i = 0;
|
||||
iter(~[1, 2, 3], |v| i += v);
|
||||
for each_ref(~[1, 2, 3]) |v| {
|
||||
i += *v;
|
||||
}
|
||||
assert i == 6;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iteri() {
|
||||
let mut i = 0;
|
||||
iteri(~[1, 2, 3], |j, v| {
|
||||
for eachi(~[1, 2, 3]) |j, v| {
|
||||
if i == 0 { assert v == 1; }
|
||||
assert j + 1u == v as uint;
|
||||
i += v;
|
||||
});
|
||||
}
|
||||
assert i == 6;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_riter_empty() {
|
||||
let mut i = 0;
|
||||
riter::<int>(~[], |_v| i += 1);
|
||||
assert i == 0;
|
||||
fn test_reach_empty() {
|
||||
for reach::<int>(~[]) |_v| {
|
||||
fail; // should never execute
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_riter_nonempty() {
|
||||
let mut i = 0;
|
||||
riter(~[1, 2, 3], |v| {
|
||||
for reach(~[1, 2, 3]) |v| {
|
||||
if i == 0 { assert v == 3; }
|
||||
i += v
|
||||
});
|
||||
}
|
||||
assert i == 6;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_riteri() {
|
||||
fn test_reachi() {
|
||||
let mut i = 0;
|
||||
riteri(~[0, 1, 2], |j, v| {
|
||||
for reachi(~[0, 1, 2]) |j, v| {
|
||||
if i == 0 { assert v == 2; }
|
||||
assert j == v as uint;
|
||||
i += v;
|
||||
});
|
||||
}
|
||||
assert i == 3;
|
||||
}
|
||||
|
||||
|
@ -642,6 +642,7 @@ mod tests {
|
||||
c.send(());
|
||||
}
|
||||
}
|
||||
|
||||
// Readers try to catch the writer in the act
|
||||
let mut children = ~[];
|
||||
for 5.times {
|
||||
@ -652,8 +653,10 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for children to pass their asserts
|
||||
for vec::each(children) |r| { future::get(&r); }
|
||||
for vec::each_ref(children) |r| { future::get(r); }
|
||||
|
||||
// Wait for writer to finish
|
||||
p.recv();
|
||||
do arc.read |num| { assert *num == 10; }
|
||||
@ -713,8 +716,8 @@ mod tests {
|
||||
assert *state == 42;
|
||||
*state = 31337;
|
||||
// send to other readers
|
||||
for vec::each(reader_convos) |x| {
|
||||
match x {
|
||||
for vec::each_ref(reader_convos) |x| {
|
||||
match *x {
|
||||
(rc, _) => rc.send(()),
|
||||
}
|
||||
}
|
||||
@ -722,8 +725,8 @@ mod tests {
|
||||
let read_mode = arc.downgrade(write_mode);
|
||||
do (&read_mode).read |state| {
|
||||
// complete handshake with other readers
|
||||
for vec::each(reader_convos) |x| {
|
||||
match x {
|
||||
for vec::each_ref(reader_convos) |x| {
|
||||
match *x {
|
||||
(_, rp) => rp.recv(),
|
||||
}
|
||||
}
|
||||
|
@ -292,16 +292,16 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
|
||||
}
|
||||
}
|
||||
let mut name_pos = 0u;
|
||||
for vec::each(names) |nm| {
|
||||
for vec::each_ref(names) |nm| {
|
||||
name_pos += 1u;
|
||||
let optid = match find_opt(opts, nm) {
|
||||
let optid = match find_opt(opts, *nm) {
|
||||
Some(id) => id,
|
||||
None => return Err(UnrecognizedOption(name_str(&nm)))
|
||||
None => return Err(UnrecognizedOption(name_str(nm)))
|
||||
};
|
||||
match opts[optid].hasarg {
|
||||
No => {
|
||||
if !option::is_none::<~str>(i_arg) {
|
||||
return Err(UnexpectedArgument(name_str(&nm)));
|
||||
return Err(UnexpectedArgument(name_str(nm)));
|
||||
}
|
||||
vec::push(vals[optid], Given);
|
||||
}
|
||||
@ -318,7 +318,7 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
|
||||
vec::push(vals[optid],
|
||||
Val(option::get::<~str>(i_arg)));
|
||||
} else if i + 1u == l {
|
||||
return Err(ArgumentMissing(name_str(&nm)));
|
||||
return Err(ArgumentMissing(name_str(nm)));
|
||||
} else { i += 1u; vec::push(vals[optid], Val(args[i])); }
|
||||
}
|
||||
}
|
||||
@ -366,8 +366,8 @@ fn opt_present(+mm: Matches, nm: &str) -> bool {
|
||||
|
||||
/// Returns true if any of several options were matched
|
||||
fn opts_present(+mm: Matches, names: &[~str]) -> bool {
|
||||
for vec::each(names) |nm| {
|
||||
match find_opt(mm.opts, mkname(nm)) {
|
||||
for vec::each_ref(names) |nm| {
|
||||
match find_opt(mm.opts, mkname(*nm)) {
|
||||
Some(_) => return true,
|
||||
None => ()
|
||||
}
|
||||
@ -393,8 +393,8 @@ fn opt_str(+mm: Matches, nm: &str) -> ~str {
|
||||
* option took an argument
|
||||
*/
|
||||
fn opts_str(+mm: Matches, names: &[~str]) -> ~str {
|
||||
for vec::each(names) |nm| {
|
||||
match opt_val(mm, nm) {
|
||||
for vec::each_ref(names) |nm| {
|
||||
match opt_val(mm, *nm) {
|
||||
Val(s) => return s,
|
||||
_ => ()
|
||||
}
|
||||
@ -411,8 +411,8 @@ fn opts_str(+mm: Matches, names: &[~str]) -> ~str {
|
||||
*/
|
||||
fn opt_strs(+mm: Matches, nm: &str) -> ~[~str] {
|
||||
let mut acc: ~[~str] = ~[];
|
||||
for vec::each(opt_vals(mm, nm)) |v| {
|
||||
match v { Val(s) => vec::push(acc, s), _ => () }
|
||||
for vec::each_ref(opt_vals(mm, nm)) |v| {
|
||||
match *v { Val(s) => vec::push(acc, s), _ => () }
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ fn to_writer_pretty(wr: io::Writer, j: Json, indent: uint) {
|
||||
|
||||
fn escape_str(s: &str) -> ~str {
|
||||
let mut escaped = ~"\"";
|
||||
do str::chars_iter(s) |c| {
|
||||
for str::chars_each(s) |c| {
|
||||
match c {
|
||||
'"' => escaped += ~"\\\"",
|
||||
'\\' => escaped += ~"\\\\",
|
||||
@ -834,8 +834,8 @@ mod tests {
|
||||
fn mk_dict(items: &[(~str, Json)]) -> Json {
|
||||
let d = map::str_hash();
|
||||
|
||||
do vec::iter(items) |item| {
|
||||
let (key, value) = copy item;
|
||||
for vec::each_ref(items) |item| {
|
||||
let (key, value) = copy *item;
|
||||
d.insert(key, value);
|
||||
};
|
||||
|
||||
|
@ -435,9 +435,12 @@ fn vec_from_set<T:Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T] {
|
||||
fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>(
|
||||
items: &[(K, V)]) -> HashMap<K, V> {
|
||||
let map = HashMap();
|
||||
do vec::iter(items) |item| {
|
||||
let (key, value) = item;
|
||||
map.insert(key, value);
|
||||
for vec::each_ref(items) |item| {
|
||||
match *item {
|
||||
(key, value) => {
|
||||
map.insert(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
map
|
||||
}
|
||||
|
@ -363,13 +363,13 @@ mod test {
|
||||
let results = result::unwrap(ga_result);
|
||||
log(debug, fmt!("test_get_addr: Number of results for %s: %?",
|
||||
localhost_name, vec::len(results)));
|
||||
for vec::each(results) |r| {
|
||||
let ipv_prefix = match r {
|
||||
for vec::each_ref(results) |r| {
|
||||
let ipv_prefix = match *r {
|
||||
Ipv4(_) => ~"IPv4",
|
||||
Ipv6(_) => ~"IPv6"
|
||||
};
|
||||
log(debug, fmt!("test_get_addr: result %s: '%s'",
|
||||
ipv_prefix, format_addr(&r)));
|
||||
ipv_prefix, format_addr(r)));
|
||||
}
|
||||
// at least one result.. this is going to vary from system
|
||||
// to system, based on stuff like the contents of /etc/hosts
|
||||
|
@ -91,7 +91,7 @@ trait Deserializer {
|
||||
|
||||
fn emit_from_vec<S: Serializer, T>(s: S, v: ~[T], f: fn(T)) {
|
||||
do s.emit_vec(vec::len(v)) {
|
||||
do vec::iteri(v) |i,e| {
|
||||
for vec::eachi(v) |i,e| {
|
||||
do s.emit_vec_elt(i) {
|
||||
f(e)
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ fn sha1() -> Sha1 {
|
||||
|
||||
fn add_input(st: &Sha1State, msg: &[u8]) {
|
||||
assert (!st.computed);
|
||||
for vec::each(msg) |element| {
|
||||
st.msg_block[st.msg_block_idx] = element;
|
||||
for vec::each_ref(msg) |element| {
|
||||
st.msg_block[st.msg_block_idx] = *element;
|
||||
st.msg_block_idx += 1u;
|
||||
st.len_low += 8u32;
|
||||
if st.len_low == 0u32 {
|
||||
@ -240,7 +240,9 @@ fn sha1() -> Sha1 {
|
||||
fn result_str() -> ~str {
|
||||
let rr = mk_result(&self);
|
||||
let mut s = ~"";
|
||||
for vec::each(rr) |b| { s += uint::to_str(b as uint, 16u); }
|
||||
for vec::each_ref(rr) |b| {
|
||||
s += uint::to_str(*b as uint, 16u);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@ -329,7 +331,7 @@ mod tests {
|
||||
// Test that it works when accepting the message all at once
|
||||
|
||||
let sh = sha1::sha1();
|
||||
for vec::each(tests) |t| {
|
||||
for vec::each_ref(tests) |t| {
|
||||
sh.input_str(t.input);
|
||||
let out = sh.result();
|
||||
check_vec_eq(t.output, out);
|
||||
@ -338,7 +340,7 @@ mod tests {
|
||||
|
||||
|
||||
// Test that it works when accepting the message in pieces
|
||||
for vec::each(tests) |t| {
|
||||
for vec::each_ref(tests) |t| {
|
||||
let len = str::len(t.input);
|
||||
let mut left = len;
|
||||
while left > 0u {
|
||||
|
@ -259,8 +259,8 @@ mod test_qsort {
|
||||
let immut_names = vec::from_mut(names);
|
||||
|
||||
let pairs = vec::zip(expected, immut_names);
|
||||
for vec::each(pairs) |p| {
|
||||
let (a, b) = p;
|
||||
for vec::each_ref(pairs) |p| {
|
||||
let (a, b) = *p;
|
||||
debug!("%d %d", a, b);
|
||||
assert (a == b);
|
||||
}
|
||||
|
@ -941,7 +941,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
for vec::each(sibling_convos) |p| {
|
||||
for vec::each_ref(sibling_convos) |p| {
|
||||
let _ = p.recv(); // wait for sibling to get in the mutex
|
||||
}
|
||||
do m2.lock { }
|
||||
@ -950,7 +950,7 @@ mod tests {
|
||||
};
|
||||
assert result.is_err();
|
||||
// child task must have finished by the time try returns
|
||||
for vec::each(p.recv()) |p| { p.recv(); } // wait on all its siblings
|
||||
for vec::each_ref(p.recv()) |p| { p.recv(); } // wait on all its siblings
|
||||
do m.lock_cond |cond| {
|
||||
let woken = cond.broadcast();
|
||||
assert woken == 0;
|
||||
|
@ -39,8 +39,8 @@ fn color_supported() -> bool {
|
||||
~"screen-bce", ~"xterm-256color"];
|
||||
return match os::getenv(~"TERM") {
|
||||
option::Some(env) => {
|
||||
for vec::each(supported_terms) |term| {
|
||||
if term == env { return true; }
|
||||
for vec::each_ref(supported_terms) |term| {
|
||||
if *term == env { return true; }
|
||||
}
|
||||
false
|
||||
}
|
||||
|
@ -226,8 +226,8 @@ fn print_failures(st: ConsoleTestState) {
|
||||
let failures = copy st.failures;
|
||||
let failures = vec::map(failures, |test| test.name);
|
||||
let failures = sort::merge_sort(|x, y| str::le(*x, *y), failures);
|
||||
for vec::each(failures) |name| {
|
||||
st.out.write_line(fmt!(" %s", name));
|
||||
for vec::each_ref(failures) |name| {
|
||||
st.out.write_line(fmt!(" %s", *name));
|
||||
}
|
||||
}
|
||||
|
||||
@ -535,30 +535,34 @@ mod tests {
|
||||
~"test::sort_tests"];
|
||||
let tests =
|
||||
{
|
||||
let testfn = fn~() { };
|
||||
let mut tests = ~[];
|
||||
for vec::each(names) |name| {
|
||||
let test = {name: name, testfn: copy testfn, ignore: false,
|
||||
should_fail: false};
|
||||
tests += ~[test];
|
||||
let testfn = fn~() { };
|
||||
let mut tests = ~[];
|
||||
for vec::each_ref(names) |name| {
|
||||
let test = {name: *name, testfn: copy testfn, ignore: false,
|
||||
should_fail: false};
|
||||
vec::push(tests, test);
|
||||
}
|
||||
tests
|
||||
};
|
||||
let filtered = filter_tests(opts, tests);
|
||||
|
||||
let expected =
|
||||
~[~"int::test_pow", ~"int::test_to_str", ~"sha1::test",
|
||||
~"test::do_not_run_ignored_tests",
|
||||
~"test::filter_for_ignored_option",
|
||||
~"test::first_free_arg_should_be_a_filter",
|
||||
~"test::ignored_tests_result_in_ignored",
|
||||
~"test::parse_ignored_flag",
|
||||
~"test::sort_tests"];
|
||||
|
||||
let pairs = vec::zip(expected, filtered);
|
||||
|
||||
for vec::each_ref(pairs) |p| {
|
||||
match *p {
|
||||
(a, b) => { assert (a == b.name); }
|
||||
}
|
||||
}
|
||||
tests
|
||||
};
|
||||
let filtered = filter_tests(opts, tests);
|
||||
|
||||
let expected =
|
||||
~[~"int::test_pow", ~"int::test_to_str", ~"sha1::test",
|
||||
~"test::do_not_run_ignored_tests",
|
||||
~"test::filter_for_ignored_option",
|
||||
~"test::first_free_arg_should_be_a_filter",
|
||||
~"test::ignored_tests_result_in_ignored",
|
||||
~"test::parse_ignored_flag",
|
||||
~"test::sort_tests"];
|
||||
|
||||
let pairs = vec::zip(expected, filtered);
|
||||
|
||||
for vec::each(pairs) |p| { let (a, b) = copy p; assert (a == b.name); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
[
|
||||
for vec::each_ref([
|
||||
~"Sunday",
|
||||
~"Monday",
|
||||
~"Tuesday",
|
||||
@ -1031,9 +1031,11 @@ mod tests {
|
||||
~"Thursday",
|
||||
~"Friday",
|
||||
~"Saturday"
|
||||
]/_.iter(|day| assert test(day, ~"%A"));
|
||||
]) |day| {
|
||||
assert test(*day, ~"%A");
|
||||
}
|
||||
|
||||
[
|
||||
for vec::each_ref([
|
||||
~"Sun",
|
||||
~"Mon",
|
||||
~"Tue",
|
||||
@ -1041,9 +1043,11 @@ mod tests {
|
||||
~"Thu",
|
||||
~"Fri",
|
||||
~"Sat"
|
||||
]/_.iter(|day| assert test(day, ~"%a"));
|
||||
]) |day| {
|
||||
assert test(*day, ~"%a");
|
||||
}
|
||||
|
||||
[
|
||||
for vec::each_ref([
|
||||
~"January",
|
||||
~"February",
|
||||
~"March",
|
||||
@ -1056,9 +1060,11 @@ mod tests {
|
||||
~"October",
|
||||
~"November",
|
||||
~"December"
|
||||
]/_.iter(|day| assert test(day, ~"%B"));
|
||||
]) |day| {
|
||||
assert test(*day, ~"%B");
|
||||
}
|
||||
|
||||
[
|
||||
for vec::each_ref([
|
||||
~"Jan",
|
||||
~"Feb",
|
||||
~"Mar",
|
||||
@ -1071,7 +1077,9 @@ mod tests {
|
||||
~"Oct",
|
||||
~"Nov",
|
||||
~"Dec"
|
||||
]/_.iter(|day| assert test(day, ~"%b"));
|
||||
]) |day| {
|
||||
assert test(*day, ~"%b");
|
||||
}
|
||||
|
||||
assert test(~"19", ~"%C");
|
||||
assert test(~"Fri Feb 13 23:31:30 2009", ~"%c");
|
||||
|
@ -293,8 +293,10 @@ fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node,
|
||||
}
|
||||
let d_id = ast_util::local_def(id);
|
||||
let p = extend(cx, ident);
|
||||
// only need to handle methods
|
||||
do vec::iter(struct_def.methods) |m| { map_method(d_id, p, m, cx); }
|
||||
// only need to handle methods
|
||||
for vec::each_ref(struct_def.methods) |m| {
|
||||
map_method(d_id, p, *m, cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn map_view_item(vi: @view_item, cx: ctx, _v: vt) {
|
||||
|
@ -429,13 +429,13 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
||||
match vi.node {
|
||||
view_item_use(_, _, id) => vfn(id),
|
||||
view_item_import(vps) | view_item_export(vps) => {
|
||||
do vec::iter(vps) |vp| {
|
||||
match vp.node {
|
||||
view_path_simple(_, _, _, id) => vfn(id),
|
||||
view_path_glob(_, id) => vfn(id),
|
||||
view_path_list(_, _, id) => vfn(id)
|
||||
}
|
||||
}
|
||||
for vec::each_ref(vps) |vp| {
|
||||
match vp.node {
|
||||
view_path_simple(_, _, _, id) => vfn(id),
|
||||
view_path_glob(_, id) => vfn(id),
|
||||
view_path_list(_, _, id) => vfn(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -490,7 +490,9 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
||||
},
|
||||
|
||||
visit_ty_params: fn@(ps: ~[ty_param]) {
|
||||
vec::iter(ps, |p| vfn(p.id))
|
||||
for vec::each_ref(ps) |p| {
|
||||
vfn(p.id);
|
||||
}
|
||||
},
|
||||
|
||||
visit_fn: fn@(fk: visit::fn_kind, d: ast::fn_decl,
|
||||
@ -498,34 +500,34 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> {
|
||||
vfn(id);
|
||||
|
||||
match fk {
|
||||
visit::fk_ctor(_, _, tps, self_id, parent_id) => {
|
||||
vec::iter(tps, |tp| vfn(tp.id));
|
||||
vfn(id);
|
||||
vfn(self_id);
|
||||
vfn(parent_id.node);
|
||||
}
|
||||
visit::fk_dtor(tps, _, self_id, parent_id) => {
|
||||
vec::iter(tps, |tp| vfn(tp.id));
|
||||
vfn(id);
|
||||
vfn(self_id);
|
||||
vfn(parent_id.node);
|
||||
}
|
||||
visit::fk_item_fn(_, tps, _) => {
|
||||
vec::iter(tps, |tp| vfn(tp.id));
|
||||
}
|
||||
visit::fk_method(_, tps, m) => {
|
||||
vfn(m.self_id);
|
||||
vec::iter(tps, |tp| vfn(tp.id));
|
||||
}
|
||||
visit::fk_anon(_, capture_clause)
|
||||
| visit::fk_fn_block(capture_clause) => {
|
||||
for vec::each(*capture_clause) |clause| {
|
||||
vfn(clause.id);
|
||||
visit::fk_ctor(_, _, tps, self_id, parent_id) => {
|
||||
for vec::each_ref(tps) |tp| { vfn(tp.id); }
|
||||
vfn(id);
|
||||
vfn(self_id);
|
||||
vfn(parent_id.node);
|
||||
}
|
||||
visit::fk_dtor(tps, _, self_id, parent_id) => {
|
||||
for vec::each_ref(tps) |tp| { vfn(tp.id); }
|
||||
vfn(id);
|
||||
vfn(self_id);
|
||||
vfn(parent_id.node);
|
||||
}
|
||||
visit::fk_item_fn(_, tps, _) => {
|
||||
for vec::each_ref(tps) |tp| { vfn(tp.id); }
|
||||
}
|
||||
visit::fk_method(_, tps, m) => {
|
||||
vfn(m.self_id);
|
||||
for vec::each_ref(tps) |tp| { vfn(tp.id); }
|
||||
}
|
||||
visit::fk_anon(_, capture_clause) |
|
||||
visit::fk_fn_block(capture_clause) => {
|
||||
for vec::each_ref(*capture_clause) |clause| {
|
||||
vfn(clause.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
do vec::iter(d.inputs) |arg| {
|
||||
for vec::each_ref(d.inputs) |arg| {
|
||||
vfn(arg.id)
|
||||
}
|
||||
},
|
||||
|
@ -228,7 +228,7 @@ fn finish<T: qq_helper>
|
||||
let mut state = active;
|
||||
let mut i = 0u, j = 0u;
|
||||
let g_len = cx.gather.len();
|
||||
do str::chars_iter(*str) |ch| {
|
||||
for str::chars_each(*str) |ch| {
|
||||
if (j < g_len && i == cx.gather[j].lo) {
|
||||
assert ch == '$';
|
||||
let repl = fmt!("$%u ", j);
|
||||
|
@ -208,10 +208,10 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr {
|
||||
pure fn follow(m: arb_depth<matchable>, idx_path: &[uint]) ->
|
||||
arb_depth<matchable> {
|
||||
let mut res: arb_depth<matchable> = m;
|
||||
for vec::each(idx_path) |idx| {
|
||||
for vec::each_ref(idx_path) |idx| {
|
||||
res = match res {
|
||||
leaf(_) => return res,/* end of the line */
|
||||
seq(new_ms, _) => new_ms[idx]
|
||||
seq(new_ms, _) => new_ms[*idx]
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
@ -1672,9 +1672,9 @@ fn print_arg_mode(s: ps, m: ast::mode) {
|
||||
fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) {
|
||||
if vec::len(*bounds) > 0u {
|
||||
word(s.s, ~":");
|
||||
for vec::each(*bounds) |bound| {
|
||||
for vec::each_ref(*bounds) |bound| {
|
||||
nbsp(s);
|
||||
match bound {
|
||||
match *bound {
|
||||
ast::bound_copy => word(s.s, ~"Copy"),
|
||||
ast::bound_send => word(s.s, ~"Send"),
|
||||
ast::bound_const => word(s.s, ~"Const"),
|
||||
|
@ -262,8 +262,8 @@ fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) {
|
||||
}
|
||||
|
||||
fn visit_ty_param_bounds<E>(bounds: @~[ty_param_bound], e: E, v: vt<E>) {
|
||||
for vec::each(*bounds) |bound| {
|
||||
match bound {
|
||||
for vec::each_ref(*bounds) |bound| {
|
||||
match *bound {
|
||||
bound_trait(t) => v.visit_ty(t, e, v),
|
||||
bound_copy | bound_send | bound_const | bound_owned => ()
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str {
|
||||
// gas doesn't!
|
||||
fn sanitize(s: ~str) -> ~str {
|
||||
let mut result = ~"";
|
||||
do str::chars_iter(s) |c| {
|
||||
for str::chars_each(s) |c| {
|
||||
match c {
|
||||
'@' => result += ~"_sbox_",
|
||||
'~' => result += ~"_ubox_",
|
||||
|
@ -99,8 +99,8 @@ fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> ~str {
|
||||
fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
|
||||
data: crate_metadata) {
|
||||
p(cstore).metas.insert(cnum, data);
|
||||
do vec::iter(decoder::get_crate_module_paths(cstore.intr, data)) |dp| {
|
||||
let (did, path) = dp;
|
||||
for vec::each_ref(decoder::get_crate_module_paths(cstore.intr, data)) |dp| {
|
||||
let (did, path) = *dp;
|
||||
let d = {crate: cnum, node: did.node};
|
||||
p(cstore).mod_path_map.insert(d, @path);
|
||||
}
|
||||
|
@ -267,7 +267,9 @@ fn encode_path(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: ast_map::path,
|
||||
|
||||
do ebml_w.wr_tag(tag_path) {
|
||||
ebml_w.wr_tagged_u32(tag_path_len, (vec::len(path) + 1u) as u32);
|
||||
do vec::iter(path) |pe| { encode_path_elt(ecx, ebml_w, pe); }
|
||||
for vec::each_ref(path) |pe| {
|
||||
encode_path_elt(ecx, ebml_w, *pe);
|
||||
}
|
||||
encode_path_elt(ecx, ebml_w, name);
|
||||
}
|
||||
}
|
||||
@ -737,7 +739,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
encode_name(ecx, ebml_w, item.ident);
|
||||
encode_attributes(ebml_w, item.attrs);
|
||||
let mut i = 0u;
|
||||
for vec::each(*ty::trait_methods(tcx, local_def(item.id))) |mty| {
|
||||
for vec::each_ref(*ty::trait_methods(tcx, local_def(item.id))) |mty| {
|
||||
match ms[i] {
|
||||
required(ty_m) => {
|
||||
ebml_w.start_tag(tag_item_trait_method);
|
||||
@ -767,8 +769,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
|
||||
// method info, we output static methods with type signatures as
|
||||
// written. Here, we output the *real* type signatures. I feel like
|
||||
// maybe we should only ever handle the real type signatures.
|
||||
for vec::each(ms) |m| {
|
||||
let ty_m = ast_util::trait_method_to_ty_method(m);
|
||||
for vec::each_ref(ms) |m| {
|
||||
let ty_m = ast_util::trait_method_to_ty_method(*m);
|
||||
if ty_m.self_ty.node != ast::sty_static { loop; }
|
||||
|
||||
vec::push(*index, {val: ty_m.id, pos: ebml_w.writer.tell()});
|
||||
@ -888,7 +890,7 @@ fn encode_index<T>(ebml_w: ebml::Writer, buckets: ~[@~[entry<T>]],
|
||||
for buckets.each |bucket| {
|
||||
vec::push(bucket_locs, ebml_w.writer.tell());
|
||||
ebml_w.start_tag(tag_index_buckets_bucket);
|
||||
for vec::each(*bucket) |elt| {
|
||||
for vec::each_ref(*bucket) |elt| {
|
||||
ebml_w.start_tag(tag_index_buckets_bucket_elt);
|
||||
assert elt.pos < 0xffff_ffff;
|
||||
writer.write_be_u32(elt.pos as u32);
|
||||
|
@ -365,8 +365,8 @@ fn enc_ty_fn(w: io::Writer, cx: @ctxt, ft: ty::FnTy) {
|
||||
}
|
||||
|
||||
fn enc_bounds(w: io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
|
||||
for vec::each(*bs) |bound| {
|
||||
match bound {
|
||||
for vec::each_ref(*bs) |bound| {
|
||||
match *bound {
|
||||
ty::bound_send => w.write_char('S'),
|
||||
ty::bound_copy => w.write_char('C'),
|
||||
ty::bound_const => w.write_char('K'),
|
||||
|
@ -108,16 +108,16 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
||||
implicit_mode = cap_copy;
|
||||
}
|
||||
|
||||
do vec::iter(*freevars) |fvar| {
|
||||
for vec::each_ref(*freevars) |fvar| {
|
||||
let fvar_def_id = ast_util::def_id_of_def(fvar.def).node;
|
||||
match cap_map.find(fvar_def_id) {
|
||||
option::Some(_) => { /* was explicitly named, do nothing */ }
|
||||
option::None => {
|
||||
cap_map.insert(fvar_def_id, {def:fvar.def,
|
||||
span: fvar.span,
|
||||
cap_item: None,
|
||||
mode:implicit_mode});
|
||||
}
|
||||
option::Some(_) => { /* was explicitly named, do nothing */ }
|
||||
option::None => {
|
||||
cap_map.insert(fvar_def_id, {def:fvar.def,
|
||||
span: fvar.span,
|
||||
cap_item: None,
|
||||
mode:implicit_mode});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
|
||||
}
|
||||
let variants = ty::enum_variants(tcx, eid);
|
||||
if found.len() != (*variants).len() {
|
||||
for vec::each(*variants) |v| {
|
||||
for vec::each_ref(*variants) |v| {
|
||||
if !found.contains(variant(v.id)) {
|
||||
return Some(variant(v.id));
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
||||
|
||||
// Iterate over any free variables that may not have appeared in the
|
||||
// capture list. Ensure that they too are of the appropriate kind.
|
||||
for vec::each(*freevars::get_freevars(cx.tcx, fn_id)) |fv| {
|
||||
for vec::each_ref(*freevars::get_freevars(cx.tcx, fn_id)) |fv| {
|
||||
let id = ast_util::def_id_of_def(fv.def).node;
|
||||
|
||||
// skip over free variables that appear in the cap clause
|
||||
@ -211,7 +211,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
||||
};
|
||||
|
||||
let ty = ty::node_id_to_type(cx.tcx, id);
|
||||
chk(cx, fn_id, Some(fv), is_move, ty, fv.span);
|
||||
chk(cx, fn_id, Some(*fv), is_move, ty, fv.span);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +227,8 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) {
|
||||
}
|
||||
|
||||
fn check_arm(a: arm, cx: ctx, v: visit::vt<ctx>) {
|
||||
for vec::each(a.pats) |p| {
|
||||
do pat_util::pat_bindings(cx.tcx.def_map, p) |mode, id, span, _path| {
|
||||
for vec::each_ref(a.pats) |p| {
|
||||
do pat_util::pat_bindings(cx.tcx.def_map, *p) |mode, id, span, _path| {
|
||||
if mode == bind_by_value {
|
||||
let t = ty::node_id_to_type(cx.tcx, id);
|
||||
let reason = "consider binding with `ref` or `move` instead";
|
||||
|
@ -451,7 +451,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
||||
fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
|
||||
decl: ast::fn_decl) {
|
||||
let tys = vec::map(decl.inputs, |a| a.ty );
|
||||
for vec::each(vec::append_one(tys, decl.output)) |ty| {
|
||||
for vec::each_ref(vec::append_one(tys, decl.output)) |ty| {
|
||||
match ty.node {
|
||||
ast::ty_path(_, id) => {
|
||||
match cx.def_map.get(id) {
|
||||
|
@ -4343,11 +4343,11 @@ impl Resolver {
|
||||
let rib = self.type_ribs.get_elt(i);
|
||||
match rib.kind {
|
||||
MethodRibKind(node_id, _) =>
|
||||
for vec::each(self.crate.node.module.items) |item| {
|
||||
for vec::each_ref(self.crate.node.module.items) |item| {
|
||||
if item.id == node_id {
|
||||
match item.node {
|
||||
item_class(class_def, _) => {
|
||||
for vec::each(class_def.fields) |field| {
|
||||
for vec::each_ref(class_def.fields) |field| {
|
||||
match field.node.kind {
|
||||
syntax::ast::unnamed_field
|
||||
=> {},
|
||||
@ -4360,7 +4360,7 @@ impl Resolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
for vec::each(class_def.methods) |method| {
|
||||
for vec::each_ref(class_def.methods) |method| {
|
||||
if str::eq_slice(self.session.str_of(method.ident),
|
||||
name) {
|
||||
return true
|
||||
|
@ -124,13 +124,13 @@ fn macros() { include!("macros.rs"); } // FIXME(#3114): Macro import/export.
|
||||
|
||||
// An option identifying a branch (either a literal, a enum variant or a
|
||||
// range)
|
||||
enum opt {
|
||||
enum Opt {
|
||||
lit(@ast::expr),
|
||||
var(/* disr val */int, /* variant dids */{enm: def_id, var: def_id}),
|
||||
range(@ast::expr, @ast::expr)
|
||||
}
|
||||
fn opt_eq(tcx: ty::ctxt, a: opt, b: opt) -> bool {
|
||||
match (a, b) {
|
||||
fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
|
||||
match (*a, *b) {
|
||||
(lit(a), lit(b)) => const_eval::compare_lit_exprs(tcx, a, b) == 0,
|
||||
(range(a1, a2), range(b1, b2)) => {
|
||||
const_eval::compare_lit_exprs(tcx, a1, b1) == 0 &&
|
||||
@ -145,11 +145,11 @@ enum opt_result {
|
||||
single_result(Result),
|
||||
range_result(Result, Result),
|
||||
}
|
||||
fn trans_opt(bcx: block, o: opt) -> opt_result {
|
||||
fn trans_opt(bcx: block, o: &Opt) -> opt_result {
|
||||
let _icx = bcx.insn_ctxt("alt::trans_opt");
|
||||
let ccx = bcx.ccx();
|
||||
let mut bcx = bcx;
|
||||
match o {
|
||||
match *o {
|
||||
lit(lit_expr) => {
|
||||
let datumblock = expr::trans_to_datum(bcx, lit_expr);
|
||||
return single_result(datumblock.to_result());
|
||||
@ -164,10 +164,10 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
|
||||
}
|
||||
}
|
||||
|
||||
fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt {
|
||||
fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> Opt {
|
||||
let vdef = ast_util::variant_def_ids(tcx.def_map.get(pat_id));
|
||||
let variants = ty::enum_variants(tcx, vdef.enm);
|
||||
for vec::each(*variants) |v| {
|
||||
for vec::each_ref(*variants) |v| {
|
||||
if vdef.var == v.id { return var(v.disr_val, vdef); }
|
||||
}
|
||||
core::unreachable();
|
||||
@ -221,7 +221,7 @@ fn matches_to_str(bcx: block, m: &[@Match]) -> ~str {
|
||||
}
|
||||
|
||||
fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
match br.pats[col].node {
|
||||
ast::pat_ident(_, _, Some(_)) => return true,
|
||||
_ => ()
|
||||
@ -285,7 +285,7 @@ fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
let _indenter = indenter();
|
||||
|
||||
let mut result = ~[];
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
match e(br.pats[col]) {
|
||||
Some(sub) => {
|
||||
let pats =
|
||||
@ -337,7 +337,7 @@ fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
}
|
||||
}
|
||||
|
||||
fn enter_opt(bcx: block, m: &[@Match/&r], opt: opt, col: uint,
|
||||
fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
|
||||
variant_size: uint, val: ValueRef)
|
||||
-> ~[@Match/&r]
|
||||
{
|
||||
@ -353,7 +353,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: opt, col: uint,
|
||||
do enter_match(bcx, tcx.def_map, m, col, val) |p| {
|
||||
match p.node {
|
||||
ast::pat_enum(_, subpats) => {
|
||||
if opt_eq(tcx, variant_opt(tcx, p.id), opt) {
|
||||
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
|
||||
Some(option::get_default(subpats,
|
||||
vec::from_elem(variant_size,
|
||||
dummy)))
|
||||
@ -362,17 +362,17 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: opt, col: uint,
|
||||
}
|
||||
}
|
||||
ast::pat_ident(_, _, None) if pat_is_variant(tcx.def_map, p) => {
|
||||
if opt_eq(tcx, variant_opt(tcx, p.id), opt) {
|
||||
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
|
||||
Some(~[])
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
ast::pat_lit(l) => {
|
||||
if opt_eq(tcx, lit(l), opt) { Some(~[]) } else { None }
|
||||
if opt_eq(tcx, &lit(l), opt) { Some(~[]) } else { None }
|
||||
}
|
||||
ast::pat_range(l1, l2) => {
|
||||
if opt_eq(tcx, range(l1, l2), opt) { Some(~[]) } else { None }
|
||||
if opt_eq(tcx, &range(l1, l2), opt) { Some(~[]) } else { None }
|
||||
}
|
||||
_ => {
|
||||
assert_is_binding_or_wild(bcx, p);
|
||||
@ -396,8 +396,8 @@ fn enter_rec_or_struct(bcx: block, dm: DefMap, m: &[@Match/&r], col: uint,
|
||||
match p.node {
|
||||
ast::pat_rec(fpats, _) | ast::pat_struct(_, fpats, _) => {
|
||||
let mut pats = ~[];
|
||||
for vec::each(fields) |fname| {
|
||||
match fpats.find(|p| p.ident == fname) {
|
||||
for vec::each_ref(fields) |fname| {
|
||||
match fpats.find(|p| p.ident == *fname) {
|
||||
None => vec::push(pats, dummy),
|
||||
Some(pat) => vec::push(pats, pat.pat)
|
||||
}
|
||||
@ -487,14 +487,14 @@ fn enter_uniq(bcx: block, dm: DefMap, m: &[@Match/&r],
|
||||
}
|
||||
}
|
||||
|
||||
fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[opt] {
|
||||
fn add_to_set(tcx: ty::ctxt, set: &DVec<opt>, val: opt) {
|
||||
if set.any(|l| opt_eq(tcx, l, val)) {return;}
|
||||
fn get_options(ccx: @crate_ctxt, m: &[@Match], col: uint) -> ~[Opt] {
|
||||
fn add_to_set(tcx: ty::ctxt, set: &DVec<Opt>, val: Opt) {
|
||||
if set.any(|l| opt_eq(tcx, &l, &val)) {return;}
|
||||
set.push(val);
|
||||
}
|
||||
|
||||
let found = DVec();
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
let cur = br.pats[col];
|
||||
if pat_is_variant(ccx.tcx.def_map, cur) {
|
||||
add_to_set(ccx.tcx, &found, variant_opt(ccx.tcx, cur.id));
|
||||
@ -544,7 +544,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
|
||||
|
||||
fn collect_record_or_struct_fields(m: &[@Match], col: uint) -> ~[ast::ident] {
|
||||
let mut fields: ~[ast::ident] = ~[];
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
match br.pats[col].node {
|
||||
ast::pat_rec(fs, _) => extend(&mut fields, fs),
|
||||
ast::pat_struct(_, fs, _) => extend(&mut fields, fs),
|
||||
@ -566,7 +566,7 @@ fn collect_record_or_struct_fields(m: &[@Match], col: uint) -> ~[ast::ident] {
|
||||
fn root_pats_as_necessary(bcx: block, m: &[@Match],
|
||||
col: uint, val: ValueRef)
|
||||
{
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
let pat_id = br.pats[col].id;
|
||||
|
||||
match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) {
|
||||
@ -586,7 +586,7 @@ fn root_pats_as_necessary(bcx: block, m: &[@Match],
|
||||
}
|
||||
|
||||
fn any_box_pat(m: &[@Match], col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
match br.pats[col].node {
|
||||
ast::pat_box(_) => return true,
|
||||
_ => ()
|
||||
@ -596,7 +596,7 @@ fn any_box_pat(m: &[@Match], col: uint) -> bool {
|
||||
}
|
||||
|
||||
fn any_uniq_pat(m: &[@Match], col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
match br.pats[col].node {
|
||||
ast::pat_uniq(_) => return true,
|
||||
_ => ()
|
||||
@ -606,7 +606,7 @@ fn any_uniq_pat(m: &[@Match], col: uint) -> bool {
|
||||
}
|
||||
|
||||
fn any_tup_pat(m: &[@Match], col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
match br.pats[col].node {
|
||||
ast::pat_tup(_) => return true,
|
||||
_ => ()
|
||||
@ -626,14 +626,16 @@ fn pick_col(m: &[@Match]) -> uint {
|
||||
}
|
||||
}
|
||||
let scores = vec::to_mut(vec::from_elem(m[0].pats.len(), 0u));
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
let mut i = 0u;
|
||||
for vec::each(br.pats) |p| { scores[i] += score(p); i += 1u; }
|
||||
for vec::each_ref(br.pats) |p| { scores[i] += score(*p); i += 1u; }
|
||||
}
|
||||
let mut max_score = 0u;
|
||||
let mut best_col = 0u;
|
||||
let mut i = 0u;
|
||||
for vec::each(scores) |score| {
|
||||
for vec::each_ref(scores) |score| {
|
||||
let score = *score;
|
||||
|
||||
// Irrefutable columns always go first, they'd only be duplicated in
|
||||
// the branches.
|
||||
if score == 0u { return i; }
|
||||
@ -871,7 +873,7 @@ fn compile_submatch(bcx: block,
|
||||
vec::view(vals, col + 1u, vals.len()));
|
||||
let ccx = bcx.fcx.ccx;
|
||||
let mut pat_id = 0;
|
||||
for vec::each(m) |br| {
|
||||
for vec::each_ref(m) |br| {
|
||||
// Find a real id (we're adding placeholder wildcard patterns, but
|
||||
// each column is guaranteed to have at least one real pattern)
|
||||
if pat_id == 0 { pat_id = br.pats[col].id; }
|
||||
@ -958,8 +960,8 @@ fn compile_submatch(bcx: block,
|
||||
}
|
||||
}
|
||||
}
|
||||
for vec::each(opts) |o| {
|
||||
match o {
|
||||
for vec::each_ref(opts) |o| {
|
||||
match *o {
|
||||
range(_, _) => { kind = compare; break }
|
||||
_ => ()
|
||||
}
|
||||
@ -980,7 +982,7 @@ fn compile_submatch(bcx: block,
|
||||
let mut i = 0u;
|
||||
|
||||
// Compile subtrees for each option
|
||||
for vec::each(opts) |opt| {
|
||||
for vec::each_ref(opts) |opt| {
|
||||
i += 1u;
|
||||
let mut opt_cx = else_cx;
|
||||
if !exhaustive || i < len {
|
||||
@ -1037,7 +1039,7 @@ fn compile_submatch(bcx: block,
|
||||
|
||||
let mut size = 0u;
|
||||
let mut unpacked = ~[];
|
||||
match opt {
|
||||
match *opt {
|
||||
var(_, vdef) => {
|
||||
let args = extract_variant_args(opt_cx, pat_id, vdef, val);
|
||||
size = args.vals.len();
|
||||
@ -1128,8 +1130,8 @@ fn trans_alt_inner(scope_cx: block,
|
||||
arm: arm,
|
||||
bindings_map: bindings_map};
|
||||
vec::push(arm_datas, arm_data);
|
||||
for vec::each(arm.pats) |p| {
|
||||
vec::push(matches, @Match {pats: ~[p], data: arm_data});
|
||||
for vec::each_ref(arm.pats) |p| {
|
||||
vec::push(matches, @Match {pats: ~[*p], data: arm_data});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1224,7 +1226,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
||||
let tcx = bcx.tcx();
|
||||
let pat_ty = node_id_type(bcx, pat.id);
|
||||
do expr::with_field_tys(tcx, pat_ty) |_has_dtor, field_tys| {
|
||||
for vec::each(fields) |f| {
|
||||
for vec::each_ref(fields) |f| {
|
||||
let ix = ty::field_idx_strict(tcx, f.ident, field_tys);
|
||||
let fldptr = GEPi(bcx, val, struct_field(ix));
|
||||
bcx = bind_irrefutable_pat(bcx, f.pat, fldptr, make_copy);
|
||||
|
@ -160,11 +160,7 @@ fn trans_foreign_call(cx: block, externs: HashMap<~str, ValueRef>,
|
||||
let n = args.len() as int;
|
||||
let llforeign: ValueRef =
|
||||
get_simple_extern_fn(cx, externs, llmod, name, n);
|
||||
let mut call_args: ~[ValueRef] = ~[];
|
||||
for vec::each(args) |a| {
|
||||
vec::push(call_args, a);
|
||||
}
|
||||
return Call(cx, llforeign, call_args);
|
||||
return Call(cx, llforeign, args);
|
||||
}
|
||||
|
||||
fn umax(cx: block, a: ValueRef, b: ValueRef) -> ValueRef {
|
||||
@ -532,7 +528,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
||||
ty::ty_fn(ref fn_ty) => {
|
||||
let mut j = 0u;
|
||||
let v_id = variant.id;
|
||||
for vec::each(fn_ty.sig.inputs) |a| {
|
||||
for vec::each_ref(fn_ty.sig.inputs) |a| {
|
||||
let llfldp_a = GEP_enum(cx, a_tup, tid, v_id, tps, j);
|
||||
let ty_subst = ty::subst_tps(ccx.tcx, tps, a.ty);
|
||||
cx = f(cx, llfldp_a, ty_subst);
|
||||
@ -592,14 +588,14 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
||||
Unreachable(unr_cx);
|
||||
let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants);
|
||||
let next_cx = sub_block(cx, ~"enum-iter-next");
|
||||
for vec::each(*variants) |variant| {
|
||||
for vec::each_ref(*variants) |variant| {
|
||||
let variant_cx =
|
||||
sub_block(cx,
|
||||
~"enum-iter-variant-" +
|
||||
int::to_str(variant.disr_val, 10u));
|
||||
AddCase(llswitch, C_int(ccx, variant.disr_val), variant_cx.llbb);
|
||||
let variant_cx =
|
||||
iter_variant(variant_cx, llunion_a_ptr, variant,
|
||||
iter_variant(variant_cx, llunion_a_ptr, *variant,
|
||||
substs.tps, tid, f);
|
||||
Br(variant_cx, next_cx.llbb);
|
||||
}
|
||||
@ -747,8 +743,8 @@ fn need_invoke(bcx: block) -> bool {
|
||||
loop {
|
||||
match cur.kind {
|
||||
block_scope(inf) => {
|
||||
for vec::each(inf.cleanups) |cleanup| {
|
||||
match cleanup {
|
||||
for vec::each_ref(inf.cleanups) |cleanup| {
|
||||
match *cleanup {
|
||||
clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => {
|
||||
if cleanup_type == normal_exit_and_unwind {
|
||||
return true;
|
||||
@ -1019,10 +1015,10 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block {
|
||||
ast::stmt_decl(d, _) => {
|
||||
match d.node {
|
||||
ast::decl_local(locals) => {
|
||||
for vec::each(locals) |local| {
|
||||
bcx = init_local(bcx, local);
|
||||
for vec::each_ref(locals) |local| {
|
||||
bcx = init_local(bcx, *local);
|
||||
if cx.sess().opts.extra_debuginfo {
|
||||
debuginfo::create_local_var(bcx, local);
|
||||
debuginfo::create_local_var(bcx, *local);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1118,7 +1114,7 @@ fn trans_block_cleanups_(bcx: block,
|
||||
bcx.ccx().sess.opts.debugging_opts & session::no_landing_pads != 0;
|
||||
if bcx.unreachable && !no_lpads { return bcx; }
|
||||
let mut bcx = bcx;
|
||||
do vec::riter(cleanups) |cu| {
|
||||
for vec::reach(cleanups) |cu| {
|
||||
match cu {
|
||||
clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => {
|
||||
// Some types don't need to be cleaned up during
|
||||
@ -1230,12 +1226,14 @@ fn with_scope_datumblock(bcx: block, opt_node_info: Option<node_info>,
|
||||
}
|
||||
|
||||
fn block_locals(b: ast::blk, it: fn(@ast::local)) {
|
||||
for vec::each(b.node.stmts) |s| {
|
||||
for vec::each_ref(b.node.stmts) |s| {
|
||||
match s.node {
|
||||
ast::stmt_decl(d, _) => {
|
||||
match d.node {
|
||||
ast::decl_local(locals) => {
|
||||
for vec::each(locals) |local| { it(local); }
|
||||
for vec::each_ref(locals) |local| {
|
||||
it(*local);
|
||||
}
|
||||
}
|
||||
_ => {/* fall through */ }
|
||||
}
|
||||
@ -1464,7 +1462,7 @@ fn create_llargs_for_fn_args(cx: fn_ctxt,
|
||||
|
||||
// Populate the llargs field of the function context with the ValueRefs
|
||||
// that we get from llvm::LLVMGetParam for each argument.
|
||||
for vec::each(args) |arg| {
|
||||
for vec::each_ref(args) |arg| {
|
||||
let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
|
||||
assert (llarg as int != 0);
|
||||
// Note that this uses local_mem even for things passed by value.
|
||||
@ -1499,7 +1497,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg],
|
||||
_ => {}
|
||||
}
|
||||
|
||||
for vec::each(arg_tys) |arg| {
|
||||
for vec::each_ref(arg_tys) |arg| {
|
||||
let id = args[arg_n].id;
|
||||
let argval = match fcx.llargs.get(id) {
|
||||
local_mem(v) => v,
|
||||
@ -1782,14 +1780,14 @@ fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
|
||||
id: ast::node_id, tps: ~[ast::ty_param], degen: bool,
|
||||
path: @ast_map::path, vi: @~[ty::variant_info],
|
||||
i: &mut uint) {
|
||||
for vec::each(enum_definition.variants) |variant| {
|
||||
for vec::each_ref(enum_definition.variants) |variant| {
|
||||
let disr_val = vi[*i].disr_val;
|
||||
*i += 1;
|
||||
|
||||
match variant.node.kind {
|
||||
ast::tuple_variant_kind(args) if args.len() > 0 => {
|
||||
let llfn = get_item_val(ccx, variant.node.id);
|
||||
trans_enum_variant(ccx, id, variant, args, disr_val,
|
||||
trans_enum_variant(ccx, id, *variant, args, disr_val,
|
||||
degen, None, llfn);
|
||||
}
|
||||
ast::tuple_variant_kind(_) => {
|
||||
@ -1829,7 +1827,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
|
||||
vec::append(*path, ~[path_name(item.ident)]),
|
||||
decl, body, llfndecl, no_self, None, item.id);
|
||||
} else {
|
||||
for vec::each(body.node.stmts) |stmt| {
|
||||
for vec::each_ref(body.node.stmts) |stmt| {
|
||||
match stmt.node {
|
||||
ast::stmt_decl(@{node: ast::decl_item(i), _}, _) => {
|
||||
trans_item(ccx, *i);
|
||||
@ -1910,7 +1908,9 @@ fn trans_trait(ccx: @crate_ctxt, tps: ~[ast::ty_param],
|
||||
// and control visibility.
|
||||
fn trans_mod(ccx: @crate_ctxt, m: ast::_mod) {
|
||||
let _icx = ccx.insn_ctxt("trans_mod");
|
||||
for vec::each(m.items) |item| { trans_item(ccx, *item); }
|
||||
for vec::each_ref(m.items) |item| {
|
||||
trans_item(ccx, **item);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_pair_fn_ty(llpairty: TypeRef) -> TypeRef {
|
||||
@ -2236,7 +2236,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
|
||||
node: it.id});
|
||||
let mut i = 0;
|
||||
let path = item_path(ccx, it);
|
||||
for vec::each(enum_definition.variants) |variant| {
|
||||
for vec::each_ref(enum_definition.variants) |variant| {
|
||||
let p = vec::append(path, ~[path_name(variant.node.name),
|
||||
path_name(special_idents::descrim)]);
|
||||
let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
|
||||
@ -2352,21 +2352,21 @@ fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) {
|
||||
fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||
visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{
|
||||
visit_item: |item| match item.node {
|
||||
ast::item_fn(*) => {
|
||||
let attr_metas = attr::attr_metas(
|
||||
attr::find_attrs_by_name(item.attrs, ~"rt"));
|
||||
do vec::iter(attr_metas) |attr_meta| {
|
||||
match attr::get_meta_item_list(attr_meta) {
|
||||
Some(list) => {
|
||||
let name = attr::get_meta_item_name(vec::head(list));
|
||||
push_rtcall(ccx, name, {crate: ast::local_crate,
|
||||
node: item.id});
|
||||
}
|
||||
None => ()
|
||||
ast::item_fn(*) => {
|
||||
let attr_metas = attr::attr_metas(
|
||||
attr::find_attrs_by_name(item.attrs, ~"rt"));
|
||||
for vec::each_ref(attr_metas) |attr_meta| {
|
||||
match attr::get_meta_item_list(*attr_meta) {
|
||||
Some(list) => {
|
||||
let name = attr::get_meta_item_name(vec::head(list));
|
||||
push_rtcall(ccx, name, {crate: ast::local_crate,
|
||||
node: item.id});
|
||||
}
|
||||
None => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
_ => ()
|
||||
},
|
||||
..*visit::default_simple_visitor()
|
||||
}));
|
||||
@ -2412,9 +2412,9 @@ fn gather_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||
// for an rtcall.
|
||||
let expected_rtcalls =
|
||||
~[~"exchange_free", ~"exchange_malloc", ~"fail_", ~"free", ~"malloc"];
|
||||
for vec::each(expected_rtcalls) |name| {
|
||||
if !ccx.rtcalls.contains_key(name) {
|
||||
fail fmt!("no definition for runtime call %s", name);
|
||||
for vec::each_ref(expected_rtcalls) |name| {
|
||||
if !ccx.rtcalls.contains_key(*name) {
|
||||
fail fmt!("no definition for runtime call %s", *name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +435,7 @@ fn GEP(cx: block, Pointer: ValueRef, Indices: ~[ValueRef]) -> ValueRef {
|
||||
// XXX: Use a small-vector optimization to avoid allocations here.
|
||||
fn GEPi(cx: block, base: ValueRef, ixs: &[uint]) -> ValueRef {
|
||||
let mut v: ~[ValueRef] = ~[];
|
||||
for vec::each(ixs) |i| { vec::push(v, C_i32(i as i32)); }
|
||||
for vec::each_ref(ixs) |i| { vec::push(v, C_i32(*i as i32)); }
|
||||
count_insn(cx, "gepi");
|
||||
return InBoundsGEP(cx, base, v);
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
|
||||
match args {
|
||||
ArgExprs(arg_exprs) => {
|
||||
let last = arg_exprs.len() - 1u;
|
||||
do vec::iteri(arg_exprs) |i, arg_expr| {
|
||||
for vec::eachi(arg_exprs) |i, arg_expr| {
|
||||
let arg_val = unpack_result!(bcx, {
|
||||
trans_arg_expr(bcx, arg_tys[i], arg_expr, &mut temp_cleanups,
|
||||
if i == last { ret_flag } else { None })
|
||||
@ -466,8 +466,8 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
|
||||
// now that all arguments have been successfully built, we can revoke any
|
||||
// temporary cleanups, as they are only needed if argument construction
|
||||
// should fail (for example, cleanup of copy mode args).
|
||||
do vec::iter(temp_cleanups) |c| {
|
||||
revoke_clean(bcx, c)
|
||||
for vec::each_ref(temp_cleanups) |c| {
|
||||
revoke_clean(bcx, *c)
|
||||
}
|
||||
|
||||
return {bcx: bcx, args: llargs, retslot: llretslot};
|
||||
|
@ -209,7 +209,7 @@ fn store_environment(bcx: block,
|
||||
|
||||
// Copy expr values into boxed bindings.
|
||||
let mut bcx = bcx;
|
||||
do vec::iteri(bound_values) |i, bv| {
|
||||
for vec::eachi(bound_values) |i, bv| {
|
||||
debug!("Copy %s into closure", bv.to_str(ccx));
|
||||
|
||||
if !ccx.sess.no_asm_comments() {
|
||||
@ -232,7 +232,9 @@ fn store_environment(bcx: block,
|
||||
}
|
||||
|
||||
}
|
||||
for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); }
|
||||
for vec::each_ref(temp_cleanups) |cleanup| {
|
||||
revoke_clean(bcx, *cleanup);
|
||||
}
|
||||
|
||||
return {llbox: llbox, cdata_ty: cdata_ty, bcx: bcx};
|
||||
}
|
||||
@ -251,8 +253,8 @@ fn build_closure(bcx0: block,
|
||||
|
||||
// Package up the captured upvars
|
||||
let mut env_vals = ~[];
|
||||
do vec::iter(cap_vars) |cap_var| {
|
||||
debug!("Building closure: captured variable %?", cap_var);
|
||||
for vec::each_ref(cap_vars) |cap_var| {
|
||||
debug!("Building closure: captured variable %?", *cap_var);
|
||||
let datum = expr::trans_local_var(bcx, id, cap_var.def);
|
||||
match cap_var.mode {
|
||||
capture::cap_ref => {
|
||||
@ -316,7 +318,7 @@ fn load_environment(fcx: fn_ctxt,
|
||||
|
||||
// Populate the upvars from the environment.
|
||||
let mut i = 0u;
|
||||
do vec::iter(cap_vars) |cap_var| {
|
||||
for vec::each_ref(cap_vars) |cap_var| {
|
||||
match cap_var.mode {
|
||||
capture::cap_drop => { /* ignore */ }
|
||||
_ => {
|
||||
|
@ -1174,12 +1174,14 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
|
||||
|
||||
fn path_str(sess: session::session, p: path) -> ~str {
|
||||
let mut r = ~"", first = true;
|
||||
for vec::each(p) |e| {
|
||||
match e { ast_map::path_name(s) | ast_map::path_mod(s) => {
|
||||
if first { first = false; }
|
||||
else { r += ~"::"; }
|
||||
r += sess.str_of(s);
|
||||
} }
|
||||
for vec::each_ref(p) |e| {
|
||||
match *e {
|
||||
ast_map::path_name(s) | ast_map::path_mod(s) => {
|
||||
if first { first = false; }
|
||||
else { r += ~"::"; }
|
||||
r += sess.str_of(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
@ -1267,10 +1269,10 @@ fn find_vtable(tcx: ty::ctxt, ps: ¶m_substs,
|
||||
let mut vtable_off = n_bound, i = 0u;
|
||||
// Vtables are stored in a flat array, finding the right one is
|
||||
// somewhat awkward
|
||||
for vec::each(*ps.bounds) |bounds| {
|
||||
for vec::each_ref(*ps.bounds) |bounds| {
|
||||
if i >= n_param { break; }
|
||||
for vec::each(*bounds) |bound| {
|
||||
match bound { ty::bound_trait(_) => vtable_off += 1u, _ => () }
|
||||
for vec::each_ref(**bounds) |bound| {
|
||||
match *bound { ty::bound_trait(_) => vtable_off += 1u, _ => () }
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ fn trans_block(bcx: block, b: ast::blk, dest: expr::Dest) -> block {
|
||||
do block_locals(b) |local| {
|
||||
bcx = alloc_local(bcx, local);
|
||||
};
|
||||
for vec::each(b.node.stmts) |s| {
|
||||
for vec::each_ref(b.node.stmts) |s| {
|
||||
debuginfo::update_source_pos(bcx, b.span);
|
||||
bcx = trans_stmt(bcx, *s);
|
||||
bcx = trans_stmt(bcx, **s);
|
||||
}
|
||||
match b.node.expr {
|
||||
Some(e) => {
|
||||
@ -83,9 +83,9 @@ fn trans_if(bcx: block,
|
||||
fn join_blocks(parent_bcx: block, in_cxs: ~[block]) -> block {
|
||||
let out = sub_block(parent_bcx, ~"join");
|
||||
let mut reachable = false;
|
||||
for vec::each(in_cxs) |bcx| {
|
||||
for vec::each_ref(in_cxs) |bcx| {
|
||||
if !bcx.unreachable {
|
||||
Br(bcx, out.llbb);
|
||||
Br(*bcx, out.llbb);
|
||||
reachable = true;
|
||||
}
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ fn trans_rec_or_struct(bcx: block,
|
||||
Ignore => {
|
||||
// just evaluate the values for each field and drop them
|
||||
// on the floor
|
||||
for vec::each(fields) |fld| {
|
||||
for vec::each_ref(fields) |fld| {
|
||||
bcx = trans_into(bcx, fld.node.expr, Ignore);
|
||||
}
|
||||
return bcx;
|
||||
@ -1027,7 +1027,9 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block {
|
||||
let mut bcx = bcx;
|
||||
let addr = match dest {
|
||||
Ignore => {
|
||||
for vec::each(elts) |ex| { bcx = trans_into(bcx, ex, Ignore); }
|
||||
for vec::each_ref(elts) |ex| {
|
||||
bcx = trans_into(bcx, *ex, Ignore);
|
||||
}
|
||||
return bcx;
|
||||
}
|
||||
SaveIn(pos) => pos,
|
||||
@ -1040,7 +1042,9 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block {
|
||||
add_clean_temp_mem(bcx, dest, e_ty);
|
||||
vec::push(temp_cleanups, dest);
|
||||
}
|
||||
for vec::each(temp_cleanups) |cleanup| { revoke_clean(bcx, cleanup); }
|
||||
for vec::each_ref(temp_cleanups) |cleanup| {
|
||||
revoke_clean(bcx, *cleanup);
|
||||
}
|
||||
return bcx;
|
||||
}
|
||||
|
||||
|
@ -164,10 +164,10 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
||||
classify(T_i64(), cls, i, off);
|
||||
} else {
|
||||
let mut field_off = off;
|
||||
for vec::each(tys) |ty| {
|
||||
field_off = align(field_off, ty);
|
||||
classify(ty, cls, i, field_off);
|
||||
field_off += ty_size(ty);
|
||||
for vec::each_ref(tys) |ty| {
|
||||
field_off = align(field_off, *ty);
|
||||
classify(*ty, cls, i, field_off);
|
||||
field_off += ty_size(*ty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,8 +282,8 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
||||
fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef {
|
||||
fn llvec_len(cls: ~[x86_64_reg_class]) -> uint {
|
||||
let mut len = 1u;
|
||||
for vec::each(cls) |c| {
|
||||
if c != sseup_class {
|
||||
for vec::each_ref(cls) |c| {
|
||||
if *c != sseup_class {
|
||||
break;
|
||||
}
|
||||
len += 1u;
|
||||
@ -376,8 +376,8 @@ fn x86_64_tys(atys: ~[TypeRef],
|
||||
|
||||
let mut arg_tys = ~[];
|
||||
let mut attrs = ~[];
|
||||
for vec::each(atys) |t| {
|
||||
let (ty, attr) = x86_64_ty(t, is_pass_byval, ByValAttribute);
|
||||
for vec::each_ref(atys) |t| {
|
||||
let (ty, attr) = x86_64_ty(*t, is_pass_byval, ByValAttribute);
|
||||
vec::push(arg_tys, ty);
|
||||
vec::push(attrs, attr);
|
||||
}
|
||||
@ -410,7 +410,7 @@ fn decl_x86_64_fn(tys: x86_64_tys,
|
||||
let fnty = T_fn(atys, rty);
|
||||
let llfn = decl(fnty);
|
||||
|
||||
do vec::iteri(tys.attrs) |i, a| {
|
||||
for vec::eachi(tys.attrs) |i, a| {
|
||||
match a {
|
||||
option::Some(attr) => {
|
||||
let llarg = get_param(llfn, i);
|
||||
@ -640,7 +640,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
||||
let _icx = bcx.insn_ctxt("foreign::shim::build_ret");
|
||||
match tys.x86_64_tys {
|
||||
Some(x86_64) => {
|
||||
do vec::iteri(x86_64.attrs) |i, a| {
|
||||
for vec::eachi(x86_64.attrs) |i, a| {
|
||||
match a {
|
||||
Some(attr) => {
|
||||
llvm::LLVMAddInstrAttribute(
|
||||
@ -762,7 +762,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
||||
ast::foreign_abi_stdcall => lib::llvm::X86StdcallCallConv
|
||||
};
|
||||
|
||||
for vec::each(foreign_mod.items) |foreign_item| {
|
||||
for vec::each_ref(foreign_mod.items) |foreign_item| {
|
||||
match foreign_item.node {
|
||||
ast::foreign_item_fn(*) => {
|
||||
let id = foreign_item.id;
|
||||
@ -771,9 +771,9 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
||||
let tys = c_stack_tys(ccx, id);
|
||||
if attr::attrs_contains_name(foreign_item.attrs,
|
||||
~"rust_stack") {
|
||||
build_direct_fn(ccx, llwrapfn, foreign_item, tys, cc);
|
||||
build_direct_fn(ccx, llwrapfn, *foreign_item, tys, cc);
|
||||
} else {
|
||||
let llshimfn = build_shim_fn(ccx, foreign_item, tys, cc);
|
||||
let llshimfn = build_shim_fn(ccx, *foreign_item, tys, cc);
|
||||
build_wrap_fn(ccx, tys, llshimfn, llwrapfn);
|
||||
}
|
||||
} else {
|
||||
|
@ -31,11 +31,11 @@ fn trans_impl(ccx: @crate_ctxt, path: path, name: ast::ident,
|
||||
let _icx = ccx.insn_ctxt("impl::trans_impl");
|
||||
if tps.len() > 0u { return; }
|
||||
let sub_path = vec::append_one(path, path_name(name));
|
||||
for vec::each(methods) |method| {
|
||||
for vec::each_ref(methods) |method| {
|
||||
if method.tps.len() == 0u {
|
||||
let llfn = get_item_val(ccx, method.id);
|
||||
let path = vec::append_one(sub_path, path_name(method.ident));
|
||||
trans_method(ccx, path, method, None, llfn);
|
||||
trans_method(ccx, path, *method, None, llfn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -243,8 +243,8 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||
let mut i = 0u;
|
||||
vec::map2(*bounds, substs, |bounds, subst| {
|
||||
let mut v = ~[];
|
||||
for vec::each(*bounds) |bound| {
|
||||
match bound {
|
||||
for vec::each_ref(*bounds) |bound| {
|
||||
match *bound {
|
||||
ty::bound_trait(_) => {
|
||||
vec::push(v, meth::vtable_id(ccx, vts[i]));
|
||||
i += 1u;
|
||||
|
@ -33,11 +33,11 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::ExportMap,
|
||||
|
||||
fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool {
|
||||
let mut found_export = false;
|
||||
for vec::each(vis) |vi| {
|
||||
for vec::each_ref(vis) |vi| {
|
||||
match vi.node {
|
||||
view_item_export(vps) => {
|
||||
found_export = true;
|
||||
for vec::each(vps) |vp| {
|
||||
for vec::each_ref(vps) |vp| {
|
||||
match vp.node {
|
||||
view_path_simple(_, _, _, id) | view_path_glob(_, id) |
|
||||
view_path_list(_, _, id) => {
|
||||
@ -54,7 +54,9 @@ fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool {
|
||||
|
||||
fn traverse_export(cx: ctx, exp_id: node_id) {
|
||||
do option::iter(cx.exp_map.find(exp_id)) |defs| {
|
||||
for vec::each(defs) |def| { traverse_def_id(cx, def.id); }
|
||||
for vec::each_ref(defs) |def| {
|
||||
traverse_def_id(cx, def.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +84,9 @@ fn traverse_def_id(cx: ctx, did: def_id) {
|
||||
fn traverse_public_mod(cx: ctx, m: _mod) {
|
||||
if !traverse_exports(cx, m.view_items) {
|
||||
// No exports, so every local item is exported
|
||||
for vec::each(m.items) |item| { traverse_public_item(cx, item); }
|
||||
for vec::each_ref(m.items) |item| {
|
||||
traverse_public_item(cx, *item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +97,9 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
||||
item_mod(m) => traverse_public_mod(cx, m),
|
||||
item_foreign_mod(nm) => {
|
||||
if !traverse_exports(cx, nm.view_items) {
|
||||
for vec::each(nm.items) |item| { cx.rmap.insert(item.id, ()); }
|
||||
for vec::each_ref(nm.items) |item| {
|
||||
cx.rmap.insert(item.id, ());
|
||||
}
|
||||
}
|
||||
}
|
||||
item_fn(_, _, tps, blk) => {
|
||||
@ -103,7 +109,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
||||
}
|
||||
}
|
||||
item_impl(tps, _, _, ms) => {
|
||||
for vec::each(ms) |m| {
|
||||
for vec::each_ref(ms) |m| {
|
||||
if tps.len() > 0u || m.tps.len() > 0u ||
|
||||
attr::find_inline_attr(m.attrs) != attr::ia_none {
|
||||
cx.rmap.insert(m.id, ());
|
||||
@ -126,7 +132,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
||||
traverse_inline_body(cx, dtor.node.body);
|
||||
}
|
||||
}
|
||||
for vec::each(struct_def.methods) |m| {
|
||||
for vec::each_ref(struct_def.methods) |m| {
|
||||
cx.rmap.insert(m.id, ());
|
||||
if tps.len() > 0 ||
|
||||
attr::find_inline_attr(m.attrs) != attr::ia_none {
|
||||
|
@ -314,7 +314,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
||||
|
||||
ty::ty_rec(fields) => {
|
||||
let mut s = ~[shape_struct], sub = ~[];
|
||||
for vec::each(fields) |f| {
|
||||
for vec::each_ref(fields) |f| {
|
||||
sub += shape_of(ccx, f.mt.ty);
|
||||
}
|
||||
add_substr(s, sub);
|
||||
@ -322,8 +322,8 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
||||
}
|
||||
ty::ty_tup(elts) => {
|
||||
let mut s = ~[shape_struct], sub = ~[];
|
||||
for vec::each(elts) |elt| {
|
||||
sub += shape_of(ccx, elt);
|
||||
for vec::each_ref(elts) |elt| {
|
||||
sub += shape_of(ccx, *elt);
|
||||
}
|
||||
add_substr(s, sub);
|
||||
s
|
||||
@ -376,7 +376,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
||||
|
||||
fn shape_of_variant(ccx: @crate_ctxt, v: ty::variant_info) -> ~[u8] {
|
||||
let mut s = ~[];
|
||||
for vec::each(v.args) |t| { s += shape_of(ccx, t); }
|
||||
for vec::each_ref(v.args) |t| { s += shape_of(ccx, *t); }
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -391,10 +391,10 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
while i < ccx.shape_cx.tag_order.len() {
|
||||
let {did, substs} = ccx.shape_cx.tag_order[i];
|
||||
let variants = @ty::substd_enum_variants(ccx.tcx, did, &substs);
|
||||
do vec::iter(*variants) |v| {
|
||||
for vec::each_ref(*variants) |v| {
|
||||
offsets += ~[vec::len(data) as u16];
|
||||
|
||||
let variant_shape = shape_of_variant(ccx, v);
|
||||
let variant_shape = shape_of_variant(ccx, *v);
|
||||
add_substr(data, variant_shape);
|
||||
|
||||
let zname = str::to_bytes(ccx.sess.str_of(v.name)) + ~[0u8];
|
||||
@ -435,7 +435,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
|
||||
let lv = largest_variants(ccx, variants);
|
||||
add_u16(lv_table, vec::len(lv) as u16);
|
||||
for vec::each(lv) |v| { add_u16(lv_table, v as u16); }
|
||||
for vec::each_ref(lv) |v| { add_u16(lv_table, *v as u16); }
|
||||
|
||||
// Determine whether the enum has dynamic size.
|
||||
assert !vec::any(*variants, |v| {
|
||||
@ -451,7 +451,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
inf += ~[size_align.align];
|
||||
|
||||
// Now write in the offset of each variant.
|
||||
for vec::each(*variants) |_v| {
|
||||
for vec::each_ref(*variants) |_v| {
|
||||
add_u16(inf, header_sz + inf_sz + offsets[i]);
|
||||
i += 1u;
|
||||
}
|
||||
@ -478,17 +478,17 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
// variant that contains (T,T) must be as least as large as
|
||||
// any variant that contains just T.
|
||||
let mut ranges = ~[];
|
||||
for vec::each(*variants) |variant| {
|
||||
for vec::each_ref(*variants) |variant| {
|
||||
let mut bounded = true;
|
||||
let mut min_size = 0u, min_align = 0u;
|
||||
for vec::each(variant.args) |elem_t| {
|
||||
if ty::type_has_params(elem_t) {
|
||||
for vec::each_ref(variant.args) |elem_t| {
|
||||
if ty::type_has_params(*elem_t) {
|
||||
// NB: We could do better here; this causes us to
|
||||
// conservatively assume that (int, T) has minimum size 0,
|
||||
// when in fact it has minimum size sizeof(int).
|
||||
bounded = false;
|
||||
} else {
|
||||
let llty = type_of::type_of(ccx, elem_t);
|
||||
let llty = type_of::type_of(ccx, *elem_t);
|
||||
min_size += llsize_of_real(ccx, llty);
|
||||
min_align += llalign_of_pref(ccx, llty);
|
||||
}
|
||||
@ -550,11 +550,11 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
|
||||
-> size_align {
|
||||
let mut max_size = 0u16;
|
||||
let mut max_align = 1u8;
|
||||
for vec::each(largest_variants) |vid| {
|
||||
for vec::each_ref(largest_variants) |vid| {
|
||||
// We increment a "virtual data pointer" to compute the size.
|
||||
let mut lltys = ~[];
|
||||
for vec::each(variants[vid].args) |typ| {
|
||||
lltys += ~[type_of::type_of(ccx, typ)];
|
||||
for vec::each_ref(variants[*vid].args) |typ| {
|
||||
lltys += ~[type_of::type_of(ccx, *typ)];
|
||||
}
|
||||
|
||||
let llty = trans::common::T_struct(lltys);
|
||||
@ -724,7 +724,7 @@ fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
|
||||
// Compute max(variant sizes).
|
||||
let mut max_size = 0u;
|
||||
let variants = ty::enum_variants(cx.tcx, tid);
|
||||
for vec::each(*variants) |variant| {
|
||||
for vec::each_ref(*variants) |variant| {
|
||||
let tup_ty = simplify_type(cx.tcx,
|
||||
ty::mk_tup(cx.tcx, variant.args));
|
||||
// Perform any type parameter substitutions.
|
||||
|
@ -334,8 +334,8 @@ fn write_content(bcx: block,
|
||||
add_clean_temp_mem(bcx, lleltptr, vt.unit_ty);
|
||||
vec::push(temp_cleanups, lleltptr);
|
||||
}
|
||||
for vec::each(temp_cleanups) |cleanup| {
|
||||
revoke_clean(bcx, cleanup);
|
||||
for vec::each_ref(temp_cleanups) |cleanup| {
|
||||
revoke_clean(bcx, *cleanup);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -372,8 +372,8 @@ fn write_content(bcx: block,
|
||||
vec::push(temp_cleanups, lleltptr);
|
||||
}
|
||||
|
||||
for vec::each(temp_cleanups) |cleanup| {
|
||||
revoke_clean(bcx, cleanup);
|
||||
for vec::each_ref(temp_cleanups) |cleanup| {
|
||||
revoke_clean(bcx, *cleanup);
|
||||
}
|
||||
|
||||
return bcx;
|
||||
|
@ -143,7 +143,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
||||
|
||||
ty::ty_rec(fields) => {
|
||||
let mut tys: ~[TypeRef] = ~[];
|
||||
for vec::each(fields) |f| {
|
||||
for vec::each_ref(fields) |f| {
|
||||
let mt_ty = f.mt.ty;
|
||||
vec::push(tys, type_of(cx, mt_ty));
|
||||
}
|
||||
@ -157,8 +157,8 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
||||
ty::ty_type => T_ptr(cx.tydesc_type),
|
||||
ty::ty_tup(elts) => {
|
||||
let mut tys = ~[];
|
||||
for vec::each(elts) |elt| {
|
||||
vec::push(tys, type_of(cx, elt));
|
||||
for vec::each_ref(elts) |elt| {
|
||||
vec::push(tys, type_of(cx, *elt));
|
||||
}
|
||||
T_struct(tys)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
||||
let cx = {ccx: ccx, uses: vec::to_mut(vec::from_elem(n_tps, 0u))};
|
||||
match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).sty {
|
||||
ty::ty_fn(ref fn_ty) => {
|
||||
for vec::each(fn_ty.sig.inputs) |arg| {
|
||||
for vec::each_ref(fn_ty.sig.inputs) |arg| {
|
||||
if arg.mode == expl(by_val) { type_needs(cx, use_repr, arg.ty); }
|
||||
}
|
||||
}
|
||||
@ -142,9 +142,9 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t,
|
||||
ty::ty_enum(did, substs) => {
|
||||
if option::is_none(list::find(enums_seen, |id| *id == did)) {
|
||||
let seen = @Cons(did, enums_seen);
|
||||
for vec::each(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
|
||||
for vec::each(v.args) |aty| {
|
||||
let t = ty::subst(cx.ccx.tcx, &substs, aty);
|
||||
for vec::each_ref(*ty::enum_variants(cx.ccx.tcx, did)) |v| {
|
||||
for vec::each_ref(v.args) |aty| {
|
||||
let t = ty::subst(cx.ccx.tcx, &substs, *aty);
|
||||
type_needs_inner(cx, use_, t, seen);
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
||||
ty::proto_bare | ty::proto_vstore(ty::vstore_uniq) => {}
|
||||
ty::proto_vstore(ty::vstore_box) |
|
||||
ty::proto_vstore(ty::vstore_slice(_)) => {
|
||||
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
|
||||
for vec::each_ref(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
|
||||
let node_id = ast_util::def_id_of_def(fv.def).node;
|
||||
node_type_needs(cx, use_repr, node_id);
|
||||
}
|
||||
@ -247,14 +247,16 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
||||
node_type_needs(cx, use_tydesc, val.id);
|
||||
}
|
||||
expr_call(f, _, _) => {
|
||||
vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), |a| {
|
||||
match a.mode {
|
||||
expl(by_move) | expl(by_copy) | expl(by_val) => {
|
||||
type_needs(cx, use_repr, a.ty);
|
||||
for vec::each_ref(
|
||||
ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id))
|
||||
) |a| {
|
||||
match a.mode {
|
||||
expl(by_move) | expl(by_copy) | expl(by_val) => {
|
||||
type_needs(cx, use_repr, a.ty);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
expr_match(*) | expr_block(_) | expr_if(*) |
|
||||
expr_while(*) | expr_fail(_) | expr_break(_) | expr_again(_) |
|
||||
|
@ -773,8 +773,8 @@ impl FnVid : to_bytes::IterBytes {
|
||||
|
||||
fn param_bounds_to_kind(bounds: param_bounds) -> kind {
|
||||
let mut kind = kind_noncopyable();
|
||||
for vec::each(*bounds) |bound| {
|
||||
match bound {
|
||||
for vec::each_ref(*bounds) |bound| {
|
||||
match *bound {
|
||||
bound_copy => {
|
||||
kind = raise_kind(kind, kind_implicitly_copyable());
|
||||
}
|
||||
@ -1604,10 +1604,10 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||
ty_class(did, ref substs) => {
|
||||
// Any class with a dtor needs a drop
|
||||
option::is_some(ty_dtor(cx, did)) || {
|
||||
for vec::each(ty::class_items_as_fields(cx, did, substs)) |f| {
|
||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||
}
|
||||
accum
|
||||
for vec::each_ref(ty::class_items_as_fields(cx, did, substs)) |f| {
|
||||
if type_needs_drop(cx, f.mt.ty) { accum = true; }
|
||||
}
|
||||
accum
|
||||
}
|
||||
}
|
||||
ty_tup(elts) => {
|
||||
@ -1616,7 +1616,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||
}
|
||||
ty_enum(did, ref substs) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
for vec::each(*variants) |variant| {
|
||||
for vec::each_ref(*variants) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
// Perform any type parameter substitutions.
|
||||
let arg_ty = subst(cx, substs, aty);
|
||||
@ -1680,7 +1680,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
|
||||
true
|
||||
}
|
||||
ty_enum(did, ref substs) => {
|
||||
for vec::each(*enum_variants(cx, did)) |v| {
|
||||
for vec::each_ref(*enum_variants(cx, did)) |v| {
|
||||
for v.args.each |aty| {
|
||||
let t = subst(cx, substs, aty);
|
||||
needs_unwind_cleanup |=
|
||||
@ -2041,7 +2041,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
if vec::len(*variants) == 0u {
|
||||
lowest = kind_send_only() | kind_owned();
|
||||
} else {
|
||||
for vec::each(*variants) |variant| {
|
||||
for vec::each_ref(*variants) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
// Perform any type parameter substitutions.
|
||||
let arg_ty = subst(cx, substs, aty);
|
||||
@ -2261,7 +2261,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(x: &sty) -> bool) ->
|
||||
if test(sty) { return true; }
|
||||
match *sty {
|
||||
ty_enum(did, ref substs) => {
|
||||
for vec::each(*enum_variants(cx, did)) |variant| {
|
||||
for vec::each_ref(*enum_variants(cx, did)) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
let sty = subst(cx, substs, aty);
|
||||
if type_structurally_contains(cx, sty, test) { return true; }
|
||||
@ -2350,7 +2350,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
||||
// Structural types
|
||||
ty_enum(did, ref substs) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
for vec::each(*variants) |variant| {
|
||||
for vec::each_ref(*variants) |variant| {
|
||||
let tup_ty = mk_tup(cx, variant.args);
|
||||
|
||||
// Perform any type parameter substitutions.
|
||||
@ -2672,7 +2672,7 @@ pure fn hash_type_structure(st: &sty) -> uint {
|
||||
}
|
||||
pure fn hash_subtys(id: uint, subtys: ~[t]) -> uint {
|
||||
let mut h = id;
|
||||
for vec::each(subtys) |s| { h = (h << 2u) + type_id(s) }
|
||||
for vec::each_ref(subtys) |s| { h = (h << 2u) + type_id(*s) }
|
||||
h
|
||||
}
|
||||
pure fn hash_substs(h: uint, substs: &substs) -> uint {
|
||||
@ -2713,12 +2713,12 @@ pure fn hash_type_structure(st: &sty) -> uint {
|
||||
ty_tup(ts) => hash_subtys(25u, ts),
|
||||
ty_rec(fields) => {
|
||||
let mut h = 26u;
|
||||
for vec::each(fields) |f| { h = hash_subty(h, f.mt.ty); }
|
||||
for vec::each_ref(fields) |f| { h = hash_subty(h, f.mt.ty); }
|
||||
h
|
||||
}
|
||||
ty_fn(ref f) => {
|
||||
let mut h = 27u;
|
||||
for vec::each(f.sig.inputs) |a| {
|
||||
for vec::each_ref(f.sig.inputs) |a| {
|
||||
h = hash_subty(h, a.ty);
|
||||
}
|
||||
hash_subty(h, f.sig.output)
|
||||
|
@ -57,7 +57,6 @@ use std::smallintmap;
|
||||
use std::map;
|
||||
use std::map::{HashMap, int_hash};
|
||||
use std::serialization::{serialize_uint, deserialize_uint};
|
||||
use vec::each;
|
||||
use syntax::print::pprust::*;
|
||||
use util::ppaux::{ty_to_str, tys_to_str, region_to_str,
|
||||
bound_region_to_str, vstore_to_str, expr_repr};
|
||||
|
@ -292,8 +292,8 @@ impl LookupContext {
|
||||
let tcx = self.tcx();
|
||||
let mut next_bound_idx = 0; // count only trait bounds
|
||||
let bounds = tcx.ty_param_bounds.get(param_ty.def_id.node);
|
||||
for vec::each(*bounds) |bound| {
|
||||
let bound_t = match bound {
|
||||
for vec::each_ref(*bounds) |bound| {
|
||||
let bound_t = match *bound {
|
||||
ty::bound_trait(bound_t) => bound_t,
|
||||
|
||||
ty::bound_copy | ty::bound_send |
|
||||
|
@ -48,8 +48,8 @@ fn lookup_vtables(fcx: @fn_ctxt,
|
||||
let tcx = fcx.ccx.tcx;
|
||||
let mut result = ~[], i = 0u;
|
||||
for substs.tps.each |ty| {
|
||||
for vec::each(*bounds[i]) |bound| {
|
||||
match bound {
|
||||
for vec::each_ref(*bounds[i]) |bound| {
|
||||
match *bound {
|
||||
ty::bound_trait(i_ty) => {
|
||||
let i_ty = ty::subst(tcx, substs, i_ty);
|
||||
vec::push(result, lookup_vtable(fcx, expr, ty, i_ty,
|
||||
@ -121,8 +121,8 @@ fn lookup_vtable(fcx: @fn_ctxt,
|
||||
match ty::get(ty).sty {
|
||||
ty::ty_param({idx: n, def_id: did}) => {
|
||||
let mut n_bound = 0;
|
||||
for vec::each(*tcx.ty_param_bounds.get(did.node)) |bound| {
|
||||
match bound {
|
||||
for vec::each_ref(*tcx.ty_param_bounds.get(did.node)) |bound| {
|
||||
match *bound {
|
||||
ty::bound_send | ty::bound_copy | ty::bound_const |
|
||||
ty::bound_owned => {
|
||||
/* ignore */
|
||||
@ -156,7 +156,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
|
||||
|
||||
relate_trait_tys(fcx, expr, trait_ty, ty);
|
||||
if !allow_unsafe && !is_early {
|
||||
for vec::each(*ty::trait_methods(tcx, did)) |m| {
|
||||
for vec::each_ref(*ty::trait_methods(tcx, did)) |m| {
|
||||
if ty::type_has_self(ty::mk_fn(tcx, m.fty)) {
|
||||
tcx.sess.span_err(
|
||||
expr.span,
|
||||
@ -214,8 +214,8 @@ fn lookup_vtable(fcx: @fn_ctxt,
|
||||
// it's the same trait as trait_ty, we need to
|
||||
// unify it with trait_ty in order to get all
|
||||
// the ty vars sorted out.
|
||||
for vec::each(ty::impl_traits(tcx, im.did)) |of_ty| {
|
||||
match ty::get(of_ty).sty {
|
||||
for vec::each_ref(ty::impl_traits(tcx, im.did)) |of_ty| {
|
||||
match ty::get(*of_ty).sty {
|
||||
ty::ty_trait(id, _, _) => {
|
||||
// Not the trait we're looking for
|
||||
if id != trait_id { loop; }
|
||||
@ -271,8 +271,8 @@ fn lookup_vtable(fcx: @fn_ctxt,
|
||||
debug!("(checking vtable) @2 relating trait \
|
||||
ty %s to of_ty %s",
|
||||
fcx.infcx().ty_to_str(trait_ty),
|
||||
fcx.infcx().ty_to_str(of_ty));
|
||||
let of_ty = ty::subst(tcx, &substs, of_ty);
|
||||
fcx.infcx().ty_to_str(*of_ty));
|
||||
let of_ty = ty::subst(tcx, &substs, *of_ty);
|
||||
relate_trait_tys(fcx, expr, trait_ty, of_ty);
|
||||
|
||||
// Recall that trait_ty -- the trait type
|
||||
|
@ -137,20 +137,20 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) {
|
||||
match e.node {
|
||||
ast::expr_fn(_, decl, _, _) |
|
||||
ast::expr_fn_block(decl, _, _) => {
|
||||
do vec::iter(decl.inputs) |input| {
|
||||
let r_ty = resolve_type_vars_for_node(wbcx, e.span, input.id);
|
||||
for vec::each_ref(decl.inputs) |input| {
|
||||
let r_ty = resolve_type_vars_for_node(wbcx, e.span, input.id);
|
||||
|
||||
// Just in case we never constrained the mode to anything,
|
||||
// constrain it to the default for the type in question.
|
||||
match (r_ty, input.mode) {
|
||||
(Some(t), ast::infer(_)) => {
|
||||
let tcx = wbcx.fcx.ccx.tcx;
|
||||
let m_def = ty::default_arg_mode_for_ty(tcx, t);
|
||||
ty::set_default_mode(tcx, input.mode, m_def);
|
||||
// Just in case we never constrained the mode to anything,
|
||||
// constrain it to the default for the type in question.
|
||||
match (r_ty, input.mode) {
|
||||
(Some(t), ast::infer(_)) => {
|
||||
let tcx = wbcx.fcx.ccx.tcx;
|
||||
let m_def = ty::default_arg_mode_for_ty(tcx, t);
|
||||
ty::set_default_mode(tcx, input.mode, m_def);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ast::expr_binary(*) | ast::expr_unary(*) | ast::expr_assign_op(*)
|
||||
|
@ -358,12 +358,12 @@ fn check_methods_against_trait(ccx: @crate_ctxt,
|
||||
if did.crate == ast::local_crate {
|
||||
ensure_trait_methods(ccx, did.node, tpt.ty);
|
||||
}
|
||||
for vec::each(*ty::trait_methods(tcx, did)) |trait_m| {
|
||||
for vec::each_ref(*ty::trait_methods(tcx, did)) |trait_m| {
|
||||
match vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) {
|
||||
Some({mty: impl_m, span, _}) => {
|
||||
compare_impl_method(
|
||||
ccx.tcx, span, impl_m, vec::len(tps),
|
||||
trait_m, tpt.substs, selfty);
|
||||
*trait_m, tpt.substs, selfty);
|
||||
}
|
||||
None => {
|
||||
// If we couldn't find an implementation for trait_m in
|
||||
|
@ -1098,8 +1098,8 @@ impl RegionVarBindings {
|
||||
let upper_bounds =
|
||||
self.collect_concrete_regions(graph, node_idx, Outgoing);
|
||||
|
||||
for vec::each(lower_bounds) |lower_bound| {
|
||||
for vec::each(upper_bounds) |upper_bound| {
|
||||
for vec::each_ref(lower_bounds) |lower_bound| {
|
||||
for vec::each_ref(upper_bounds) |upper_bound| {
|
||||
if !self.is_subregion_of(lower_bound.region,
|
||||
upper_bound.region) {
|
||||
|
||||
@ -1148,8 +1148,8 @@ impl RegionVarBindings {
|
||||
let upper_bounds = self.collect_concrete_regions(graph, node_idx,
|
||||
Outgoing);
|
||||
|
||||
for vec::each(upper_bounds) |upper_bound_1| {
|
||||
for vec::each(upper_bounds) |upper_bound_2| {
|
||||
for vec::each_ref(upper_bounds) |upper_bound_1| {
|
||||
for vec::each_ref(upper_bounds) |upper_bound_2| {
|
||||
match self.glb_concrete_regions(upper_bound_1.region,
|
||||
upper_bound_2.region) {
|
||||
Ok(_) => {}
|
||||
|
@ -74,10 +74,13 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
|
||||
map::HashMap::<node_id, ()>()
|
||||
};
|
||||
|
||||
do vec::each(edges) |e| {
|
||||
let (i, j) = e;
|
||||
map::set_add(graph[i], j);
|
||||
map::set_add(graph[j], i);
|
||||
do vec::each_ref(edges) |e| {
|
||||
match *e {
|
||||
(i, j) => {
|
||||
map::set_add(graph[i], j);
|
||||
map::set_add(graph[j], i);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@ -407,7 +410,7 @@ fn main(args: ~[~str]) {
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
let mut total_edges = 0u;
|
||||
vec::each(graph, |edges| { total_edges += edges.len(); true });
|
||||
vec::each_ref(graph, |edges| { total_edges += edges.len(); true });
|
||||
|
||||
io::stdout().write_line(fmt!("Generated graph with %? edges in %? seconds.",
|
||||
total_edges / 2u,
|
||||
|
@ -73,7 +73,10 @@ fn run(args: &[~str]) {
|
||||
server(from_parent, to_parent);
|
||||
}
|
||||
|
||||
vec::iter(worker_results, |r| { future::get(&r); } );
|
||||
for vec::each_ref(worker_results) |r| {
|
||||
future::get(r);
|
||||
}
|
||||
|
||||
//error!("sending stop message");
|
||||
to_child.send(stop);
|
||||
move_out!(to_child);
|
||||
|
@ -70,7 +70,10 @@ fn run(args: &[~str]) {
|
||||
server(from_parent, to_parent);
|
||||
}
|
||||
|
||||
vec::iter(worker_results, |r| { future::get(&r); } );
|
||||
for vec::each_ref(worker_results) |r| {
|
||||
future::get(r);
|
||||
}
|
||||
|
||||
//error!("sending stop message");
|
||||
to_child.send(stop);
|
||||
move_out!(to_child);
|
||||
|
@ -44,7 +44,9 @@ fn run(args: ~[~str]) {
|
||||
}
|
||||
};
|
||||
}
|
||||
vec::iter(worker_results, |r| { future::get(&r); } );
|
||||
for vec::each_ref(worker_results) |r| {
|
||||
future::get(r);
|
||||
}
|
||||
comm::send(to_child, stop);
|
||||
let result = comm::recv(from_child);
|
||||
let end = std::time::precise_time_s();
|
||||
|
@ -7,10 +7,10 @@ use std::sort;
|
||||
|
||||
fn print_complements() {
|
||||
let all = ~[Blue, Red, Yellow];
|
||||
for vec::each(all) |aa| {
|
||||
for vec::each(all) |bb| {
|
||||
io::println(show_color(aa) + ~" + " + show_color(bb) +
|
||||
~" -> " + show_color(transform(aa,bb)));
|
||||
for vec::each_ref(all) |aa| {
|
||||
for vec::each_ref(all) |bb| {
|
||||
io::println(show_color(*aa) + ~" + " + show_color(*bb) +
|
||||
~" -> " + show_color(transform(*aa, *bb)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
|
||||
|
||||
// save each creature's meeting stats
|
||||
let mut report = ~[];
|
||||
for vec::each(to_creature) |_to_one| {
|
||||
for vec::each_ref(to_creature) |_to_one| {
|
||||
vec::push(report, comm::recv(from_creatures_log));
|
||||
}
|
||||
|
||||
@ -170,8 +170,8 @@ fn rendezvous(nn: uint, set: ~[color]) {
|
||||
io::println(show_color_list(set));
|
||||
|
||||
// print each creature's stats
|
||||
for vec::each(report) |rep| {
|
||||
io::println(rep);
|
||||
for vec::each_ref(report) |rep| {
|
||||
io::println(*rep);
|
||||
}
|
||||
|
||||
// print the total number of creatures met
|
||||
|
@ -31,9 +31,9 @@ fn calc(children: uint, parent_ch: comm::Chan<msg>) {
|
||||
|
||||
match comm::recv(port) {
|
||||
start => {
|
||||
do vec::iter (child_chs) |child_ch| {
|
||||
comm::send(child_ch, start);
|
||||
}
|
||||
for vec::each_ref(child_chs) |child_ch| {
|
||||
comm::send(*child_ch, start);
|
||||
}
|
||||
}
|
||||
_ => fail ~"task-perf-one-million failed (port not in start state)"
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// error-pattern:mismatched types: expected `()` but found `bool`
|
||||
|
||||
fn main() {
|
||||
for vec::each(~[0]) |_i| {
|
||||
for vec::each_ref(~[0]) |_i| {
|
||||
true
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
fn want_slice(v: &[int]) -> int {
|
||||
let mut sum = 0;
|
||||
for vec::each(v) |i| { sum += i; }
|
||||
for vec::each_ref(v) |i| { sum += *i; }
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
fn main() {
|
||||
do vec::iter(fail) |i| {
|
||||
for vec::each_ref(fail) |i| {
|
||||
log (debug, i * 2);
|
||||
//~^ ERROR the type of this value must be known
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
fn main() {
|
||||
let a: ~[int] = ~[];
|
||||
vec::each(a, fn@(_x: int) -> bool { //~ ERROR not all control paths return a value
|
||||
vec::each_ref(a, fn@(_x: &int) -> bool {
|
||||
//~^ ERROR not all control paths return a value
|
||||
});
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ fn concat<T: Copy>(v: ~[const ~[const T]]) -> ~[T] {
|
||||
let mut r = ~[];
|
||||
|
||||
// Earlier versions of our type checker accepted this:
|
||||
vec::iter(v, |&&inner: ~[T]| {
|
||||
vec::each_ref(v, |inner: &~[T]| {
|
||||
//~^ ERROR values differ in mutability
|
||||
r += inner;
|
||||
r += *inner; true
|
||||
});
|
||||
|
||||
return r;
|
||||
|
@ -3,8 +3,8 @@ fn main() {
|
||||
let v = ~[-1f, 0f, 1f, 2f, 3f];
|
||||
|
||||
// Statement form does not require parentheses:
|
||||
do vec::iter(v) |i| {
|
||||
log(info, i);
|
||||
for vec::each_ref(v) |i| {
|
||||
log(info, *i);
|
||||
}
|
||||
|
||||
// Usable at all:
|
||||
|
Loading…
x
Reference in New Issue
Block a user