De-mode vec::map, vec::eachi, vec::rev_each, vec::rev_eachi
This commit is contained in:
parent
f3c31a07d7
commit
3d59ac3a19
@ -426,7 +426,7 @@ annotation:
|
||||
~~~~
|
||||
// The type of this vector will be inferred based on its use.
|
||||
let x = [];
|
||||
# vec::map(x, fn&(&&_y:int) -> int { _y });
|
||||
# vec::map(x, fn&(_y: &int) -> int { *_y });
|
||||
// Explicitly say this is a vector of zero integers.
|
||||
let y: [int * 0] = [];
|
||||
~~~~
|
||||
@ -1242,7 +1242,7 @@ for crayons.each |crayon| {
|
||||
}
|
||||
|
||||
// Map vector elements
|
||||
let crayon_names = crayons.map(|v| crayon_to_str(v));
|
||||
let crayon_names = crayons.map(|v| crayon_to_str(*v));
|
||||
let favorite_crayon_name = crayon_names[0];
|
||||
|
||||
// Remove whitespace from before and after the string
|
||||
@ -1298,7 +1298,7 @@ access local variables in the enclosing scope.
|
||||
|
||||
~~~~
|
||||
let mut max = 0;
|
||||
(~[1, 2, 3]).map(|x| if x > max { max = x });
|
||||
(~[1, 2, 3]).map(|x| if *x > max { max = *x });
|
||||
~~~~
|
||||
|
||||
Stack closures are very efficient because their environment is
|
||||
|
@ -195,17 +195,17 @@ fn is_uuid(id: ~str) -> bool {
|
||||
|
||||
match i {
|
||||
0u => {
|
||||
if str::len(part) == 8u {
|
||||
if part.len() == 8u {
|
||||
correct += 1u;
|
||||
}
|
||||
}
|
||||
1u | 2u | 3u => {
|
||||
if str::len(part) == 4u {
|
||||
if part.len() == 4u {
|
||||
correct += 1u;
|
||||
}
|
||||
}
|
||||
4u => {
|
||||
if str::len(part) == 12u {
|
||||
if part.len() == 12u {
|
||||
correct += 1u;
|
||||
}
|
||||
}
|
||||
|
@ -437,13 +437,12 @@ impl<T: Copy> DList<T> {
|
||||
/// Get data at the list's tail, failing if empty. O(1).
|
||||
pure fn tail() -> T { self.tail_n().data }
|
||||
/// Get the elements of the list as a vector. O(n).
|
||||
pure fn to_vec() -> ~[mut T] {
|
||||
let mut v = ~[mut];
|
||||
pure fn to_vec() -> ~[T] {
|
||||
let mut v = vec::with_capacity(self.size);
|
||||
unsafe {
|
||||
vec::reserve(v, self.size);
|
||||
// Take this out of the unchecked when iter's functions are pure
|
||||
for self.eachi |index,data| {
|
||||
v[index] = data;
|
||||
v[index] = *data;
|
||||
}
|
||||
}
|
||||
move v
|
||||
|
@ -117,7 +117,7 @@ priv impl<A> DVec<A> {
|
||||
impl<A> DVec<A> {
|
||||
/// Reserves space for N elements
|
||||
fn reserve(count: uint) {
|
||||
vec::reserve(self.data, count)
|
||||
vec::reserve(&mut self.data, count)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +243,7 @@ impl<A: Copy> DVec<A> {
|
||||
do self.swap |v| {
|
||||
let mut v <- v;
|
||||
let new_len = vec::len(v) + to_idx - from_idx;
|
||||
vec::reserve(v, new_len);
|
||||
vec::reserve(&mut v, new_len);
|
||||
let mut i = from_idx;
|
||||
while i < to_idx {
|
||||
vec::push(v, ts[i]);
|
||||
@ -313,9 +313,9 @@ impl<A: Copy> DVec<A> {
|
||||
*/
|
||||
fn grow_set_elt(idx: uint, initval: A, val: A) {
|
||||
do self.swap |v| {
|
||||
let mut v = vec::to_mut(move v);
|
||||
let mut v = move v;
|
||||
vec::grow_set(v, idx, initval, val);
|
||||
move vec::from_mut(v)
|
||||
move v
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,14 +334,28 @@ impl<A: Copy> DVec<A> {
|
||||
|
||||
/// Iterates over the elements in reverse order
|
||||
#[inline(always)]
|
||||
fn reach(f: fn(A) -> bool) {
|
||||
do self.swap |v| { vec::reach(v, f); move v }
|
||||
fn rev_each(f: fn(v: &A) -> bool) {
|
||||
do self.swap |v| {
|
||||
// FIXME(#2263)---we should be able to write
|
||||
// `vec::rev_each(v, f);` but we cannot write now
|
||||
for vec::rev_each(v) |e| {
|
||||
if !f(e) { break; }
|
||||
}
|
||||
move v
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterates over the elements and indices in reverse order
|
||||
#[inline(always)]
|
||||
fn reachi(f: fn(uint, A) -> bool) {
|
||||
do self.swap |v| { vec::reachi(v, f); move v }
|
||||
fn rev_eachi(f: fn(uint, v: &A) -> bool) {
|
||||
do self.swap |v| {
|
||||
// FIXME(#2263)---we should be able to write
|
||||
// `vec::rev_eachi(v, f);` but we cannot write now
|
||||
for vec::rev_eachi(v) |i, e| {
|
||||
if !f(i, e) { break; }
|
||||
}
|
||||
move v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,14 +52,13 @@ trait ReaderUtil {
|
||||
|
||||
impl<T: Reader> T : ReaderUtil {
|
||||
fn read_bytes(len: uint) -> ~[u8] {
|
||||
let mut buf = ~[mut];
|
||||
vec::reserve(buf, len);
|
||||
let mut buf = vec::with_capacity(len);
|
||||
unsafe { vec::raw::set_len(buf, len); }
|
||||
|
||||
let count = self.read(buf, len);
|
||||
|
||||
unsafe { vec::raw::set_len(buf, count); }
|
||||
vec::from_mut(move buf)
|
||||
move buf
|
||||
}
|
||||
fn read_line() -> ~str {
|
||||
let mut buf = ~[];
|
||||
@ -696,7 +695,7 @@ impl BytesWriter: Writer {
|
||||
let buf_len = buf.len();
|
||||
|
||||
let count = uint::max(buf_len, self.pos + v_len);
|
||||
vec::reserve(buf, count);
|
||||
vec::reserve(&mut buf, count);
|
||||
unsafe { vec::raw::set_len(buf, count); }
|
||||
|
||||
let view = vec::mut_view(buf, self.pos, count);
|
||||
@ -910,7 +909,7 @@ mod tests {
|
||||
assert(vec::len(res) == len);
|
||||
}
|
||||
assert(vec::slice(ivals, 0u, vec::len(res)) ==
|
||||
vec::map(res, |x| x as int));
|
||||
vec::map(res, |x| *x as int));
|
||||
}
|
||||
}
|
||||
let mut i = 0u;
|
||||
|
@ -12,7 +12,7 @@ impl<A> IMPL_T<A>: iter::BaseIter<A> {
|
||||
}
|
||||
|
||||
impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
|
||||
pure fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) }
|
||||
pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(self, blk) }
|
||||
pure fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) }
|
||||
pure fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) }
|
||||
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
|
||||
@ -32,7 +32,7 @@ impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
|
||||
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
|
||||
iter::filter_to_vec(self, pred)
|
||||
}
|
||||
pure fn map_to_vec<B>(op: fn(A) -> B) -> ~[B] {
|
||||
pure fn map_to_vec<B>(op: fn(v: &A) -> B) -> ~[B] {
|
||||
iter::map_to_vec(self, op)
|
||||
}
|
||||
pure fn to_vec() -> ~[A] { iter::to_vec(self) }
|
||||
|
@ -15,7 +15,7 @@ trait BaseIter<A> {
|
||||
}
|
||||
|
||||
trait ExtendedIter<A> {
|
||||
pure fn eachi(blk: fn(uint, A) -> bool);
|
||||
pure fn eachi(blk: fn(uint, v: &A) -> bool);
|
||||
pure fn all(blk: fn(A) -> bool) -> bool;
|
||||
pure fn any(blk: fn(A) -> bool) -> bool;
|
||||
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B;
|
||||
@ -36,7 +36,7 @@ trait TimesIx{
|
||||
|
||||
trait CopyableIter<A:Copy> {
|
||||
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A];
|
||||
pure fn map_to_vec<B>(op: fn(A) -> B) -> ~[B];
|
||||
pure fn map_to_vec<B>(op: fn(v: &A) -> B) -> ~[B];
|
||||
pure fn to_vec() -> ~[A];
|
||||
pure fn find(p: fn(A) -> bool) -> Option<A>;
|
||||
}
|
||||
@ -66,10 +66,10 @@ trait Buildable<A> {
|
||||
builder: fn(push: pure fn(+A))) -> self;
|
||||
}
|
||||
|
||||
pure fn eachi<A,IA:BaseIter<A>>(self: IA, blk: fn(uint, A) -> bool) {
|
||||
pure fn eachi<A,IA:BaseIter<A>>(self: IA, blk: fn(uint, v: &A) -> bool) {
|
||||
let mut i = 0u;
|
||||
for self.each |a| {
|
||||
if !blk(i, *a) { break; }
|
||||
if !blk(i, a) { break; }
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
@ -97,11 +97,11 @@ pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(self: IA,
|
||||
}
|
||||
}
|
||||
|
||||
pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: IA, op: fn(A) -> B)
|
||||
pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: IA, op: fn(v: &A) -> B)
|
||||
-> ~[B] {
|
||||
do vec::build_sized_opt(self.size_hint()) |push| {
|
||||
for self.each |a| {
|
||||
push(op(*a));
|
||||
push(op(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ fn list_dir(p: &Path) -> ~[~str] {
|
||||
* This version prepends each entry with the directory.
|
||||
*/
|
||||
fn list_dir_path(p: &Path) -> ~[~Path] {
|
||||
os::list_dir(p).map(|f| ~p.push(f))
|
||||
os::list_dir(p).map(|f| ~p.push(*f))
|
||||
}
|
||||
|
||||
/// Removes a directory at the specified path
|
||||
@ -721,9 +721,8 @@ fn copy_file(from: &Path, to: &Path) -> bool {
|
||||
fclose(istream);
|
||||
return false;
|
||||
}
|
||||
let mut buf : ~[mut u8] = ~[mut];
|
||||
let bufsize = 8192u;
|
||||
vec::reserve(buf, bufsize);
|
||||
let mut buf = vec::with_capacity::<u8>(bufsize);
|
||||
let mut done = false;
|
||||
let mut ok = true;
|
||||
while !done {
|
||||
|
@ -269,8 +269,7 @@ 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> {
|
||||
|
||||
let mut vs: ~[V] = ~[];
|
||||
vec::reserve(vs, vec::len(ts));
|
||||
let mut vs: ~[V] = vec::with_capacity(vec::len(ts));
|
||||
for vec::each(ts) |t| {
|
||||
match op(t) {
|
||||
Ok(v) => vec::push(vs, v),
|
||||
@ -306,8 +305,7 @@ fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
|
||||
|
||||
assert vec::same_length(ss, ts);
|
||||
let n = vec::len(ts);
|
||||
let mut vs = ~[];
|
||||
vec::reserve(vs, n);
|
||||
let mut vs = vec::with_capacity(n);
|
||||
let mut i = 0u;
|
||||
while i < n {
|
||||
match op(ss[i],ts[i]) {
|
||||
|
@ -669,8 +669,8 @@ pure fn lines(s: &str) -> ~[~str] { split_char(s, '\n') }
|
||||
*/
|
||||
pure fn lines_any(s: &str) -> ~[~str] {
|
||||
vec::map(lines(s), |s| {
|
||||
let l = len(s);
|
||||
let mut cp = copy s;
|
||||
let l = len(*s);
|
||||
let mut cp = copy *s;
|
||||
if l > 0u && s[l - 1u] == '\r' as u8 {
|
||||
unsafe { raw::set_len(&mut cp, l - 1u); }
|
||||
}
|
||||
@ -1984,7 +1984,7 @@ pure fn as_buf<T>(s: &str, f: fn(*u8, uint) -> T) -> T {
|
||||
fn reserve(s: &const ~str, n: uint) {
|
||||
unsafe {
|
||||
let v: *mut ~[u8] = cast::transmute(copy s);
|
||||
vec::reserve(*v, n + 1);
|
||||
vec::reserve(&mut *v, n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2077,10 +2077,8 @@ mod raw {
|
||||
|
||||
/// Create a Rust string from a *u8 buffer of the given length
|
||||
unsafe fn from_buf_len(buf: *const u8, len: uint) -> ~str {
|
||||
let mut v: ~[mut u8] = ~[mut];
|
||||
vec::reserve(v, len + 1u);
|
||||
vec::as_imm_buf(v, |vbuf, _len| {
|
||||
let vbuf = ::cast::transmute_mut_unsafe(vbuf);
|
||||
let mut v: ~[u8] = vec::with_capacity(len + 1);
|
||||
vec::as_mut_buf(v, |vbuf, _len| {
|
||||
ptr::memcpy(vbuf, buf as *u8, len)
|
||||
});
|
||||
vec::raw::set_len(v, len);
|
||||
@ -2132,8 +2130,7 @@ mod raw {
|
||||
assert (begin <= end);
|
||||
assert (end <= n);
|
||||
|
||||
let mut v = ~[];
|
||||
vec::reserve(v, end - begin + 1u);
|
||||
let mut v = vec::with_capacity(end - begin + 1u);
|
||||
unsafe {
|
||||
do vec::as_imm_buf(v) |vbuf, _vlen| {
|
||||
let vbuf = ::cast::transmute_mut_unsafe(vbuf);
|
||||
|
@ -19,6 +19,7 @@ export len;
|
||||
export from_fn;
|
||||
export from_elem;
|
||||
export from_slice;
|
||||
export with_capacity;
|
||||
export build, build_sized, build_sized_opt;
|
||||
export to_mut;
|
||||
export from_mut;
|
||||
@ -76,7 +77,7 @@ export zip, zip_slice;
|
||||
export swap;
|
||||
export reverse;
|
||||
export reversed;
|
||||
export each, each_mut, each_const, eachi, reach, reachi;
|
||||
export each, each_mut, each_const, eachi, rev_each, rev_eachi;
|
||||
export iter2;
|
||||
export permute;
|
||||
export windowed;
|
||||
@ -135,12 +136,14 @@ pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
|
||||
* * v - A vector
|
||||
* * n - The number of elements to reserve space for
|
||||
*/
|
||||
fn reserve<T>(&v: ~[const T], n: uint) {
|
||||
fn reserve<T>(+v: &mut ~[T], +n: uint) {
|
||||
// Only make the (slow) call into the runtime if we have to
|
||||
if capacity(v) < n {
|
||||
let ptr = ptr::addr_of(v) as **raw::VecRepr;
|
||||
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
|
||||
ptr, n as size_t);
|
||||
if capacity(*v) < n {
|
||||
unsafe {
|
||||
let ptr: **raw::VecRepr = cast::transmute(v);
|
||||
rustrt::vec_reserve_shared(sys::get_type_desc::<T>(),
|
||||
ptr, n as size_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,7 +162,7 @@ fn reserve<T>(&v: ~[const T], n: uint) {
|
||||
* * v - A vector
|
||||
* * n - The number of elements to reserve space for
|
||||
*/
|
||||
fn reserve_at_least<T>(&v: ~[const T], n: uint) {
|
||||
fn reserve_at_least<T>(v: &mut ~[T], n: uint) {
|
||||
reserve(v, uint::next_power_of_two(n));
|
||||
}
|
||||
|
||||
@ -185,8 +188,7 @@ pure fn len<T>(&&v: &[const T]) -> uint {
|
||||
* to the value returned by the function `op`.
|
||||
*/
|
||||
pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
|
||||
let mut v = ~[];
|
||||
unsafe{reserve(v, n_elts);}
|
||||
let mut v = with_capacity(n_elts);
|
||||
let mut i: uint = 0u;
|
||||
while i < n_elts unsafe { raw::set(v, i, op(i)); i += 1u; }
|
||||
unsafe { raw::set_len(v, n_elts); }
|
||||
@ -200,8 +202,7 @@ pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] {
|
||||
* to the value `t`.
|
||||
*/
|
||||
pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> ~[T] {
|
||||
let mut v = ~[];
|
||||
unsafe{reserve(v, n_elts)}
|
||||
let mut v = with_capacity(n_elts);
|
||||
let mut i: uint = 0u;
|
||||
unsafe { // because unsafe::set is unsafe
|
||||
while i < n_elts { raw::set(v, i, t); i += 1u; }
|
||||
@ -215,6 +216,12 @@ pure fn from_slice<T: Copy>(t: &[T]) -> ~[T] {
|
||||
from_fn(t.len(), |i| t[i])
|
||||
}
|
||||
|
||||
pure fn with_capacity<T>(capacity: uint) -> ~[T] {
|
||||
let mut vec = ~[];
|
||||
unsafe { reserve(&mut vec, capacity); }
|
||||
return move vec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a vector by calling a provided function with an argument
|
||||
* function that pushes an element to the back of a vector.
|
||||
@ -229,8 +236,7 @@ pure fn from_slice<T: Copy>(t: &[T]) -> ~[T] {
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> ~[A] {
|
||||
let mut vec = ~[];
|
||||
unsafe { reserve(vec, size); }
|
||||
let mut vec = with_capacity(size);
|
||||
builder(|+x| unsafe { push(vec, move x) });
|
||||
move vec
|
||||
}
|
||||
@ -422,7 +428,7 @@ fn rsplit<T: Copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
|
||||
if (ln == 0u) { return ~[] }
|
||||
|
||||
let mut end = ln;
|
||||
let mut result = ~[mut ];
|
||||
let mut result = ~[];
|
||||
while end > 0u {
|
||||
match rposition_between(v, 0u, end, f) {
|
||||
None => break,
|
||||
@ -434,7 +440,7 @@ fn rsplit<T: Copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] {
|
||||
}
|
||||
push(result, slice(v, 0u, end));
|
||||
reverse(result);
|
||||
return from_mut(move result);
|
||||
return move result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -447,7 +453,7 @@ fn rsplitn<T: Copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
|
||||
|
||||
let mut end = ln;
|
||||
let mut count = n;
|
||||
let mut result = ~[mut ];
|
||||
let mut result = ~[];
|
||||
while end > 0u && count > 0u {
|
||||
match rposition_between(v, 0u, end, f) {
|
||||
None => break,
|
||||
@ -461,7 +467,7 @@ fn rsplitn<T: Copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] {
|
||||
}
|
||||
push(result, slice(v, 0u, end));
|
||||
reverse(result);
|
||||
move from_mut(move result)
|
||||
move result
|
||||
}
|
||||
|
||||
// Mutators
|
||||
@ -561,7 +567,7 @@ fn swap_remove<T>(&v: ~[const T], index: uint) -> T {
|
||||
|
||||
/// Append an element to a vector
|
||||
#[inline(always)]
|
||||
fn push<T>(&v: ~[const T], +initval: T) {
|
||||
fn push<T>(&v: ~[T], +initval: T) {
|
||||
unsafe {
|
||||
let repr: **raw::VecRepr = ::cast::reinterpret_cast(&addr_of(v));
|
||||
let fill = (**repr).unboxed.fill;
|
||||
@ -576,7 +582,7 @@ fn push<T>(&v: ~[const T], +initval: T) {
|
||||
|
||||
// This doesn't bother to make sure we have space.
|
||||
#[inline(always)] // really pretty please
|
||||
unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
|
||||
unsafe fn push_fast<T>(&v: ~[T], +initval: T) {
|
||||
let repr: **raw::VecRepr = ::cast::reinterpret_cast(&addr_of(v));
|
||||
let fill = (**repr).unboxed.fill;
|
||||
(**repr).unboxed.fill += sys::size_of::<T>();
|
||||
@ -586,14 +592,14 @@ unsafe fn push_fast<T>(&v: ~[const T], +initval: T) {
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn push_slow<T>(&v: ~[const T], +initval: T) {
|
||||
reserve_at_least(v, v.len() + 1u);
|
||||
fn push_slow<T>(&v: ~[T], +initval: T) {
|
||||
reserve_at_least(&mut v, v.len() + 1u);
|
||||
unsafe { push_fast(v, move initval) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn push_all<T: Copy>(&v: ~[const T], rhs: &[const T]) {
|
||||
reserve(v, v.len() + rhs.len());
|
||||
fn push_all<T: Copy>(&v: ~[T], rhs: &[const T]) {
|
||||
reserve(&mut v, v.len() + rhs.len());
|
||||
|
||||
for uint::range(0u, rhs.len()) |i| {
|
||||
push(v, unsafe { raw::get(rhs, i) })
|
||||
@ -601,8 +607,8 @@ fn push_all<T: Copy>(&v: ~[const T], rhs: &[const T]) {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn push_all_move<T>(&v: ~[const T], -rhs: ~[const T]) {
|
||||
reserve(v, v.len() + rhs.len());
|
||||
fn push_all_move<T>(&v: ~[T], -rhs: ~[const T]) {
|
||||
reserve(&mut v, v.len() + rhs.len());
|
||||
unsafe {
|
||||
do as_imm_buf(rhs) |p, len| {
|
||||
for uint::range(0, len) |i| {
|
||||
@ -681,23 +687,8 @@ pure fn append_one<T>(+lhs: ~[T], +x: T) -> ~[T] {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pure fn append_mut<T: Copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] {
|
||||
let mut v = ~[mut];
|
||||
let mut i = 0u;
|
||||
while i < lhs.len() {
|
||||
unsafe { // This is impure, but it appears pure to the caller.
|
||||
push(v, lhs[i]);
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
i = 0u;
|
||||
while i < rhs.len() {
|
||||
unsafe { // This is impure, but it appears pure to the caller.
|
||||
push(v, rhs[i]);
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
move v
|
||||
pure fn append_mut<T: Copy>(+lhs: ~[mut T], rhs: &[const T]) -> ~[mut T] {
|
||||
to_mut(append(from_mut(lhs), rhs))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -709,8 +700,8 @@ pure fn append_mut<T: Copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] {
|
||||
* * n - The number of elements to add
|
||||
* * initval - The value for the new elements
|
||||
*/
|
||||
fn grow<T: Copy>(&v: ~[const T], n: uint, initval: T) {
|
||||
reserve_at_least(v, len(v) + n);
|
||||
fn grow<T: Copy>(&v: ~[T], n: uint, initval: T) {
|
||||
reserve_at_least(&mut v, len(v) + n);
|
||||
let mut i: uint = 0u;
|
||||
|
||||
while i < n { push(v, initval); i += 1u; }
|
||||
@ -729,8 +720,8 @@ fn grow<T: Copy>(&v: ~[const T], n: uint, initval: T) {
|
||||
* * init_op - A function to call to retreive each appended element's
|
||||
* value
|
||||
*/
|
||||
fn grow_fn<T>(&v: ~[const T], n: uint, op: iter::InitOp<T>) {
|
||||
reserve_at_least(v, len(v) + n);
|
||||
fn grow_fn<T>(&v: ~[T], n: uint, op: iter::InitOp<T>) {
|
||||
reserve_at_least(&mut v, len(v) + n);
|
||||
let mut i: uint = 0u;
|
||||
while i < n { push(v, op(i)); i += 1u; }
|
||||
}
|
||||
@ -743,7 +734,7 @@ fn grow_fn<T>(&v: ~[const T], n: uint, op: iter::InitOp<T>) {
|
||||
* of the vector, expands the vector by replicating `initval` to fill the
|
||||
* intervening space.
|
||||
*/
|
||||
fn grow_set<T: Copy>(&v: ~[mut T], index: uint, initval: T, val: T) {
|
||||
fn grow_set<T: Copy>(&v: ~[T], index: uint, initval: T, val: T) {
|
||||
if index >= len(v) { grow(v, index - len(v) + 1u, initval); }
|
||||
v[index] = val;
|
||||
}
|
||||
@ -751,10 +742,9 @@ fn grow_set<T: Copy>(&v: ~[mut T], index: uint, initval: T, val: T) {
|
||||
// Functional utilities
|
||||
|
||||
/// 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] {
|
||||
let mut result = ~[];
|
||||
unsafe{reserve(result, len(v));}
|
||||
for each(v) |elem| { unsafe { push(result, f(*elem)); } }
|
||||
pure fn map<T, U>(v: &[T], f: fn(v: &T) -> U) -> ~[U] {
|
||||
let mut result = with_capacity(len(v));
|
||||
for each(v) |elem| { unsafe { push(result, f(elem)); } }
|
||||
move result
|
||||
}
|
||||
|
||||
@ -767,11 +757,12 @@ fn map_consume<T, U>(+v: ~[T], f: fn(+T) -> U) -> ~[U] {
|
||||
}
|
||||
|
||||
/// Apply a function to each element of a vector and return the results
|
||||
pure fn mapi<T, U>(v: &[T], f: fn(uint, T) -> U) -> ~[U] {
|
||||
let mut result = ~[];
|
||||
unsafe{reserve(result, len(v));}
|
||||
for eachi(v) |i, elem| { unsafe { push(result, f(i, elem)); } }
|
||||
move result
|
||||
pure fn mapi<T, U>(v: &[T], f: fn(uint, v: &T) -> U) -> ~[U] {
|
||||
let mut i = 0;
|
||||
do map(v) |e| {
|
||||
i += 1;
|
||||
f(i - 1, e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -865,8 +856,8 @@ 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;
|
||||
for reach(v) |elt| {
|
||||
accum = p(elt, accum);
|
||||
for rev_each(v) |elt| {
|
||||
accum = p(*elt, accum);
|
||||
}
|
||||
return accum;
|
||||
}
|
||||
@ -914,7 +905,7 @@ pure fn all<T>(v: &[T], f: fn(T) -> bool) -> bool {
|
||||
* If the vector contains no elements then true is returned.
|
||||
*/
|
||||
pure fn alli<T>(v: &[T], f: fn(uint, T) -> bool) -> bool {
|
||||
for eachi(v) |i, elem| { if !f(i, elem) { return false; } }
|
||||
for eachi(v) |i, elem| { if !f(i, *elem) { return false; } }
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1120,13 +1111,13 @@ pure fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U])
|
||||
pure fn zip<T, U>(+v: ~[const T], +u: ~[const U]) -> ~[(T, U)] {
|
||||
let mut v = move v, u = move u, i = len(v);
|
||||
assert i == len(u);
|
||||
let mut w = ~[mut];
|
||||
let mut w = with_capacity(i);
|
||||
while i > 0 {
|
||||
unsafe { push(w, (pop(v),pop(u))); }
|
||||
i -= 1;
|
||||
}
|
||||
unsafe { reverse(w); }
|
||||
from_mut(move w)
|
||||
move w
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1222,17 +1213,11 @@ pure fn each_const<T>(v: &[const T], f: fn(elem: &const T) -> bool) {
|
||||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn eachi<T>(v: &[T], f: fn(uint, T) -> bool) {
|
||||
do vec::as_imm_buf(v) |p, n| {
|
||||
let mut i = 0u;
|
||||
let mut p = p;
|
||||
while i < n {
|
||||
unsafe {
|
||||
if !f(i, *p) { break; }
|
||||
p = ptr::offset(p, 1u);
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
pure fn eachi<T>(v: &r/[T], f: fn(uint, v: &r/T) -> bool) {
|
||||
let mut i = 0;
|
||||
for each(v) |p| {
|
||||
if !f(i, p) { return; }
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1242,16 +1227,8 @@ pure fn eachi<T>(v: &[T], f: fn(uint, T) -> bool) {
|
||||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn reach<T>(v: &[T], blk: fn(T) -> bool) {
|
||||
do vec::as_imm_buf(v) |p, n| {
|
||||
let mut i = 1;
|
||||
while i <= n {
|
||||
unsafe {
|
||||
if !blk(*ptr::offset(p, n-i)) { break; }
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
pure fn rev_each<T>(v: &r/[T], blk: fn(v: &r/T) -> bool) {
|
||||
rev_eachi(v, |_i, v| blk(v))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1260,14 +1237,12 @@ pure fn reach<T>(v: &[T], blk: fn(T) -> bool) {
|
||||
* Return true to continue, false to break.
|
||||
*/
|
||||
#[inline(always)]
|
||||
pure fn reachi<T>(v: &[T], blk: fn(uint, T) -> bool) {
|
||||
do vec::as_imm_buf(v) |p, n| {
|
||||
let mut i = 1;
|
||||
while i <= n {
|
||||
unsafe {
|
||||
if !blk(n-i, *ptr::offset(p, n-i)) { break; }
|
||||
}
|
||||
i += 1;
|
||||
pure fn rev_eachi<T>(v: &r/[T], blk: fn(i: uint, v: &r/T) -> bool) {
|
||||
let mut i = v.len();
|
||||
while i > 0 {
|
||||
i -= 1;
|
||||
if !blk(i, &v[i]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1559,15 +1534,16 @@ mod traits {
|
||||
impl<T: Copy> ~[mut T]: Add<&[const T],~[mut T]> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: &[const T]) -> ~[mut T] {
|
||||
append_mut(self, rhs)
|
||||
append_mut(copy self, rhs)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
impl<T: Copy> ~[mut T] : Add<&[const T],~[mut T]> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: & &[const T]) -> ~[mut T] {
|
||||
append_mut(self, (*rhs))
|
||||
append_mut(copy self, (*rhs))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1624,8 +1600,8 @@ 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 map<U>(f: fn(T) -> U) -> ~[U];
|
||||
pure fn mapi<U>(f: fn(uint, T) -> U) -> ~[U];
|
||||
pure fn map<U>(f: fn(v: &T) -> U) -> ~[U];
|
||||
pure fn mapi<U>(f: fn(uint, v: &T) -> U) -> ~[U];
|
||||
fn map_r<U>(f: fn(x: &T) -> U) -> ~[U];
|
||||
pure fn alli(f: fn(uint, T) -> bool) -> bool;
|
||||
pure fn flat_map<U>(f: fn(T) -> ~[U]) -> ~[U];
|
||||
@ -1646,12 +1622,12 @@ impl<T> &[T]: ImmutableVector<T> {
|
||||
pure fn foldr<U: Copy>(z: U, p: fn(T, U) -> U) -> U { foldr(self, z, p) }
|
||||
/// 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) }
|
||||
pure fn map<U>(f: fn(v: &T) -> U) -> ~[U] { map(self, f) }
|
||||
/**
|
||||
* Apply a function to the index and value of each element in the vector
|
||||
* and return the results
|
||||
*/
|
||||
pure fn mapi<U>(f: fn(uint, T) -> U) -> ~[U] {
|
||||
pure fn mapi<U>(f: fn(uint, v: &T) -> U) -> ~[U] {
|
||||
mapi(self, f)
|
||||
}
|
||||
|
||||
@ -1779,8 +1755,7 @@ mod raw {
|
||||
*/
|
||||
#[inline(always)]
|
||||
unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] {
|
||||
let mut dst = ~[];
|
||||
reserve(dst, elts);
|
||||
let mut dst = with_capacity(elts);
|
||||
set_len(dst, elts);
|
||||
as_mut_buf(dst, |p_dst, _len_dst| ptr::memcpy(p_dst, ptr, elts));
|
||||
move dst
|
||||
@ -1972,6 +1947,7 @@ mod bytes {
|
||||
|
||||
impl<A> &[A]: iter::BaseIter<A> {
|
||||
pure fn each(blk: fn(v: &A) -> bool) {
|
||||
// FIXME(#2263)---should be able to call each(self, blk)
|
||||
for each(self) |e| {
|
||||
if (!blk(e)) {
|
||||
return;
|
||||
@ -1982,7 +1958,7 @@ impl<A> &[A]: iter::BaseIter<A> {
|
||||
}
|
||||
|
||||
impl<A> &[A]: iter::ExtendedIter<A> {
|
||||
pure fn eachi(blk: fn(uint, A) -> bool) { iter::eachi(self, blk) }
|
||||
pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(self, blk) }
|
||||
pure fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) }
|
||||
pure fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) }
|
||||
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
|
||||
@ -2002,7 +1978,7 @@ impl<A: Copy> &[A]: iter::CopyableIter<A> {
|
||||
pure fn filter_to_vec(pred: fn(A) -> bool) -> ~[A] {
|
||||
iter::filter_to_vec(self, pred)
|
||||
}
|
||||
pure fn map_to_vec<B>(op: fn(A) -> B) -> ~[B] {
|
||||
pure fn map_to_vec<B>(op: fn(v: &A) -> B) -> ~[B] {
|
||||
iter::map_to_vec(self, op)
|
||||
}
|
||||
pure fn to_vec() -> ~[A] { iter::to_vec(self) }
|
||||
@ -2027,7 +2003,7 @@ mod tests {
|
||||
|
||||
fn square(n: uint) -> uint { return n * n; }
|
||||
|
||||
fn square_ref(&&n: uint) -> uint { return n * n; }
|
||||
fn square_ref(n: &uint) -> uint { return square(*n); }
|
||||
|
||||
pure fn is_three(&&n: uint) -> bool { return n == 3u; }
|
||||
|
||||
@ -2260,7 +2236,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_grow_set() {
|
||||
let mut v = ~[mut 1, 2, 3];
|
||||
let mut v = ~[1, 2, 3];
|
||||
grow_set(v, 4u, 4, 5);
|
||||
assert (len(v) == 5u);
|
||||
assert (v[0] == 1);
|
||||
@ -2378,7 +2354,7 @@ mod tests {
|
||||
return option::Some::<int>(i / 2);
|
||||
} else { return option::None::<int>; }
|
||||
}
|
||||
fn halve_for_sure(&&i: int) -> int { return i / 2; }
|
||||
fn halve_for_sure(i: &int) -> int { return *i / 2; }
|
||||
let all_even: ~[int] = ~[0, 2, 8, 6];
|
||||
let all_odd1: ~[int] = ~[1, 7, 3];
|
||||
let all_odd2: ~[int] = ~[];
|
||||
@ -2449,26 +2425,26 @@ mod tests {
|
||||
fn test_iteri() {
|
||||
let mut i = 0;
|
||||
for eachi(~[1, 2, 3]) |j, v| {
|
||||
if i == 0 { assert v == 1; }
|
||||
assert j + 1u == v as uint;
|
||||
i += v;
|
||||
if i == 0 { assert *v == 1; }
|
||||
assert j + 1u == *v as uint;
|
||||
i += *v;
|
||||
}
|
||||
assert i == 6;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_reach_empty() {
|
||||
for reach::<int>(~[]) |_v| {
|
||||
for rev_each::<int>(~[]) |_v| {
|
||||
fail; // should never execute
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_riter_nonempty() {
|
||||
fn test_reach_nonempty() {
|
||||
let mut i = 0;
|
||||
for reach(~[1, 2, 3]) |v| {
|
||||
if i == 0 { assert v == 3; }
|
||||
i += v
|
||||
for rev_each(~[1, 2, 3]) |v| {
|
||||
if i == 0 { assert *v == 3; }
|
||||
i += *v
|
||||
}
|
||||
assert i == 6;
|
||||
}
|
||||
@ -2476,10 +2452,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_reachi() {
|
||||
let mut i = 0;
|
||||
for reachi(~[0, 1, 2]) |j, v| {
|
||||
if i == 0 { assert v == 2; }
|
||||
assert j == v as uint;
|
||||
i += v;
|
||||
for rev_eachi(~[0, 1, 2]) |j, v| {
|
||||
if i == 0 { assert *v == 2; }
|
||||
assert j == *v as uint;
|
||||
i += *v;
|
||||
}
|
||||
assert i == 3;
|
||||
}
|
||||
@ -2869,10 +2845,10 @@ mod tests {
|
||||
#[test]
|
||||
fn test_capacity() {
|
||||
let mut v = ~[0u64];
|
||||
reserve(v, 10u);
|
||||
reserve(&mut v, 10u);
|
||||
assert capacity(v) == 10u;
|
||||
let mut v = ~[0u32];
|
||||
reserve(v, 10u);
|
||||
reserve(&mut v, 10u);
|
||||
assert capacity(v) == 10u;
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,7 @@ impl ~[u8]: FromBase64 {
|
||||
if self[len - 2u] == '=' as u8 { padding += 1u; }
|
||||
}
|
||||
|
||||
let mut r = ~[];
|
||||
vec::reserve(r, (len / 4u) * 3u - padding);
|
||||
let mut r = vec::with_capacity((len / 4u) * 3u - padding);
|
||||
|
||||
let mut i = 0u;
|
||||
while i < len {
|
||||
|
@ -28,11 +28,11 @@ fn create<T: Copy>() -> Deque<T> {
|
||||
* Grow is only called on full elts, so nelts is also len(elts), unlike
|
||||
* elsewhere.
|
||||
*/
|
||||
fn grow<T: Copy>(nelts: uint, lo: uint, +elts: ~[mut Cell<T>])
|
||||
-> ~[mut Cell<T>] {
|
||||
let elts = move elts;
|
||||
fn grow<T: Copy>(nelts: uint, lo: uint, +elts: ~[Cell<T>])
|
||||
-> ~[Cell<T>] {
|
||||
let mut elts = move elts;
|
||||
assert (nelts == vec::len(elts));
|
||||
let mut rv = ~[mut];
|
||||
let mut rv = ~[];
|
||||
|
||||
let mut i = 0u;
|
||||
let nalloc = uint::next_power_of_two(nelts + 1u);
|
||||
@ -62,7 +62,7 @@ fn create<T: Copy>() -> Deque<T> {
|
||||
self.lo = self.elts.len() - 1u;
|
||||
} else { self.lo -= 1u; }
|
||||
if self.lo == self.hi {
|
||||
self.elts.swap_mut(|v| grow(self.nelts, oldlo, move v));
|
||||
self.elts.swap(|v| grow(self.nelts, oldlo, move v));
|
||||
self.lo = self.elts.len() - 1u;
|
||||
self.hi = self.nelts;
|
||||
}
|
||||
@ -71,7 +71,7 @@ fn create<T: Copy>() -> Deque<T> {
|
||||
}
|
||||
fn add_back(t: T) {
|
||||
if self.lo == self.hi && self.nelts != 0u {
|
||||
self.elts.swap_mut(|v| grow(self.nelts, self.lo, move v));
|
||||
self.elts.swap(|v| grow(self.nelts, self.lo, move v));
|
||||
self.lo = 0u;
|
||||
self.hi = self.nelts;
|
||||
}
|
||||
|
@ -391,13 +391,11 @@ fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, +key: K) -> bool {
|
||||
|
||||
/// Convert a set into a vector.
|
||||
fn vec_from_set<T:Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T] {
|
||||
let mut v = ~[];
|
||||
vec::reserve(v, s.size());
|
||||
do s.each_key() |k| {
|
||||
vec::push(v, k);
|
||||
true
|
||||
};
|
||||
v
|
||||
do vec::build_sized(s.size()) |push| {
|
||||
for s.each_key() |k| {
|
||||
push(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct a hashmap from a vector
|
||||
|
@ -156,7 +156,7 @@ mod v4 {
|
||||
}
|
||||
fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
|
||||
let parts = vec::map(str::split_char(ip, '.'), |s| {
|
||||
match uint::from_str(s) {
|
||||
match uint::from_str(*s) {
|
||||
Some(n) if n <= 255u => n,
|
||||
_ => 256u
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ fn map_slices<A: Copy Send, B: Copy Send>(
|
||||
fn map<A: Copy Send, B: Copy Send>(xs: ~[A], f: fn~(A) -> B) -> ~[B] {
|
||||
vec::concat(map_slices(xs, || {
|
||||
fn~(_base: uint, slice : &[A], copy f) -> ~[B] {
|
||||
vec::map(slice, |x| f(x))
|
||||
vec::map(slice, |x| f(*x))
|
||||
}
|
||||
}))
|
||||
}
|
||||
@ -87,7 +87,7 @@ fn mapi<A: Copy Send, B: Copy Send>(xs: ~[A],
|
||||
let slices = map_slices(xs, || {
|
||||
fn~(base: uint, slice : &[A], copy f) -> ~[B] {
|
||||
vec::mapi(slice, |i, x| {
|
||||
f(i + base, x)
|
||||
f(i + base, *x)
|
||||
})
|
||||
}
|
||||
});
|
||||
@ -109,7 +109,7 @@ fn mapi_factory<A: Copy Send, B: Copy Send>(
|
||||
let f = f();
|
||||
fn~(base: uint, slice : &[A], move f) -> ~[B] {
|
||||
vec::mapi(slice, |i, x| {
|
||||
f(i + base, x)
|
||||
f(i + base, *x)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
@ -864,7 +864,7 @@ mod node {
|
||||
fn bal(node: @Node) -> Option<@Node> {
|
||||
if height(node) < hint_max_node_height { return option::None; }
|
||||
//1. Gather all leaves as a forest
|
||||
let mut forest = ~[mut];
|
||||
let mut forest = ~[];
|
||||
let it = leaf_iterator::start(node);
|
||||
loop {
|
||||
match (leaf_iterator::next(&it)) {
|
||||
|
@ -85,7 +85,7 @@ fn emit_from_vec<S: Serializer, T>(s: S, v: ~[T], f: fn(T)) {
|
||||
do s.emit_vec(vec::len(v)) {
|
||||
for vec::eachi(v) |i,e| {
|
||||
do s.emit_vec_elt(i) {
|
||||
f(e)
|
||||
f(*e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,7 @@ fn merge_sort<T: Copy>(le: Le<T>, v: &[const T]) -> ~[T] {
|
||||
}
|
||||
|
||||
fn merge<T: Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
|
||||
let mut rs = ~[];
|
||||
vec::reserve(rs, len(a) + len(b));
|
||||
let mut rs = vec::with_capacity(len(a) + len(b));
|
||||
let a_len = len(a);
|
||||
let mut a_ix = 0u;
|
||||
let b_len = len(b);
|
||||
|
@ -80,11 +80,11 @@ fn new_sem<Q: Send>(count: int, +q: Q) -> Sem<Q> {
|
||||
#[doc(hidden)]
|
||||
fn new_sem_and_signal(count: int, num_condvars: uint)
|
||||
-> Sem<~[mut Waitqueue]> {
|
||||
let mut queues = ~[mut];
|
||||
let mut queues = ~[];
|
||||
for num_condvars.times {
|
||||
vec::push(queues, new_waitqueue());
|
||||
}
|
||||
new_sem(count, move queues)
|
||||
new_sem(count, vec::to_mut(move queues))
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
@ -58,7 +58,7 @@ type path = ~[path_elt];
|
||||
/* FIXMEs that say "bad" are as per #2543 */
|
||||
fn path_to_str_with_sep(p: path, sep: ~str, itr: ident_interner) -> ~str {
|
||||
let strs = do vec::map(p) |e| {
|
||||
match e {
|
||||
match *e {
|
||||
path_mod(s) => *itr.get(s),
|
||||
path_name(s) => *itr.get(s)
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ pure fn dummy_sp() -> span { return mk_sp(0u, 0u); }
|
||||
|
||||
pure fn path_name_i(idents: ~[ident], intr: token::ident_interner) -> ~str {
|
||||
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
|
||||
str::connect(idents.map(|i| *intr.get(i)), ~"::")
|
||||
str::connect(idents.map(|i| *intr.get(*i)), ~"::")
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,14 +95,14 @@ fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
|
||||
return mitems;
|
||||
}
|
||||
|
||||
fn desugar_doc_attr(attr: ast::attribute) -> ast::attribute {
|
||||
fn desugar_doc_attr(attr: &ast::attribute) -> ast::attribute {
|
||||
if attr.node.is_sugared_doc {
|
||||
let comment = get_meta_item_value_str(@attr.node.value).get();
|
||||
let meta = mk_name_value_item_str(~"doc",
|
||||
strip_doc_comment_decoration(comment));
|
||||
return mk_attr(meta);
|
||||
} else {
|
||||
attr
|
||||
*attr
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ impl ext_ctxt: ext_ctxt_helpers {
|
||||
-output: @ast::ty) -> @ast::ty {
|
||||
let args = do vec::map(input_tys) |ty| {
|
||||
{mode: ast::expl(ast::by_ref),
|
||||
ty: ty,
|
||||
ty: *ty,
|
||||
ident: parse::token::special_idents::invalid,
|
||||
id: self.next_id()}
|
||||
};
|
||||
@ -333,7 +333,7 @@ fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path,
|
||||
cx.helper_path(path, ~"serialize")));
|
||||
|
||||
let ty_args = do vec::map(path.types) |ty| {
|
||||
let sv_stmts = ser_ty(cx, tps, ty, cx.clone(s), #ast{ __v });
|
||||
let sv_stmts = ser_ty(cx, tps, *ty, cx.clone(s), #ast{ __v });
|
||||
let sv = cx.expr(path.span,
|
||||
ast::expr_block(cx.blk(path.span, sv_stmts)));
|
||||
cx.at(ty.span, #ast{ |__v| $(sv) })
|
||||
@ -588,7 +588,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident,
|
||||
vec::append(~[{ident: cx.ident_of(~"__S"),
|
||||
id: cx.next_id(),
|
||||
bounds: ser_bnds}],
|
||||
vec::map(tps, |tp| cx.clone_ty_param(tp)));
|
||||
vec::map(tps, |tp| cx.clone_ty_param(*tp)));
|
||||
|
||||
let ser_output: @ast::ty = @{id: cx.next_id(),
|
||||
node: ast::ty_nil,
|
||||
@ -624,7 +624,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path,
|
||||
cx.helper_path(path, ~"deserialize")));
|
||||
|
||||
let ty_args = do vec::map(path.types) |ty| {
|
||||
let dv_expr = deser_ty(cx, tps, ty, cx.clone(d));
|
||||
let dv_expr = deser_ty(cx, tps, *ty, cx.clone(d));
|
||||
cx.lambda(cx.expr_blk(dv_expr))
|
||||
};
|
||||
|
||||
@ -795,7 +795,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span,
|
||||
id: cx.next_id(),
|
||||
bounds: deser_bnds}],
|
||||
vec::map(tps, |tp| {
|
||||
let cloned = cx.clone_ty_param(tp);
|
||||
let cloned = cx.clone_ty_param(*tp);
|
||||
{bounds: @(vec::append(*cloned.bounds,
|
||||
~[ast::bound_copy])),
|
||||
.. cloned}
|
||||
|
@ -320,7 +320,7 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree])
|
||||
argument_gram).get(arg_nm) {
|
||||
@matched_seq(s, _) => {
|
||||
do s.map() |lf| {
|
||||
match lf {
|
||||
match *lf {
|
||||
@matched_nonterminal(parse::token::nt_expr(arg)) =>
|
||||
arg, /* whew! list of exprs, here we come! */
|
||||
_ => fail ~"badly-structured parse result"
|
||||
|
@ -265,7 +265,7 @@ impl ext_ctxt: ext_ctxt_ast_builder {
|
||||
fn variant(name: ident,
|
||||
span: span,
|
||||
+tys: ~[@ast::ty]) -> ast::variant {
|
||||
let args = tys.map(|ty| {ty: ty, id: self.next_id()});
|
||||
let args = tys.map(|ty| {ty: *ty, id: self.next_id()});
|
||||
|
||||
{node: {name: name,
|
||||
attrs: ~[],
|
||||
|
@ -91,7 +91,7 @@ impl message: gen_send {
|
||||
this.proto.name,
|
||||
self.name(),
|
||||
str::connect(vec::append_one(
|
||||
arg_names.map(|x| ~"move " + cx.str_of(x)),
|
||||
arg_names.map(|x| ~"move " + cx.str_of(*x)),
|
||||
~"move s"), ~", "));
|
||||
|
||||
if !try {
|
||||
@ -144,7 +144,7 @@ impl message: gen_send {
|
||||
~""
|
||||
}
|
||||
else {
|
||||
~"(" + str::connect(arg_names.map(|x| ~"move " + x),
|
||||
~"(" + str::connect(arg_names.map(|x| ~"move " + *x),
|
||||
~", ") + ~")"
|
||||
};
|
||||
|
||||
|
@ -224,10 +224,10 @@ fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
|
||||
// the copy keywords prevent recursive use of dvec
|
||||
let states = do (copy proto.states).map_to_vec |s| {
|
||||
let messages = do (copy s.messages).map_to_vec |m| {
|
||||
let message(name, span, tys, this, next) = m;
|
||||
let message(name, span, tys, this, next) = *m;
|
||||
visitor.visit_message(name, span, tys, this, next)
|
||||
};
|
||||
visitor.visit_state(s, messages)
|
||||
visitor.visit_state(*s, messages)
|
||||
};
|
||||
visitor.visit_proto(proto, states)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ enum fragment {
|
||||
}
|
||||
|
||||
fn ids_ext(cx: ext_ctxt, strs: ~[~str]) -> ~[ast::ident] {
|
||||
strs.map(|str| cx.parse_sess().interner.intern(@str))
|
||||
strs.map(|str| cx.parse_sess().interner.intern(@*str))
|
||||
}
|
||||
fn id_ext(cx: ext_ctxt, str: ~str) -> ast::ident {
|
||||
cx.parse_sess().interner.intern(@str)
|
||||
|
@ -262,11 +262,11 @@ fn wrong_occurs(cx: ext_ctxt, l: ident, l_c: uint, r: ident, r_c: uint)
|
||||
|
||||
/* handle sequences (anywhere in the AST) of exprs, either real or ...ed */
|
||||
fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
|
||||
recur: fn@(&&@expr) -> @expr,
|
||||
recur: fn@(&&v: @expr) -> @expr,
|
||||
exprs: ~[@expr]) -> ~[@expr] {
|
||||
match elts_to_ell(cx, exprs) {
|
||||
{pre: pre, rep: repeat_me_maybe, post: post} => {
|
||||
let mut res = vec::map(pre, recur);
|
||||
let mut res = vec::map(pre, |x| recur(*x));
|
||||
match repeat_me_maybe {
|
||||
None => (),
|
||||
Some(repeat_me) => {
|
||||
@ -314,7 +314,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint],
|
||||
}
|
||||
}
|
||||
}
|
||||
res = vec::append(res, vec::map(post, recur));
|
||||
res = vec::append(res, vec::map(post, |x| recur(*x)));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body)
|
||||
-> @ast::expr {
|
||||
get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"file");
|
||||
return mk_uniq_str(cx, sp,
|
||||
str::connect(cx.mod_path().map(|x| cx.str_of(x)), ~"::"));
|
||||
str::connect(cx.mod_path().map(
|
||||
|x| cx.str_of(*x)), ~"::"));
|
||||
}
|
||||
|
||||
fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
|
||||
@ -88,8 +89,8 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
|
||||
|
||||
match io::read_whole_file(&res_rel_file(cx, sp, &Path(file))) {
|
||||
result::Ok(src) => {
|
||||
let u8_exprs = vec::map(src, |char: u8| {
|
||||
mk_u8(cx, sp, char)
|
||||
let u8_exprs = vec::map(src, |char| {
|
||||
mk_u8(cx, sp, *char)
|
||||
});
|
||||
return mk_base_vec_e(cx, sp, u8_exprs);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident,
|
||||
let itr = cx.parse_sess().interner;
|
||||
|
||||
for lhses.eachi() |i, lhs| { // try each arm's matchers
|
||||
match lhs {
|
||||
match *lhs {
|
||||
@matched_nonterminal(nt_matchers(mtcs)) => {
|
||||
// `none` is because we're not interpolating
|
||||
let arg_rdr = new_tt_reader(s_d, itr, None, arg) as reader;
|
||||
|
@ -29,7 +29,7 @@ type tt_reader = @{
|
||||
mut cur: tt_frame,
|
||||
/* for MBE-style macro transcription */
|
||||
interpolations: std::map::HashMap<ident, @named_match>,
|
||||
mut repeat_idx: ~[mut uint],
|
||||
mut repeat_idx: ~[uint],
|
||||
mut repeat_len: ~[uint],
|
||||
/* cached: */
|
||||
mut cur_tok: token,
|
||||
@ -50,7 +50,8 @@ fn new_tt_reader(sp_diag: span_handler, itr: ident_interner,
|
||||
None => std::map::HashMap::<uint,@named_match>(),
|
||||
Some(x) => x
|
||||
},
|
||||
mut repeat_idx: ~[mut], mut repeat_len: ~[],
|
||||
mut repeat_idx: ~[],
|
||||
mut repeat_len: ~[],
|
||||
/* dummy values, never read: */
|
||||
mut cur_tok: EOF,
|
||||
mut cur_span: ast_util::mk_sp(0u,0u)
|
||||
|
@ -85,7 +85,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
|
||||
meta_list(id, mis) => {
|
||||
let fold_meta_item = |x|fold_meta_item_(x, fld);
|
||||
meta_list(/* FIXME: (#2543) */ copy id,
|
||||
vec::map(mis, fold_meta_item))
|
||||
vec::map(mis, |e| fold_meta_item(*e)))
|
||||
}
|
||||
meta_name_value(id, s) => {
|
||||
meta_name_value(id, /* FIXME (#2543) */ copy s)
|
||||
@ -125,7 +125,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
||||
}
|
||||
|
||||
fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
|
||||
return {inputs: vec::map(decl.inputs, |x| fold_arg_(x, fld) ),
|
||||
return {inputs: vec::map(decl.inputs, |x| fold_arg_(*x, fld) ),
|
||||
output: fld.fold_ty(decl.output),
|
||||
cf: decl.cf}
|
||||
}
|
||||
@ -140,11 +140,11 @@ fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound {
|
||||
fn fold_ty_param(tp: ty_param, fld: ast_fold) -> ty_param {
|
||||
{ident: /* FIXME (#2543) */ copy tp.ident,
|
||||
id: fld.new_id(tp.id),
|
||||
bounds: @vec::map(*tp.bounds, |x| fold_ty_param_bound(x, fld) )}
|
||||
bounds: @vec::map(*tp.bounds, |x| fold_ty_param_bound(*x, fld) )}
|
||||
}
|
||||
|
||||
fn fold_ty_params(tps: ~[ty_param], fld: ast_fold) -> ~[ty_param] {
|
||||
vec::map(tps, |x| fold_ty_param(x, fld) )
|
||||
vec::map(tps, |x| fold_ty_param(*x, fld) )
|
||||
}
|
||||
|
||||
fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
|
||||
@ -152,10 +152,10 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
|
||||
return {
|
||||
directives: vec::map(c.directives, |x| fld.fold_crate_directive(x)),
|
||||
directives: vec::map(c.directives, |x| fld.fold_crate_directive(*x)),
|
||||
module: fld.fold_mod(c.module),
|
||||
attrs: vec::map(c.attrs, fold_attribute),
|
||||
config: vec::map(c.config, fold_meta_item)
|
||||
attrs: vec::map(c.attrs, |x| fold_attribute(*x)),
|
||||
config: vec::map(c.config, |x| fold_meta_item(*x))
|
||||
};
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) ->
|
||||
}
|
||||
cdir_dir_mod(id, cds, attrs) => {
|
||||
cdir_dir_mod(fld.fold_ident(id),
|
||||
vec::map(cds, |x| fld.fold_crate_directive(x)),
|
||||
vec::map(cds, |x| fld.fold_crate_directive(*x)),
|
||||
/* FIXME (#2543) */ copy attrs)
|
||||
}
|
||||
cdir_view_item(vi) => cdir_view_item(fld.fold_view_item(vi)),
|
||||
@ -186,15 +186,16 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold)
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
|
||||
return @{ident: fld.fold_ident(ni.ident),
|
||||
attrs: vec::map(ni.attrs, fold_attribute),
|
||||
attrs: vec::map(ni.attrs, |x| fold_attribute(*x)),
|
||||
node:
|
||||
match ni.node {
|
||||
foreign_item_fn(fdec, purity, typms) => {
|
||||
foreign_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
|
||||
output: fld.fold_ty(fdec.output),
|
||||
cf: fdec.cf},
|
||||
purity,
|
||||
fold_ty_params(typms, fld))
|
||||
foreign_item_fn(
|
||||
{inputs: vec::map(fdec.inputs, |a| fold_arg(*a)),
|
||||
output: fld.fold_ty(fdec.output),
|
||||
cf: fdec.cf},
|
||||
purity,
|
||||
fold_ty_params(typms, fld))
|
||||
}
|
||||
foreign_item_const(t) => {
|
||||
foreign_item_const(fld.fold_ty(t))
|
||||
@ -208,7 +209,7 @@ fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> {
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
|
||||
return Some(@{ident: fld.fold_ident(i.ident),
|
||||
attrs: vec::map(i.attrs, fold_attribute),
|
||||
attrs: vec::map(i.attrs, |e| fold_attribute(*e)),
|
||||
id: fld.new_id(i.id),
|
||||
node: fld.fold_item_underscore(i.node),
|
||||
vis: i.vis,
|
||||
@ -239,7 +240,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
||||
item_enum(enum_definition, typms) => {
|
||||
item_enum(ast::enum_def({
|
||||
variants: vec::map(enum_definition.variants,
|
||||
|x| fld.fold_variant(x)),
|
||||
|x| fld.fold_variant(*x)),
|
||||
common: option::map(enum_definition.common,
|
||||
|x| fold_struct_def(x, fld))
|
||||
}), fold_ty_params(typms, fld))
|
||||
@ -252,11 +253,11 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
||||
item_impl(fold_ty_params(tps, fld),
|
||||
ifce.map(|p| fold_trait_ref(p, fld)),
|
||||
fld.fold_ty(ty),
|
||||
vec::map(methods, |x| fld.fold_method(x)))
|
||||
vec::map(methods, |x| fld.fold_method(*x)))
|
||||
}
|
||||
item_trait(tps, traits, methods) => {
|
||||
item_trait(fold_ty_params(tps, fld),
|
||||
vec::map(traits, |p| fold_trait_ref(p, fld)),
|
||||
vec::map(traits, |p| fold_trait_ref(*p, fld)),
|
||||
/* FIXME (#2543) */ copy methods)
|
||||
}
|
||||
item_mac(m) => {
|
||||
@ -292,9 +293,9 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
|
||||
id: dtor_id,.. dtor.node},
|
||||
.. dtor}};
|
||||
return @{
|
||||
traits: vec::map(struct_def.traits, |p| fold_trait_ref(p, fld)),
|
||||
fields: vec::map(struct_def.fields, |f| fold_struct_field(f, fld)),
|
||||
methods: vec::map(struct_def.methods, |m| fld.fold_method(m)),
|
||||
traits: vec::map(struct_def.traits, |p| fold_trait_ref(*p, fld)),
|
||||
fields: vec::map(struct_def.fields, |f| fold_struct_field(*f, fld)),
|
||||
methods: vec::map(struct_def.methods, |m| fld.fold_method(*m)),
|
||||
ctor: resulting_optional_constructor,
|
||||
dtor: dtor
|
||||
};
|
||||
@ -328,8 +329,8 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
|
||||
|
||||
|
||||
fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ {
|
||||
return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(x)),
|
||||
stmts: vec::map(b.stmts, |x| fld.fold_stmt(x)),
|
||||
return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(*x)),
|
||||
stmts: vec::map(b.stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(b.expr, |x| fld.fold_expr(x)),
|
||||
id: fld.new_id(b.id),
|
||||
rules: b.rules};
|
||||
@ -344,7 +345,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
|
||||
}
|
||||
|
||||
fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
|
||||
return {pats: vec::map(a.pats, |x| fld.fold_pat(x)),
|
||||
return {pats: vec::map(a.pats, |x| fld.fold_pat(*x)),
|
||||
guard: option::map(a.guard, |x| fld.fold_expr(x)),
|
||||
body: fld.fold_block(a.body)};
|
||||
}
|
||||
@ -360,7 +361,7 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
pat_lit(e) => pat_lit(fld.fold_expr(e)),
|
||||
pat_enum(pth, pats) => {
|
||||
pat_enum(fld.fold_path(pth), option::map(pats,
|
||||
|pats| vec::map(pats, |x| fld.fold_pat(x))))
|
||||
|pats| vec::map(pats, |x| fld.fold_pat(*x))))
|
||||
}
|
||||
pat_rec(fields, etc) => {
|
||||
let mut fs = ~[];
|
||||
@ -381,7 +382,7 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
}
|
||||
pat_struct(pth_, fs, etc)
|
||||
}
|
||||
pat_tup(elts) => pat_tup(vec::map(elts, |x| fld.fold_pat(x))),
|
||||
pat_tup(elts) => pat_tup(vec::map(elts, |x| fld.fold_pat(*x))),
|
||||
pat_box(inner) => pat_box(fld.fold_pat(inner)),
|
||||
pat_uniq(inner) => pat_uniq(fld.fold_pat(inner)),
|
||||
pat_region(inner) => pat_region(fld.fold_pat(inner)),
|
||||
@ -393,7 +394,7 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
|
||||
|
||||
fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ {
|
||||
match d {
|
||||
decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(x))),
|
||||
decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(*x))),
|
||||
decl_item(it) => match fld.fold_item(it) {
|
||||
Some(it_folded) => decl_item(it_folded),
|
||||
None => decl_local(~[])
|
||||
@ -431,10 +432,10 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
expr_repeat(expr, count, mutt) =>
|
||||
expr_repeat(fld.fold_expr(expr), fld.fold_expr(count), mutt),
|
||||
expr_rec(fields, maybe_expr) => {
|
||||
expr_rec(vec::map(fields, fold_field),
|
||||
expr_rec(vec::map(fields, |x| fold_field(*x)),
|
||||
option::map(maybe_expr, |x| fld.fold_expr(x)))
|
||||
}
|
||||
expr_tup(elts) => expr_tup(vec::map(elts, |x| fld.fold_expr(x))),
|
||||
expr_tup(elts) => expr_tup(vec::map(elts, |x| fld.fold_expr(*x))),
|
||||
expr_call(f, args, blk) => {
|
||||
expr_call(fld.fold_expr(f),
|
||||
fld.map_exprs(|x| fld.fold_expr(x), args),
|
||||
@ -462,20 +463,20 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
}
|
||||
expr_match(expr, arms) => {
|
||||
expr_match(fld.fold_expr(expr),
|
||||
vec::map(arms, |x| fld.fold_arm(x)))
|
||||
vec::map(arms, |x| fld.fold_arm(*x)))
|
||||
}
|
||||
expr_fn(proto, decl, body, captures) => {
|
||||
expr_fn(proto, fold_fn_decl(decl, fld),
|
||||
fld.fold_block(body),
|
||||
@((*captures).map(|cap_item| {
|
||||
@({id: fld.new_id((*cap_item).id),
|
||||
.. *cap_item})})))
|
||||
@({id: fld.new_id(cap_item.id),
|
||||
..**cap_item})})))
|
||||
}
|
||||
expr_fn_block(decl, body, captures) => {
|
||||
expr_fn_block(fold_fn_decl(decl, fld), fld.fold_block(body),
|
||||
@((*captures).map(|cap_item| {
|
||||
@({id: fld.new_id((*cap_item).id),
|
||||
.. *cap_item})})))
|
||||
@({id: fld.new_id(cap_item.id),
|
||||
..**cap_item})})))
|
||||
}
|
||||
expr_block(blk) => expr_block(fld.fold_block(blk)),
|
||||
expr_move(el, er) => {
|
||||
@ -494,7 +495,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
}
|
||||
expr_field(el, id, tys) => {
|
||||
expr_field(fld.fold_expr(el), fld.fold_ident(id),
|
||||
vec::map(tys, |x| fld.fold_ty(x)))
|
||||
vec::map(tys, |x| fld.fold_ty(*x)))
|
||||
}
|
||||
expr_index(el, er) => {
|
||||
expr_index(fld.fold_expr(el), fld.fold_expr(er))
|
||||
@ -512,7 +513,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
||||
expr_mac(mac) => expr_mac(fold_mac(mac)),
|
||||
expr_struct(path, fields, maybe_expr) => {
|
||||
expr_struct(fld.fold_path(path),
|
||||
vec::map(fields, fold_field),
|
||||
vec::map(fields, |x| fold_field(*x)),
|
||||
option::map(maybe_expr, |x| fld.fold_expr(x)))
|
||||
}
|
||||
}
|
||||
@ -535,13 +536,13 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
||||
ty_vec(mt) => ty_vec(fold_mt(mt, fld)),
|
||||
ty_ptr(mt) => ty_ptr(fold_mt(mt, fld)),
|
||||
ty_rptr(region, mt) => ty_rptr(region, fold_mt(mt, fld)),
|
||||
ty_rec(fields) => ty_rec(vec::map(fields, |f| fold_field(f, fld))),
|
||||
ty_rec(fields) => ty_rec(vec::map(fields, |f| fold_field(*f, fld))),
|
||||
ty_fn(proto, purity, bounds, decl) =>
|
||||
ty_fn(proto, purity,
|
||||
@vec::map(*bounds,
|
||||
|x| fold_ty_param_bound(x, fld)),
|
||||
|x| fold_ty_param_bound(*x, fld)),
|
||||
fold_fn_decl(decl, fld)),
|
||||
ty_tup(tys) => ty_tup(vec::map(tys, |ty| fld.fold_ty(ty))),
|
||||
ty_tup(tys) => ty_tup(vec::map(tys, |ty| fld.fold_ty(*ty))),
|
||||
ty_path(path, id) => ty_path(fld.fold_path(path), fld.new_id(id)),
|
||||
ty_fixed_length(t, vs) => ty_fixed_length(fld.fold_ty(t), vs),
|
||||
ty_mac(mac) => ty_mac(fold_mac(mac))
|
||||
@ -550,14 +551,14 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
|
||||
|
||||
// ...nor do modules
|
||||
fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
|
||||
return {view_items: vec::map(m.view_items, |x| fld.fold_view_item(x)),
|
||||
return {view_items: vec::map(m.view_items, |x| fld.fold_view_item(*x)),
|
||||
items: vec::filter_map(m.items, |x| fld.fold_item(x))};
|
||||
}
|
||||
|
||||
fn noop_fold_foreign_mod(nm: foreign_mod, fld: ast_fold) -> foreign_mod {
|
||||
return {sort: nm.sort,
|
||||
view_items: vec::map(nm.view_items, |x| fld.fold_view_item(x)),
|
||||
items: vec::map(nm.items, |x| fld.fold_foreign_item(x))}
|
||||
view_items: vec::map(nm.view_items, |x| fld.fold_view_item(*x)),
|
||||
items: vec::map(nm.items, |x| fld.fold_foreign_item(*x))}
|
||||
}
|
||||
|
||||
fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
@ -570,7 +571,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
match v.kind {
|
||||
tuple_variant_kind(variant_args) =>
|
||||
kind = tuple_variant_kind(vec::map(variant_args,
|
||||
fold_variant_arg)),
|
||||
|x| fold_variant_arg(*x))),
|
||||
struct_variant_kind(struct_def) => {
|
||||
let dtor = do option::map(struct_def.dtor) |dtor| {
|
||||
let dtor_body = fld.fold_block(dtor.node.body);
|
||||
@ -581,8 +582,9 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
kind = struct_variant_kind(@{
|
||||
traits: ~[],
|
||||
fields: vec::map(struct_def.fields,
|
||||
|f| fld.fold_struct_field(f)),
|
||||
methods: vec::map(struct_def.methods, |m| fld.fold_method(m)),
|
||||
|f| fld.fold_struct_field(*f)),
|
||||
methods: vec::map(struct_def.methods,
|
||||
|m| fld.fold_method(*m)),
|
||||
ctor: None,
|
||||
dtor: dtor
|
||||
})
|
||||
@ -590,7 +592,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
|
||||
enum_variant_kind(enum_definition) => {
|
||||
let variants = vec::map(enum_definition.variants,
|
||||
|x| fld.fold_variant(x));
|
||||
|x| fld.fold_variant(*x));
|
||||
let common = option::map(enum_definition.common,
|
||||
|x| fold_struct_def(x, fld));
|
||||
kind = enum_variant_kind(ast::enum_def({ variants: variants,
|
||||
@ -599,7 +601,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
||||
}
|
||||
|
||||
let fold_attribute = |x| fold_attribute_(x, fld);
|
||||
let attrs = vec::map(v.attrs, fold_attribute);
|
||||
let attrs = vec::map(v.attrs, |x| fold_attribute(*x));
|
||||
|
||||
let de = match v.disr_expr {
|
||||
Some(e) => Some(fld.fold_expr(e)),
|
||||
@ -619,9 +621,9 @@ fn noop_fold_ident(&&i: ident, _fld: ast_fold) -> ident {
|
||||
|
||||
fn noop_fold_path(&&p: path, fld: ast_fold) -> path {
|
||||
return {span: fld.new_span(p.span), global: p.global,
|
||||
idents: vec::map(p.idents, |x| fld.fold_ident(x)),
|
||||
idents: vec::map(p.idents, |x| fld.fold_ident(*x)),
|
||||
rp: p.rp,
|
||||
types: vec::map(p.types, |x| fld.fold_ty(x))};
|
||||
types: vec::map(p.types, |x| fld.fold_ty(*x))};
|
||||
}
|
||||
|
||||
fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
|
||||
@ -642,7 +644,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ {
|
||||
/* temporarily eta-expand because of a compiler bug with using `fn<T>` as a
|
||||
value */
|
||||
fn noop_map_exprs(f: fn@(&&@expr) -> @expr, es: ~[@expr]) -> ~[@expr] {
|
||||
return vec::map(es, f);
|
||||
return vec::map(es, |x| f(*x));
|
||||
}
|
||||
|
||||
fn noop_id(i: node_id) -> node_id { return i; }
|
||||
@ -692,7 +694,7 @@ impl ast_fold_precursor: ast_fold {
|
||||
@view_item {
|
||||
return @{node: self.fold_view_item(x.node, self as ast_fold),
|
||||
attrs: vec::map(x.attrs, |a|
|
||||
fold_attribute_(a, self as ast_fold)),
|
||||
fold_attribute_(*a, self as ast_fold)),
|
||||
vis: x.vis,
|
||||
span: self.new_span(x.span)};
|
||||
}
|
||||
@ -784,7 +786,7 @@ impl ast_fold_precursor: ast_fold {
|
||||
|
||||
impl ast_fold {
|
||||
fn fold_attributes(attrs: ~[attribute]) -> ~[attribute] {
|
||||
attrs.map(|x| fold_attribute_(x, self))
|
||||
attrs.map(|x| fold_attribute_(*x, self))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str {
|
||||
}
|
||||
|
||||
return do lines.map |line| {
|
||||
let chars = str::chars(line);
|
||||
let chars = str::chars(*line);
|
||||
if i > chars.len() {
|
||||
~""
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ fn get_rpaths_relative_to_output(os: session::os,
|
||||
output: &Path,
|
||||
libs: &[Path]) -> ~[Path] {
|
||||
vec::map(libs, |a| {
|
||||
get_rpath_relative_to_output(os, output, &a)
|
||||
get_rpath_relative_to_output(os, output, a)
|
||||
})
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
|
||||
}
|
||||
|
||||
fn get_absolute_rpaths(libs: &[Path]) -> ~[Path] {
|
||||
vec::map(libs, |a| get_absolute_rpath(&a) )
|
||||
vec::map(libs, |a| get_absolute_rpath(a) )
|
||||
}
|
||||
|
||||
fn get_absolute_rpath(lib: &Path) -> Path {
|
||||
|
@ -553,7 +553,7 @@ fn build_session_options(binary: ~str,
|
||||
|
||||
let addl_lib_search_paths =
|
||||
getopts::opt_strs(matches, ~"L")
|
||||
.map(|s| Path(s));
|
||||
.map(|s| Path(*s));
|
||||
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"));
|
||||
let test = opt_present(matches, ~"test");
|
||||
let sopts: @session::options =
|
||||
|
@ -55,7 +55,7 @@ fn fold_mod(cx: ctxt, m: ast::_mod, fld: fold::ast_fold) ->
|
||||
let view_item_filter = |a| filter_view_item(cx, a);
|
||||
let filtered_view_items = vec::filter_map(m.view_items, view_item_filter);
|
||||
return {
|
||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)),
|
||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
||||
items: vec::filter_map(filtered_items, |x| fld.fold_item(x))
|
||||
};
|
||||
}
|
||||
@ -76,7 +76,7 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
|
||||
nm.view_items, view_item_filter);
|
||||
return {
|
||||
sort: nm.sort,
|
||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(x)),
|
||||
view_items: vec::map(filtered_view_items, |x| fld.fold_view_item(*x)),
|
||||
items: filtered_items
|
||||
};
|
||||
}
|
||||
@ -103,7 +103,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
|
||||
let filter = |a| filter_stmt(cx, a);
|
||||
let filtered_stmts = vec::filter_map(b.stmts, filter);
|
||||
return {view_items: b.view_items,
|
||||
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(x)),
|
||||
stmts: vec::map(filtered_stmts, |x| fld.fold_stmt(*x)),
|
||||
expr: option::map(b.expr, |x| fld.fold_expr(x)),
|
||||
id: b.id,
|
||||
rules: b.rules};
|
||||
|
@ -63,9 +63,9 @@ fn warn_if_multiple_versions(e: env, diag: span_handler,
|
||||
partition(crate_cache.map_to_vec(|entry| {
|
||||
let othername = loader::crate_name_from_metas(*entry.metas);
|
||||
if name == othername {
|
||||
Left(entry)
|
||||
Left(*entry)
|
||||
} else {
|
||||
Right(entry)
|
||||
Right(*entry)
|
||||
}
|
||||
}));
|
||||
|
||||
|
@ -171,7 +171,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[~str] {
|
||||
for sorted.each |x| {
|
||||
debug!(" hash[%s]: %s", x.name, x.hash);
|
||||
}
|
||||
fn mapper(ch: crate_hash) -> ~str { return ch.hash; }
|
||||
fn mapper(ch: &crate_hash) -> ~str { return ch.hash; }
|
||||
return vec::map(sorted, mapper);
|
||||
}
|
||||
|
||||
|
@ -283,9 +283,7 @@ fn item_path(intr: ident_interner, item_doc: ebml::Doc) -> ast_map::path {
|
||||
let len_doc = ebml::get_doc(path_doc, tag_path_len);
|
||||
let len = ebml::doc_as_u32(len_doc) as uint;
|
||||
|
||||
let mut result = ~[];
|
||||
vec::reserve(result, len);
|
||||
|
||||
let mut result = vec::with_capacity(len);
|
||||
for ebml::docs(path_doc) |tag, elt_doc| {
|
||||
if tag == tag_path_elt_mod {
|
||||
let str = ebml::doc_as_str(elt_doc);
|
||||
|
@ -1026,7 +1026,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer,
|
||||
type numdep = decoder::crate_dep;
|
||||
|
||||
// Pull the cnums and name,vers,hash out of cstore
|
||||
let mut deps: ~[mut numdep] = ~[mut];
|
||||
let mut deps: ~[numdep] = ~[];
|
||||
do cstore::iter_crate_data(cstore) |key, val| {
|
||||
let dep = {cnum: key, name: ecx.tcx.sess.ident_of(val.name),
|
||||
vers: decoder::get_crate_vers(val.data),
|
||||
|
@ -81,7 +81,7 @@ fn raw_pat(p: @pat) -> @pat {
|
||||
|
||||
fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
|
||||
assert(pats.is_not_empty());
|
||||
let ext = match is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) {
|
||||
let ext = match is_useful(tcx, vec::map(pats, |p| ~[*p]), ~[wild()]) {
|
||||
not_useful => return, // This is good, wildcard pattern isn't reachable
|
||||
useful_ => None,
|
||||
useful(ty, ctor) => {
|
||||
|
@ -83,7 +83,7 @@ fn classify(e: @expr,
|
||||
|
||||
ast::expr_tup(es) |
|
||||
ast::expr_vec(es, ast::m_imm) => {
|
||||
join_all(vec::map(es, |e| classify(e, def_map, tcx)))
|
||||
join_all(vec::map(es, |e| classify(*e, def_map, tcx)))
|
||||
}
|
||||
|
||||
ast::expr_vstore(e, vstore) => {
|
||||
|
@ -1287,7 +1287,7 @@ impl Resolver {
|
||||
|
||||
for full_path.idents.eachi |i, ident| {
|
||||
if i != path_len - 1u {
|
||||
(*module_path).push(ident);
|
||||
(*module_path).push(*ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3762,8 +3762,8 @@ impl Resolver {
|
||||
fn check_consistent_bindings(arm: arm) {
|
||||
if arm.pats.len() == 0 { return; }
|
||||
let map_0 = self.binding_mode_map(arm.pats[0]);
|
||||
for arm.pats.eachi() |i, p: @pat| {
|
||||
let map_i = self.binding_mode_map(p);
|
||||
for arm.pats.eachi() |i, p| {
|
||||
let map_i = self.binding_mode_map(*p);
|
||||
|
||||
for map_0.each |key, binding_0| {
|
||||
match map_i.find(key) {
|
||||
@ -3894,7 +3894,7 @@ impl Resolver {
|
||||
debug!("(resolving type) writing resolution for `%s` \
|
||||
(id %d)",
|
||||
connect(path.idents.map(
|
||||
|x| self.session.str_of(x)), ~"::"),
|
||||
|x| self.session.str_of(*x)), ~"::"),
|
||||
path_id);
|
||||
self.record_def(path_id, def);
|
||||
}
|
||||
@ -3902,7 +3902,7 @@ impl Resolver {
|
||||
self.session.span_err
|
||||
(ty.span, fmt!("use of undeclared type name `%s`",
|
||||
connect(path.idents.map(
|
||||
|x| self.session.str_of(x)),
|
||||
|x| self.session.str_of(*x)),
|
||||
~"::")));
|
||||
}
|
||||
}
|
||||
@ -4080,7 +4080,7 @@ impl Resolver {
|
||||
path.span,
|
||||
fmt!("`%s` does not name a structure",
|
||||
connect(path.idents.map(
|
||||
|x| self.session.str_of(x)),
|
||||
|x| self.session.str_of(*x)),
|
||||
~"::")));
|
||||
}
|
||||
}
|
||||
@ -4256,7 +4256,7 @@ impl Resolver {
|
||||
break;
|
||||
}
|
||||
|
||||
(*module_path_atoms).push(ident);
|
||||
(*module_path_atoms).push(*ident);
|
||||
}
|
||||
|
||||
return module_path_atoms;
|
||||
@ -4482,13 +4482,13 @@ impl Resolver {
|
||||
// Write the result into the def map.
|
||||
debug!("(resolving expr) resolved `%s`",
|
||||
connect(path.idents.map(
|
||||
|x| self.session.str_of(x)), ~"::"));
|
||||
|x| self.session.str_of(*x)), ~"::"));
|
||||
self.record_def(expr.id, def);
|
||||
}
|
||||
None => {
|
||||
let wrong_name =
|
||||
connect(path.idents.map(
|
||||
|x| self.session.str_of(x)), ~"::") ;
|
||||
|x| self.session.str_of(*x)), ~"::") ;
|
||||
if self.name_exists_in_scope_class(wrong_name) {
|
||||
self.session.span_err(expr.span,
|
||||
fmt!("unresolved name: `%s`. \
|
||||
@ -4550,7 +4550,7 @@ impl Resolver {
|
||||
path.span,
|
||||
fmt!("`%s` does not name a structure",
|
||||
connect(path.idents.map(
|
||||
|x| self.session.str_of(x)),
|
||||
|x| self.session.str_of(*x)),
|
||||
~"::")));
|
||||
}
|
||||
}
|
||||
|
@ -210,14 +210,14 @@ struct Match {
|
||||
fn match_to_str(bcx: block, m: &Match) -> ~str {
|
||||
if bcx.sess().verbose() {
|
||||
// for many programs, this just take too long to serialize
|
||||
fmt!("%?", m.pats.map(|p| pat_to_str(p, bcx.sess().intr())))
|
||||
fmt!("%?", m.pats.map(|p| pat_to_str(*p, bcx.sess().intr())))
|
||||
} else {
|
||||
fmt!("%u pats", m.pats.len())
|
||||
}
|
||||
}
|
||||
|
||||
fn matches_to_str(bcx: block, m: &[@Match]) -> ~str {
|
||||
fmt!("%?", m.map(|n| match_to_str(bcx, n)))
|
||||
fmt!("%?", m.map(|n| match_to_str(bcx, *n)))
|
||||
}
|
||||
|
||||
fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
|
||||
@ -256,7 +256,7 @@ fn expand_nested_bindings(bcx: block, m: &[@Match/&r],
|
||||
@Match {pats: pats, data: br.data}
|
||||
}
|
||||
_ => {
|
||||
br
|
||||
*br
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -789,7 +789,7 @@ fn compile_guard(bcx: block,
|
||||
bcx.to_str(),
|
||||
bcx.expr_to_str(guard_expr),
|
||||
matches_to_str(bcx, m),
|
||||
vals.map(|v| bcx.val_str(v)));
|
||||
vals.map(|v| bcx.val_str(*v)));
|
||||
let _indenter = indenter();
|
||||
|
||||
let mut bcx = bcx;
|
||||
@ -840,7 +840,7 @@ fn compile_submatch(bcx: block,
|
||||
debug!("compile_submatch(bcx=%s, m=%s, vals=%?)",
|
||||
bcx.to_str(),
|
||||
matches_to_str(bcx, m),
|
||||
vals.map(|v| bcx.val_str(v)));
|
||||
vals.map(|v| bcx.val_str(*v)));
|
||||
let _indenter = indenter();
|
||||
|
||||
/*
|
||||
@ -895,7 +895,7 @@ fn compile_submatch(bcx: block,
|
||||
let pat_ty = node_id_type(bcx, pat_id);
|
||||
do expr::with_field_tys(tcx, pat_ty) |_has_dtor, field_tys| {
|
||||
let rec_vals = rec_fields.map(|field_name| {
|
||||
let ix = ty::field_idx_strict(tcx, field_name, field_tys);
|
||||
let ix = ty::field_idx_strict(tcx, *field_name, field_tys);
|
||||
GEPi(bcx, val, struct_field(ix))
|
||||
});
|
||||
compile_submatch(
|
||||
@ -1227,7 +1227,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
||||
for sub_pats.each |sub_pat| {
|
||||
for vec::eachi(args.vals) |i, argval| {
|
||||
bcx = bind_irrefutable_pat(bcx, sub_pat[i],
|
||||
argval, make_copy);
|
||||
*argval, make_copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1245,7 +1245,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
||||
ast::pat_tup(elems) => {
|
||||
for vec::eachi(elems) |i, elem| {
|
||||
let fldptr = GEPi(bcx, val, [0u, i]);
|
||||
bcx = bind_irrefutable_pat(bcx, elem, fldptr, make_copy);
|
||||
bcx = bind_irrefutable_pat(bcx, *elem, fldptr, make_copy);
|
||||
}
|
||||
}
|
||||
ast::pat_box(inner) | ast::pat_uniq(inner) |
|
||||
|
@ -206,7 +206,7 @@ fn GEP_enum(bcx: block, llblobptr: ValueRef, enum_id: ast::def_id,
|
||||
assert ix < variant.args.len();
|
||||
|
||||
let arg_lltys = vec::map(variant.args, |aty| {
|
||||
type_of(ccx, ty::subst_tps(ccx.tcx, ty_substs, aty))
|
||||
type_of(ccx, ty::subst_tps(ccx.tcx, ty_substs, *aty))
|
||||
});
|
||||
let typed_blobptr = PointerCast(bcx, llblobptr,
|
||||
T_ptr(T_struct(arg_lltys)));
|
||||
@ -560,7 +560,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t,
|
||||
ty::ty_tup(args) => {
|
||||
for vec::eachi(args) |i, arg| {
|
||||
let llfld_a = GEPi(cx, av, [0u, i]);
|
||||
cx = f(cx, llfld_a, arg);
|
||||
cx = f(cx, llfld_a, *arg);
|
||||
}
|
||||
}
|
||||
ty::ty_enum(tid, substs) => {
|
||||
@ -1113,17 +1113,17 @@ 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;
|
||||
for vec::reach(cleanups) |cu| {
|
||||
match cu {
|
||||
clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => {
|
||||
for vec::rev_each(cleanups) |cu| {
|
||||
match *cu {
|
||||
clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => {
|
||||
// Some types don't need to be cleaned up during
|
||||
// landing pads because they can be freed en mass later
|
||||
if cleanup_type == normal_exit_and_unwind || !is_lpad {
|
||||
bcx = cfn(bcx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return bcx;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ fn Invoke(cx: block, Fn: ValueRef, Args: ~[ValueRef],
|
||||
cx.terminated = true;
|
||||
debug!("Invoke(%s with arguments (%s))",
|
||||
val_str(cx.ccx().tn, Fn),
|
||||
str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, a)),
|
||||
str::connect(vec::map(Args, |a| val_str(cx.ccx().tn, *a)),
|
||||
~", "));
|
||||
unsafe {
|
||||
count_insn(cx, "invoke");
|
||||
@ -677,7 +677,7 @@ fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
|
||||
|
||||
debug!("Call(Fn=%s, Args=%?)",
|
||||
val_str(cx.ccx().tn, Fn),
|
||||
Args.map(|arg| val_str(cx.ccx().tn, arg)));
|
||||
Args.map(|arg| val_str(cx.ccx().tn, *arg)));
|
||||
|
||||
do vec::as_imm_buf(Args) |ptr, len| {
|
||||
llvm::LLVMBuildCall(B(cx), Fn, ptr, len as c_uint, noname())
|
||||
|
@ -174,7 +174,7 @@ fn trans_fn_ref_with_vtables(
|
||||
debug!("trans_fn_ref_with_vtables(bcx=%s, def_id=%?, ref_id=%?, \
|
||||
type_params=%?, vtables=%?)",
|
||||
bcx.to_str(), def_id, ref_id,
|
||||
type_params.map(|t| bcx.ty_to_str(t)),
|
||||
type_params.map(|t| bcx.ty_to_str(*t)),
|
||||
vtables);
|
||||
let _indenter = indenter();
|
||||
|
||||
@ -454,7 +454,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
|
||||
let last = arg_exprs.len() - 1u;
|
||||
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,
|
||||
trans_arg_expr(bcx, arg_tys[i], *arg_expr, &mut temp_cleanups,
|
||||
if i == last { ret_flag } else { None },
|
||||
autoref_arg)
|
||||
});
|
||||
|
@ -192,9 +192,9 @@ type param_substs = {tys: ~[ty::t],
|
||||
|
||||
fn param_substs_to_str(tcx: ty::ctxt, substs: ¶m_substs) -> ~str {
|
||||
fmt!("param_substs {tys:%?, vtables:%?, bounds:%?}",
|
||||
substs.tys.map(|t| ty_to_str(tcx, t)),
|
||||
substs.tys.map(|t| ty_to_str(tcx, *t)),
|
||||
substs.vtables.map(|vs| vs.map(|v| v.to_str(tcx))),
|
||||
substs.bounds.map(|b| ty::param_bounds_to_str(tcx, b)))
|
||||
substs.bounds.map(|b| ty::param_bounds_to_str(tcx, *b)))
|
||||
}
|
||||
|
||||
// Function context. Every LLVM function we create will have one of
|
||||
@ -1265,7 +1265,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
|
||||
let params = ty::node_id_to_type_params(tcx, id);
|
||||
match bcx.fcx.param_substs {
|
||||
Some(substs) => {
|
||||
vec::map(params, |t| ty::subst_tps(tcx, substs.tys, t))
|
||||
vec::map(params, |t| ty::subst_tps(tcx, substs.tys, *t))
|
||||
}
|
||||
_ => params
|
||||
}
|
||||
@ -1280,7 +1280,7 @@ fn node_vtables(bcx: block, id: ast::node_id) -> Option<typeck::vtable_res> {
|
||||
fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res)
|
||||
-> typeck::vtable_res
|
||||
{
|
||||
@vec::map(*vts, |d| resolve_vtable_in_fn_ctxt(fcx, d))
|
||||
@vec::map(*vts, |d| resolve_vtable_in_fn_ctxt(fcx, *d))
|
||||
}
|
||||
|
||||
// Apply the typaram substitutions in the fn_ctxt to a vtable. This should
|
||||
@ -1293,7 +1293,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
|
||||
typeck::vtable_static(trait_id, tys, sub) => {
|
||||
let tys = match fcx.param_substs {
|
||||
Some(substs) => {
|
||||
vec::map(tys, |t| ty::subst_tps(tcx, substs.tys, t))
|
||||
vec::map(tys, |t| ty::subst_tps(tcx, substs.tys, *t))
|
||||
}
|
||||
_ => tys
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ fn const_vec(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr])
|
||||
let vec_ty = ty::expr_ty(cx.tcx, e);
|
||||
let unit_ty = ty::sequence_element_type(cx.tcx, vec_ty);
|
||||
let llunitty = type_of::type_of(cx, unit_ty);
|
||||
let v = C_array(llunitty, es.map(|e| const_expr(cx, e)));
|
||||
let v = C_array(llunitty, es.map(|e| const_expr(cx, *e)));
|
||||
let unit_sz = shape::llsize_of(cx, llunitty);
|
||||
let sz = llvm::LLVMConstMul(C_uint(cx, es.len()), unit_sz);
|
||||
return (v, sz, llunitty);
|
||||
@ -286,7 +286,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
||||
gv
|
||||
}
|
||||
ast::expr_tup(es) => {
|
||||
C_struct(es.map(|e| const_expr(cx, e)))
|
||||
C_struct(es.map(|e| const_expr(cx, *e)))
|
||||
}
|
||||
ast::expr_rec(fs, None) => {
|
||||
C_struct([C_struct(
|
||||
|
@ -1057,8 +1057,8 @@ fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: Dest) -> block {
|
||||
let mut temp_cleanups = ~[];
|
||||
for vec::eachi(elts) |i, e| {
|
||||
let dest = GEPi(bcx, addr, [0u, i]);
|
||||
let e_ty = expr_ty(bcx, e);
|
||||
bcx = trans_into(bcx, e, SaveIn(dest));
|
||||
let e_ty = expr_ty(bcx, *e);
|
||||
bcx = trans_into(bcx, *e, SaveIn(dest));
|
||||
add_clean_temp_mem(bcx, dest, e_ty);
|
||||
vec::push(temp_cleanups, dest);
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ fn decl_x86_64_fn(tys: x86_64_tys,
|
||||
let llfn = decl(fnty);
|
||||
|
||||
for vec::eachi(tys.attrs) |i, a| {
|
||||
match a {
|
||||
match *a {
|
||||
option::Some(attr) => {
|
||||
let llarg = get_param(llfn, i);
|
||||
llvm::LLVMAddAttribute(llarg, attr as c_uint);
|
||||
@ -650,7 +650,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
||||
match tys.x86_64_tys {
|
||||
Some(x86_64) => {
|
||||
for vec::eachi(x86_64.attrs) |i, a| {
|
||||
match a {
|
||||
match *a {
|
||||
Some(attr) => {
|
||||
llvm::LLVMAddInstrAttribute(
|
||||
llretval, (i + 1u) as c_uint,
|
||||
|
@ -330,9 +330,9 @@ fn combine_impl_and_methods_tps(bcx: block,
|
||||
vec::tailn(node_substs,
|
||||
node_substs.len() - n_m_tps));
|
||||
debug!("n_m_tps=%?", n_m_tps);
|
||||
debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(t)));
|
||||
debug!("node_substs=%?", node_substs.map(|t| bcx.ty_to_str(t)));
|
||||
debug!("ty_substs=%?", ty_substs.map(|t| bcx.ty_to_str(t)));
|
||||
debug!("rcvr_substs=%?", rcvr_substs.map(|t| bcx.ty_to_str(*t)));
|
||||
debug!("node_substs=%?", node_substs.map(|t| bcx.ty_to_str(*t)));
|
||||
debug!("ty_substs=%?", ty_substs.map(|t| bcx.ty_to_str(*t)));
|
||||
|
||||
return ty_substs;
|
||||
}
|
||||
@ -462,7 +462,7 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id {
|
||||
}
|
||||
typeck::vtable_trait(trait_id, substs) => {
|
||||
@{def: trait_id,
|
||||
params: vec::map(substs, |t| mono_precise(t, None))}
|
||||
params: vec::map(substs, |t| mono_precise(*t, None))}
|
||||
}
|
||||
// can't this be checked at the callee?
|
||||
_ => fail ~"vtable_id"
|
||||
|
@ -22,9 +22,9 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
let _icx = ccx.insn_ctxt("monomorphic_fn");
|
||||
let mut must_cast = false;
|
||||
let substs = vec::map(real_substs, |t| {
|
||||
match normalize_for_monomorphization(ccx.tcx, t) {
|
||||
match normalize_for_monomorphization(ccx.tcx, *t) {
|
||||
Some(t) => { must_cast = true; t }
|
||||
None => t
|
||||
None => *t
|
||||
}
|
||||
});
|
||||
|
||||
@ -40,8 +40,8 @@ fn monomorphic_fn(ccx: @crate_ctxt,
|
||||
#debug["monomorphic_fn(fn_id=%? (%s), real_substs=%?, substs=%?, \
|
||||
hash_id = %?",
|
||||
fn_id, ty::item_path_str(ccx.tcx, fn_id),
|
||||
real_substs.map(|s| ty_to_str(ccx.tcx, s)),
|
||||
substs.map(|s| ty_to_str(ccx.tcx, s)), hash_id];
|
||||
real_substs.map(|s| ty_to_str(ccx.tcx, *s)),
|
||||
substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id];
|
||||
|
||||
match ccx.monomorphized.find(hash_id) {
|
||||
Some(val) => {
|
||||
@ -256,7 +256,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||
})
|
||||
}
|
||||
None => {
|
||||
vec::map(substs, |subst| (subst, None))
|
||||
vec::map(substs, |subst| (*subst, None))
|
||||
}
|
||||
};
|
||||
let param_ids = match param_uses {
|
||||
@ -298,8 +298,12 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t],
|
||||
}
|
||||
})
|
||||
}
|
||||
None => precise_param_ids.map(|x| { let (a, b) = x;
|
||||
mono_precise(a, b) })
|
||||
None => {
|
||||
precise_param_ids.map(|x| {
|
||||
let (a, b) = *x;
|
||||
mono_precise(a, b)
|
||||
})
|
||||
}
|
||||
};
|
||||
@{def: item, params: param_ids}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ impl reflector {
|
||||
debug!("passing %u args:", vec::len(args));
|
||||
let bcx = self.bcx;
|
||||
for args.eachi |i, a| {
|
||||
debug!("arg %u: %s", i, val_str(bcx.ccx().tn, a));
|
||||
debug!("arg %u: %s", i, val_str(bcx.ccx().tn, *a));
|
||||
}
|
||||
let bool_ty = ty::mk_bool(tcx);
|
||||
let scratch = scratch_datum(bcx, bool_ty, false);
|
||||
@ -171,7 +171,7 @@ impl reflector {
|
||||
for tys.eachi |i, t| {
|
||||
self.visit(~"tup_field",
|
||||
~[self.c_uint(i),
|
||||
self.c_tydesc(t)]);
|
||||
self.c_tydesc(*t)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,7 +263,7 @@ impl reflector {
|
||||
for v.args.eachi |j, a| {
|
||||
self.visit(~"enum_variant_field",
|
||||
~[self.c_uint(j),
|
||||
self.c_tydesc(a)]);
|
||||
self.c_tydesc(*a)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ impl nominal_id_ : to_bytes::IterBytes {
|
||||
fn mk_nominal_id(tcx: ty::ctxt, did: ast::def_id,
|
||||
parent_id: Option<ast::def_id>,
|
||||
tps: ~[ty::t]) -> nominal_id {
|
||||
let tps_norm = tps.map(|t| ty::normalize_ty(tcx, t));
|
||||
let tps_norm = tps.map(|t| ty::normalize_ty(tcx, *t));
|
||||
@{did: did, parent_id: parent_id, tps: tps_norm}
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ fn write_content(bcx: block,
|
||||
let lleltptr = GEPi(bcx, lldest, [i]);
|
||||
debug!("writing index %? with lleltptr=%?",
|
||||
i, bcx.val_str(lleltptr));
|
||||
bcx = expr::trans_into(bcx, element,
|
||||
bcx = expr::trans_into(bcx, *element,
|
||||
SaveIn(lleltptr));
|
||||
add_clean_temp_mem(bcx, lleltptr, vt.unit_ty);
|
||||
vec::push(temp_cleanups, lleltptr);
|
||||
|
@ -31,7 +31,7 @@ fn type_of_explicit_arg(ccx: @crate_ctxt, arg: ty::arg) -> TypeRef {
|
||||
}
|
||||
|
||||
fn type_of_explicit_args(ccx: @crate_ctxt, inputs: ~[ty::arg]) -> ~[TypeRef] {
|
||||
inputs.map(|arg| type_of_explicit_arg(ccx, arg))
|
||||
inputs.map(|arg| type_of_explicit_arg(ccx, *arg))
|
||||
}
|
||||
|
||||
fn type_of_fn(cx: @crate_ctxt, inputs: ~[ty::arg],
|
||||
|
@ -1235,7 +1235,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||
fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs {
|
||||
{self_r: substs.self_r,
|
||||
self_ty: substs.self_ty.map(|t| fldop(t)),
|
||||
tps: substs.tps.map(|t| fldop(t))}
|
||||
tps: substs.tps.map(|t| fldop(*t))}
|
||||
}
|
||||
|
||||
match *sty {
|
||||
@ -1269,7 +1269,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||
ty_rec(new_fields)
|
||||
}
|
||||
ty_tup(ts) => {
|
||||
let new_ts = vec::map(ts, |tt| fldop(tt));
|
||||
let new_ts = vec::map(ts, |tt| fldop(*tt));
|
||||
ty_tup(new_ts)
|
||||
}
|
||||
ty_fn(ref f) => {
|
||||
@ -1332,7 +1332,7 @@ fn fold_regions_and_ty(
|
||||
|
||||
{self_r: substs.self_r.map(|r| fldr(r)),
|
||||
self_ty: substs.self_ty.map(|t| fldt(t)),
|
||||
tps: substs.tps.map(|t| fldt(t))}
|
||||
tps: substs.tps.map(|t| fldt(*t))}
|
||||
}
|
||||
|
||||
let tb = ty::get(ty);
|
||||
@ -1476,7 +1476,7 @@ fn param_bound_to_str(cx: ctxt, pb: ¶m_bound) -> ~str {
|
||||
}
|
||||
|
||||
fn param_bounds_to_str(cx: ctxt, pbs: param_bounds) -> ~str {
|
||||
fmt!("%?", pbs.map(|pb| param_bound_to_str(cx, &pb)))
|
||||
fmt!("%?", pbs.map(|pb| param_bound_to_str(cx, pb)))
|
||||
}
|
||||
|
||||
fn subst(cx: ctxt,
|
||||
@ -3487,11 +3487,11 @@ fn substd_enum_variants(cx: ctxt,
|
||||
substs: &substs) -> ~[variant_info] {
|
||||
do vec::map(*enum_variants(cx, id)) |variant_info| {
|
||||
let substd_args = vec::map(variant_info.args,
|
||||
|aty| subst(cx, substs, aty));
|
||||
|aty| subst(cx, substs, *aty));
|
||||
|
||||
let substd_ctor_ty = subst(cx, substs, variant_info.ctor_ty);
|
||||
|
||||
@{args: substd_args, ctor_ty: substd_ctor_ty,.. *variant_info}
|
||||
@{args: substd_args, ctor_ty: substd_ctor_ty, ..**variant_info}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ impl vtable_origin {
|
||||
vtable_trait(def_id, ref tys) => {
|
||||
fmt!("vtable_trait(%?:%s, %?)",
|
||||
def_id, ty::item_path_str(tcx, def_id),
|
||||
tys.map(|t| ty_to_str(tcx, t)))
|
||||
tys.map(|t| ty_to_str(tcx, *t)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ fn write_substs_to_tcx(tcx: ty::ctxt,
|
||||
+substs: ~[ty::t]) {
|
||||
if substs.len() > 0u {
|
||||
debug!("write_substs_to_tcx(%d, %?)", node_id,
|
||||
substs.map(|t| ty_to_str(tcx, t)));
|
||||
substs.map(|t| ty_to_str(tcx, *t)));
|
||||
tcx.node_type_substs.insert(node_id, substs);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Owned>(
|
||||
fmt!("wrong number of type arguments: expected %u but found %u",
|
||||
(*decl_bounds).len(), path.types.len()));
|
||||
}
|
||||
let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, a_t));
|
||||
let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, *a_t));
|
||||
|
||||
let substs = {self_r:self_r, self_ty:None, tps:tps};
|
||||
{substs: substs, ty: ty::subst(tcx, &substs, decl_ty)}
|
||||
@ -295,7 +295,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Owned>(
|
||||
|tmt| ty::mk_rptr(tcx, r, tmt))
|
||||
}
|
||||
ast::ty_tup(fields) => {
|
||||
let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, t));
|
||||
let flds = vec::map(fields, |t| ast_ty_to_ty(self, rscope, *t));
|
||||
ty::mk_tup(tcx, flds)
|
||||
}
|
||||
ast::ty_rec(fields) => {
|
||||
@ -489,7 +489,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope Copy Owned>(
|
||||
// were supplied
|
||||
if i < e.inputs.len() {Some(e.inputs[i])} else {None}
|
||||
};
|
||||
ty_of_arg(self, rb, a, expected_arg_ty)
|
||||
ty_of_arg(self, rb, *a, expected_arg_ty)
|
||||
};
|
||||
|
||||
let expected_ret_ty = expected_tys.map(|e| e.output);
|
||||
|
@ -237,7 +237,7 @@ fn check_fn(ccx: @crate_ctxt,
|
||||
let ret_ty = fn_ty.sig.output;
|
||||
|
||||
debug!("check_fn(arg_tys=%?, ret_ty=%?, self_info.self_ty=%?)",
|
||||
arg_tys.map(|a| ty_to_str(tcx, a)),
|
||||
arg_tys.map(|a| ty_to_str(tcx, *a)),
|
||||
ty_to_str(tcx, ret_ty),
|
||||
option::map(self_info, |s| ty_to_str(tcx, s.self_ty)));
|
||||
|
||||
@ -1067,8 +1067,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
}
|
||||
|
||||
bot |= check_expr_with_unifier(
|
||||
fcx, arg, Some(formal_ty),
|
||||
|| demand::assign(fcx, arg.span, formal_ty, arg)
|
||||
fcx, *arg, Some(formal_ty),
|
||||
|| demand::assign(fcx, arg.span, formal_ty, *arg)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1419,7 +1419,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
_ => ()
|
||||
}
|
||||
|
||||
let tps = vec::map(tys, |ty| fcx.to_ty(ty));
|
||||
let tps = vec::map(tys, |ty| fcx.to_ty(*ty));
|
||||
|
||||
match method::lookup(fcx, expr, base, expr.id,
|
||||
field, expr_t, tps) {
|
||||
@ -1853,16 +1853,13 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
fcx.write_ty(id, t);
|
||||
}
|
||||
ast::expr_tup(elts) => {
|
||||
let mut elt_ts = ~[];
|
||||
vec::reserve(elt_ts, vec::len(elts));
|
||||
let flds = unpack_expected(fcx, expected, |sty| {
|
||||
match sty { ty::ty_tup(flds) => Some(flds), _ => None }
|
||||
});
|
||||
for elts.eachi |i, e| {
|
||||
check_expr(fcx, e, flds.map(|fs| fs[i]));
|
||||
let ety = fcx.expr_ty(e);
|
||||
vec::push(elt_ts, ety);
|
||||
}
|
||||
let elt_ts = do elts.mapi |i, e| {
|
||||
check_expr(fcx, *e, flds.map(|fs| fs[i]));
|
||||
fcx.expr_ty(*e)
|
||||
};
|
||||
let typ = ty::mk_tup(tcx, elt_ts);
|
||||
fcx.write_ty(id, typ);
|
||||
}
|
||||
@ -1886,7 +1883,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||
});
|
||||
match base {
|
||||
None => {
|
||||
fn get_node(f: spanned<field>) -> field { f.node }
|
||||
fn get_node(f: &spanned<field>) -> field { f.node }
|
||||
let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node));
|
||||
fcx.write_ty(id, typ);
|
||||
/* Check for duplicate fields */
|
||||
@ -2491,7 +2488,7 @@ fn instantiate_path(fcx: @fn_ctxt,
|
||||
(span, ~"not enough type parameters provided for this item");
|
||||
fcx.infcx().next_ty_vars(ty_param_count)
|
||||
} else {
|
||||
pth.types.map(|aty| fcx.to_ty(aty))
|
||||
pth.types.map(|aty| fcx.to_ty(*aty))
|
||||
};
|
||||
|
||||
let substs = {self_r: self_r, self_ty: None, tps: tps};
|
||||
@ -2576,7 +2573,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
|
||||
});
|
||||
|
||||
for tps_used.eachi |i, b| {
|
||||
if !b {
|
||||
if !*b {
|
||||
ccx.tcx.sess.span_err(
|
||||
span, fmt!("type parameter `%s` is unused",
|
||||
ccx.tcx.sess.str_of(tps[i].ident)));
|
||||
|
@ -145,7 +145,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
||||
let vinfo =
|
||||
ty::enum_variant_with_id(
|
||||
tcx, v_def_ids.enm, v_def_ids.var);
|
||||
vinfo.args.map(|t| { ty::subst(tcx, expected_substs, t) })
|
||||
vinfo.args.map(|t| { ty::subst(tcx, expected_substs, *t) })
|
||||
};
|
||||
let arg_len = arg_types.len(), subpats_len = match subpats {
|
||||
None => arg_len,
|
||||
|
@ -39,7 +39,7 @@ fn replace_bound_regions_in_fn_ty(
|
||||
all_tys=%?)",
|
||||
self_ty.map(|t| ty_to_str(tcx, t)),
|
||||
ty_to_str(tcx, ty::mk_fn(tcx, *fn_ty)),
|
||||
all_tys.map(|t| ty_to_str(tcx, t)));
|
||||
all_tys.map(|t| ty_to_str(tcx, *t)));
|
||||
let _i = indenter();
|
||||
|
||||
let isr = do create_bound_region_mapping(tcx, isr, all_tys) |br| {
|
||||
|
@ -164,7 +164,7 @@ fn get_enum_variant_types(ccx: @crate_ctxt,
|
||||
|
||||
fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) {
|
||||
fn store_methods<T>(ccx: @crate_ctxt, id: ast::node_id,
|
||||
stuff: ~[T], f: fn@(T) -> ty::method) {
|
||||
stuff: ~[T], f: fn@(v: &T) -> ty::method) {
|
||||
ty::store_trait_methods(ccx.tcx, id, @vec::map(stuff, f));
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) {
|
||||
ast_map::node_item(@{node: ast::item_trait(params, _, ms), _}, _) => {
|
||||
store_methods::<ast::trait_method>(ccx, id, ms, |m| {
|
||||
let trait_bounds = ty_param_bounds(ccx, params);
|
||||
let ty_m = trait_method_to_ty_method(m);
|
||||
let ty_m = trait_method_to_ty_method(*m);
|
||||
let method_ty = ty_of_ty_method(ccx, ty_m, region_paramd);
|
||||
if ty_m.self_ty.node == ast::sty_static {
|
||||
make_static_method_ty(ccx, ty_m, region_paramd,
|
||||
@ -226,7 +226,7 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) {
|
||||
// All methods need to be stored, since lookup_method
|
||||
// relies on the same method cache for self-calls
|
||||
store_methods::<@ast::method>(ccx, id, struct_def.methods, |m| {
|
||||
ty_of_method(ccx, m, region_paramd)
|
||||
ty_of_method(ccx, *m, region_paramd)
|
||||
});
|
||||
}
|
||||
_ => { /* Ignore things that aren't traits or classes */ }
|
||||
@ -413,7 +413,7 @@ fn convert_methods(ccx: @crate_ctxt,
|
||||
let tcx = ccx.tcx;
|
||||
do vec::map(ms) |m| {
|
||||
let bounds = ty_param_bounds(ccx, m.tps);
|
||||
let mty = ty_of_method(ccx, m, rp);
|
||||
let mty = ty_of_method(ccx, *m, rp);
|
||||
let fty = ty::mk_fn(tcx, mty.fty);
|
||||
tcx.tcache.insert(
|
||||
local_def(m.id),
|
||||
@ -500,7 +500,7 @@ fn convert_struct(ccx: @crate_ctxt,
|
||||
do option::iter(struct_def.ctor) |ctor| {
|
||||
// Write the ctor type
|
||||
let t_args = ctor.node.dec.inputs.map(
|
||||
|a| ty_of_arg(ccx, type_rscope(rp), a, None) );
|
||||
|a| ty_of_arg(ccx, type_rscope(rp), *a, None) );
|
||||
let t_res = ty::mk_class(
|
||||
tcx, local_def(id),
|
||||
{self_r: rscope::bound_self_region(rp),
|
||||
@ -772,7 +772,7 @@ fn ty_of_foreign_fn_decl(ccx: @crate_ctxt,
|
||||
|
||||
let bounds = ty_param_bounds(ccx, ty_params);
|
||||
let rb = in_binding_rscope(empty_rscope);
|
||||
let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, rb, a, None) );
|
||||
let input_tys = decl.inputs.map(|a| ty_of_arg(ccx, rb, *a, None) );
|
||||
let output_ty = ast_ty_to_ty(ccx, rb, decl.output);
|
||||
|
||||
let t_fn = ty::mk_fn(ccx.tcx, FnTyBase {
|
||||
|
@ -877,8 +877,7 @@ impl RegionVarBindings {
|
||||
});
|
||||
|
||||
// It would be nice to write this using map():
|
||||
let mut edges = ~[];
|
||||
vec::reserve(edges, num_edges);
|
||||
let mut edges = vec::with_capacity(num_edges);
|
||||
for self.constraints.each_ref |constraint, span| {
|
||||
vec::push(edges, GraphEdge {
|
||||
next_edge: [mut uint::max_value, uint::max_value],
|
||||
|
@ -139,10 +139,7 @@ impl Sub: combine {
|
||||
// anything to do with the region variable that's created
|
||||
// for it. The only thing we're doing with `br` here is
|
||||
// using it in the debug message.
|
||||
//
|
||||
// NDM--we should not be used dummy_sp() here, but
|
||||
// rather passing in the span or something like that.
|
||||
let rvar = self.infcx.next_region_var_nb(dummy_sp());
|
||||
let rvar = self.infcx.next_region_var_nb(self.span);
|
||||
debug!("Bound region %s maps to %s",
|
||||
bound_region_to_str(self.infcx.tcx, br),
|
||||
region_to_str(self.infcx.tcx, rvar));
|
||||
|
@ -236,7 +236,7 @@ fn expr_repr(cx: ctxt, expr: @ast::expr) -> ~str {
|
||||
}
|
||||
|
||||
fn tys_to_str(cx: ctxt, ts: ~[t]) -> ~str {
|
||||
let tstrs = ts.map(|t| ty_to_str(cx, t));
|
||||
let tstrs = ts.map(|t| ty_to_str(cx, *t));
|
||||
fmt!("[%s]", str::connect(tstrs, ", "))
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ fn parameterized(cx: ctxt,
|
||||
};
|
||||
|
||||
if vec::len(tps) > 0u {
|
||||
let strs = vec::map(tps, |t| ty_to_str(cx, t) );
|
||||
let strs = vec::map(tps, |t| ty_to_str(cx, *t));
|
||||
fmt!("%s%s<%s>", base, r_str, str::connect(strs, ~","))
|
||||
} else {
|
||||
fmt!("%s%s", base, r_str)
|
||||
|
@ -209,7 +209,7 @@ fn merge_method_attrs(
|
||||
node: ast::item_trait(_, _, methods), _
|
||||
}, _) => {
|
||||
vec::map(methods, |method| {
|
||||
match method {
|
||||
match *method {
|
||||
ast::required(ty_m) => {
|
||||
(to_str(ty_m.ident), attr_parser::parse_desc(ty_m.attrs))
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ fn variantdocs_from_variants(
|
||||
vec::map(variants, variantdoc_from_variant)
|
||||
}
|
||||
|
||||
fn variantdoc_from_variant(variant: ast::variant) -> doc::VariantDoc {
|
||||
fn variantdoc_from_variant(variant: &ast::variant) -> doc::VariantDoc {
|
||||
|
||||
{
|
||||
name: to_str(variant.node.name),
|
||||
@ -218,7 +218,7 @@ fn traitdoc_from_trait(
|
||||
{
|
||||
item: itemdoc,
|
||||
methods: do vec::map(methods) |method| {
|
||||
match method {
|
||||
match *method {
|
||||
ast::required(ty_m) => {
|
||||
{
|
||||
name: to_str(ty_m.ident),
|
||||
|
@ -143,7 +143,7 @@ fn default_par_fold<T:Send Copy>(ctxt: T) -> Fold<T> {
|
||||
fn default_seq_fold_doc<T>(fold: Fold<T>, doc: doc::Doc) -> doc::Doc {
|
||||
doc::Doc_({
|
||||
pages: do vec::map(doc.pages) |page| {
|
||||
match page {
|
||||
match *page {
|
||||
doc::CratePage(doc) => {
|
||||
doc::CratePage(fold.fold_crate(fold, doc))
|
||||
}
|
||||
@ -192,7 +192,7 @@ fn default_seq_fold_mod<T>(
|
||||
doc::ModDoc_({
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
items: vec::map(doc.items, |ItemTag| {
|
||||
fold_ItemTag(fold, ItemTag)
|
||||
fold_ItemTag(fold, *ItemTag)
|
||||
}),
|
||||
.. *doc
|
||||
})
|
||||
@ -231,7 +231,7 @@ fn default_seq_fold_nmod<T>(
|
||||
{
|
||||
item: fold.fold_item(fold, doc.item),
|
||||
fns: vec::map(doc.fns, |FnDoc| {
|
||||
fold.fold_fn(fold, FnDoc)
|
||||
fold.fold_fn(fold, *FnDoc)
|
||||
}),
|
||||
.. doc
|
||||
}
|
||||
|
@ -88,15 +88,15 @@ fn write_markdown(
|
||||
// we don't want to spawn too many pandoc processes
|
||||
do doc.pages.map |page| {
|
||||
let ctxt = {
|
||||
w: writer_factory(page)
|
||||
w: writer_factory(*page)
|
||||
};
|
||||
write_page(ctxt, page)
|
||||
};
|
||||
}
|
||||
|
||||
fn write_page(ctxt: Ctxt, page: doc::Page) {
|
||||
write_title(ctxt, page);
|
||||
match page {
|
||||
fn write_page(ctxt: Ctxt, page: &doc::Page) {
|
||||
write_title(ctxt, *page);
|
||||
match *page {
|
||||
doc::CratePage(doc) => {
|
||||
write_crate(ctxt, doc);
|
||||
}
|
||||
@ -236,7 +236,7 @@ fn header_name(doc: doc::ItemTag) -> ~str {
|
||||
} else {
|
||||
trait_part += ~", ";
|
||||
}
|
||||
trait_part += trait_type;
|
||||
trait_part += *trait_type;
|
||||
}
|
||||
fmt!("%s for %s", trait_part, self_ty)
|
||||
}
|
||||
@ -513,7 +513,7 @@ fn write_sig(ctxt: Ctxt, sig: Option<~str>) {
|
||||
|
||||
fn code_block_indent(s: ~str) -> ~str {
|
||||
let lines = str::lines_any(s);
|
||||
let indented = vec::map(lines, |line| fmt!(" %s", line) );
|
||||
let indented = vec::map(lines, |line| fmt!(" %s", *line) );
|
||||
str::connect(indented, ~"\n")
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,9 @@ fn main(args: ~[~str]) {
|
||||
|
||||
// check each vector
|
||||
assert raw_v.len() == max;
|
||||
for raw_v.eachi |i, v| { assert i == v; }
|
||||
for raw_v.eachi |i, v| { assert i == *v; }
|
||||
assert dvec_v.len() == max;
|
||||
for dvec_v.eachi |i, v| { assert i == v; }
|
||||
for dvec_v.eachi |i, v| { assert i == *v; }
|
||||
|
||||
let raw = mid - start;
|
||||
let dvec = end - mid;
|
||||
|
@ -85,7 +85,7 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
|
||||
}
|
||||
|
||||
do graph.map() |v| {
|
||||
map::vec_from_set(v)
|
||||
map::vec_from_set(*v)
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
||||
log(info, fmt!("PBFS iteration %?", i));
|
||||
i += 1u;
|
||||
colors = do colors.mapi() |i, c| {
|
||||
let c : color = c;
|
||||
let c : color = *c;
|
||||
match c {
|
||||
white => {
|
||||
let i = i as node_id;
|
||||
@ -200,7 +200,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
||||
|
||||
// Convert the results.
|
||||
do vec::map(colors) |c| {
|
||||
match c {
|
||||
match *c {
|
||||
white => { -1i64 }
|
||||
black(parent) => { parent }
|
||||
_ => { fail ~"Found remaining gray nodes in BFS" }
|
||||
@ -305,7 +305,7 @@ fn validate(edges: ~[(node_id, node_id)],
|
||||
|
||||
let mut status = true;
|
||||
let level = do tree.map() |parent| {
|
||||
let mut parent = parent;
|
||||
let mut parent = *parent;
|
||||
let mut path = ~[];
|
||||
|
||||
if parent == -1i64 {
|
||||
@ -427,7 +427,7 @@ fn main(args: ~[~str]) {
|
||||
|
||||
if do_sequential {
|
||||
let start = time::precise_time_s();
|
||||
let bfs_tree = bfs(graph, root);
|
||||
let bfs_tree = bfs(graph, *root);
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
//total_seq += stop - start;
|
||||
@ -438,7 +438,7 @@ fn main(args: ~[~str]) {
|
||||
|
||||
if do_validate {
|
||||
let start = time::precise_time_s();
|
||||
assert(validate(edges, root, bfs_tree));
|
||||
assert(validate(edges, *root, bfs_tree));
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
io::stdout().write_line(
|
||||
@ -447,7 +447,7 @@ fn main(args: ~[~str]) {
|
||||
}
|
||||
|
||||
let start = time::precise_time_s();
|
||||
let bfs_tree = bfs2(graph, root);
|
||||
let bfs_tree = bfs2(graph, *root);
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
total_seq += stop - start;
|
||||
@ -458,7 +458,7 @@ fn main(args: ~[~str]) {
|
||||
|
||||
if do_validate {
|
||||
let start = time::precise_time_s();
|
||||
assert(validate(edges, root, bfs_tree));
|
||||
assert(validate(edges, *root, bfs_tree));
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
io::stdout().write_line(
|
||||
@ -468,7 +468,7 @@ fn main(args: ~[~str]) {
|
||||
}
|
||||
|
||||
let start = time::precise_time_s();
|
||||
let bfs_tree = pbfs(graph_arc, root);
|
||||
let bfs_tree = pbfs(graph_arc, *root);
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
total_par += stop - start;
|
||||
@ -478,7 +478,7 @@ fn main(args: ~[~str]) {
|
||||
|
||||
if do_validate {
|
||||
let start = time::precise_time_s();
|
||||
assert(validate(edges, root, bfs_tree));
|
||||
assert(validate(edges, *root, bfs_tree));
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
io::stdout().write_line(fmt!("Validation completed in %? seconds.",
|
||||
|
@ -31,7 +31,7 @@ fn show_color_list(set: ~[color]) -> ~str {
|
||||
let mut out = ~"";
|
||||
for vec::eachi(set) |_ii, col| {
|
||||
out += ~" ";
|
||||
out += show_color(col);
|
||||
out += show_color(*col);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@ -131,16 +131,16 @@ fn rendezvous(nn: uint, set: ~[color]) {
|
||||
|
||||
// these channels will allow us to talk to each creature by 'name'/index
|
||||
let to_creature: ~[comm::Chan<Option<creature_info>>] =
|
||||
vec::mapi(set,
|
||||
fn@(ii: uint, col: color) -> comm::Chan<Option<creature_info>> {
|
||||
// create each creature as a listener with a port, and
|
||||
// give us a channel to talk to each
|
||||
return do task::spawn_listener |from_rendezvous| {
|
||||
creature(ii, col, from_rendezvous, to_rendezvous,
|
||||
to_rendezvous_log);
|
||||
};
|
||||
vec::mapi(set, |ii, col| {
|
||||
// create each creature as a listener with a port, and
|
||||
// give us a channel to talk to each
|
||||
let ii = ii;
|
||||
let col = *col;
|
||||
do task::spawn_listener |from_rendezvous, move ii, move col| {
|
||||
creature(ii, col, from_rendezvous, to_rendezvous,
|
||||
to_rendezvous_log);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
let mut creatures_met = 0;
|
||||
|
||||
@ -157,7 +157,7 @@ fn rendezvous(nn: uint, set: ~[color]) {
|
||||
|
||||
// tell each creature to stop
|
||||
for vec::eachi(to_creature) |_ii, to_one| {
|
||||
comm::send(to_one, None);
|
||||
comm::send(*to_one, None);
|
||||
}
|
||||
|
||||
// save each creature's meeting stats
|
||||
|
@ -147,6 +147,7 @@ fn main(args: ~[~str]) {
|
||||
let streams = vec::to_mut(streams);
|
||||
let mut from_child = ~[];
|
||||
let to_child = vec::mapi(sizes, |ii, sz| {
|
||||
let sz = *sz;
|
||||
let mut stream = None;
|
||||
stream <-> streams[ii];
|
||||
let (to_parent_, from_child_) = option::unwrap(stream);
|
||||
|
@ -142,13 +142,14 @@ fn main(args: ~[~str]) {
|
||||
let sizes = ~[1u,2u,3u,4u,6u,12u,18u];
|
||||
let from_child = vec::map (sizes, |_sz| comm::Port() );
|
||||
let to_parent = vec::mapi(sizes, |ii, _sz| comm::Chan(from_child[ii]) );
|
||||
let to_child = vec::mapi(sizes, fn@(ii: uint, sz: uint) -> comm::Chan<~[u8]> {
|
||||
return do task::spawn_listener |from_parent| {
|
||||
let to_child = vec::mapi(sizes, |ii, sz| {
|
||||
let ii = ii;
|
||||
let sz = *sz;
|
||||
do task::spawn_listener |from_parent| {
|
||||
make_sequence_processor(sz, from_parent, to_parent[ii]);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// latch stores true after we've started
|
||||
// reading the sequence of interest
|
||||
let mut proc_mode = false;
|
||||
|
@ -299,8 +299,10 @@ fn main(argv: ~[~str]) {
|
||||
}
|
||||
|
||||
let readers: ~[fn~() -> word_reader] = if argv.len() >= 2 {
|
||||
vec::view(argv, 1u, argv.len()).map(
|
||||
|f| fn~() -> word_reader { file_word_reader(f) } )
|
||||
vec::view(argv, 1u, argv.len()).map(|f| {
|
||||
let f = *f;
|
||||
fn~() -> word_reader { file_word_reader(f) }
|
||||
})
|
||||
}
|
||||
else {
|
||||
let num_readers = 50;
|
||||
|
@ -16,7 +16,7 @@ fn main() {
|
||||
assert any_negative;
|
||||
|
||||
// Higher precedence than unary operations:
|
||||
let abs_v = do vec::map(v) |e| { float::abs(e) };
|
||||
let abs_v = do vec::map(v) |e| { float::abs(*e) };
|
||||
assert do vec::all(abs_v) |e| { float::is_nonnegative(e) };
|
||||
assert !do vec::any(abs_v) |e| { float::is_negative(e) };
|
||||
|
||||
|
@ -20,7 +20,7 @@ fn main() {
|
||||
assert d.len() == exp.len();
|
||||
|
||||
for d.eachi |i, e| {
|
||||
assert e == exp[i];
|
||||
assert *e == exp[i];
|
||||
}
|
||||
|
||||
let v = dvec::unwrap(move d);
|
||||
|
@ -54,7 +54,7 @@ fn add_interfaces(store: int, managed_ip: ~str, device: std::map::HashMap<~str,
|
||||
std::json::List(interfaces) =>
|
||||
{
|
||||
do vec::map(*interfaces) |interface| {
|
||||
add_interface(store, managed_ip, interface)
|
||||
add_interface(store, managed_ip, *interface)
|
||||
}
|
||||
}
|
||||
_ =>
|
||||
|
@ -1,7 +1,7 @@
|
||||
fn main() {
|
||||
let mut c = 0u;
|
||||
for [1u, 2u, 3u, 4u, 5u]/_.eachi |i, v| {
|
||||
assert (i + 1u) == v;
|
||||
assert (i + 1u) == *v;
|
||||
c += 1u;
|
||||
}
|
||||
assert c == 5u;
|
||||
@ -10,7 +10,7 @@ fn main() {
|
||||
|
||||
let mut c = 0u;
|
||||
for Some(1u).eachi |i, v| {
|
||||
assert (i + 1u) == v;
|
||||
assert (i + 1u) == *v;
|
||||
c += 1u;
|
||||
}
|
||||
assert c == 1u;
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn inc(&&x: uint) -> uint { x + 1u }
|
||||
fn inc(x: &uint) -> uint { *x + 1u }
|
||||
|
||||
fn main() {
|
||||
assert [1u, 3u]/_.map_to_vec(inc) == ~[2u, 4u];
|
||||
|
Loading…
x
Reference in New Issue
Block a user