Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

De-mode vec::map, vec::eachi, vec::rev_each, vec::rev_eachi

  • Loading branch information...
commit 3d59ac3a1989c2d233b04cc8adc9b058690c2544 1 parent f3c31a0
@nikomatsakis nikomatsakis authored
Showing with 408 additions and 427 deletions.
  1. +3 −3 doc/tutorial.md
  2. +3 −3 src/cargo/cargo.rs
  3. +3 −4 src/libcore/dlist.rs
  4. +22 −8 src/libcore/dvec.rs
  5. +4 −5 src/libcore/io.rs
  6. +2 −2 src/libcore/iter-trait.rs
  7. +6 −6 src/libcore/iter.rs
  8. +2 −3 src/libcore/os.rs
  9. +2 −4 src/libcore/result.rs
  10. +6 −9 src/libcore/str.rs
  11. +93 −117 src/libcore/vec.rs
  12. +1 −2  src/libstd/base64.rs
  13. +6 −6 src/libstd/deque.rs
  14. +5 −7 src/libstd/map.rs
  15. +1 −1  src/libstd/net_ip.rs
  16. +3 −3 src/libstd/par.rs
  17. +1 −1  src/libstd/rope.rs
  18. +1 −1  src/libstd/serialization.rs
  19. +1 −2  src/libstd/sort.rs
  20. +2 −2 src/libstd/sync.rs
  21. +1 −1  src/libsyntax/ast_map.rs
  22. +1 −1  src/libsyntax/ast_util.rs
  23. +2 −2 src/libsyntax/attr.rs
  24. +5 −5 src/libsyntax/ext/auto_serialize.rs
  25. +1 −1  src/libsyntax/ext/base.rs
  26. +1 −1  src/libsyntax/ext/pipes/ast_builder.rs
  27. +2 −2 src/libsyntax/ext/pipes/pipec.rs
  28. +2 −2 src/libsyntax/ext/pipes/proto.rs
  29. +1 −1  src/libsyntax/ext/qquote.rs
  30. +3 −3 src/libsyntax/ext/simplext.rs
  31. +4 −3 src/libsyntax/ext/source_util.rs
  32. +1 −1  src/libsyntax/ext/tt/macro_rules.rs
  33. +3 −2 src/libsyntax/ext/tt/transcribe.rs
  34. +54 −52 src/libsyntax/fold.rs
  35. +1 −1  src/libsyntax/parse/comments.rs
  36. +2 −2 src/rustc/back/rpath.rs
  37. +1 −1  src/rustc/driver/driver.rs
  38. +3 −3 src/rustc/front/config.rs
  39. +2 −2 src/rustc/metadata/creader.rs
  40. +1 −1  src/rustc/metadata/cstore.rs
  41. +1 −3 src/rustc/metadata/decoder.rs
  42. +1 −1  src/rustc/metadata/encoder.rs
  43. +1 −1  src/rustc/middle/check_alt.rs
  44. +1 −1  src/rustc/middle/const_eval.rs
  45. +10 −10 src/rustc/middle/resolve.rs
  46. +8 −8 src/rustc/middle/trans/alt.rs
  47. +6 −6 src/rustc/middle/trans/base.rs
  48. +2 −2 src/rustc/middle/trans/build.rs
  49. +2 −2 src/rustc/middle/trans/callee.rs
  50. +5 −5 src/rustc/middle/trans/common.rs
  51. +2 −2 src/rustc/middle/trans/consts.rs
  52. +2 −2 src/rustc/middle/trans/expr.rs
  53. +2 −2 src/rustc/middle/trans/foreign.rs
  54. +4 −4 src/rustc/middle/trans/meth.rs
  55. +11 −7 src/rustc/middle/trans/monomorphize.rs
  56. +3 −3 src/rustc/middle/trans/reflect.rs
  57. +1 −1  src/rustc/middle/trans/shape.rs
  58. +1 −1  src/rustc/middle/trans/tvec.rs
  59. +1 −1  src/rustc/middle/trans/type_of.rs
  60. +6 −6 src/rustc/middle/ty.rs
  61. +2 −2 src/rustc/middle/typeck.rs
  62. +3 −3 src/rustc/middle/typeck/astconv.rs
  63. +11 −14 src/rustc/middle/typeck/check.rs
  64. +1 −1  src/rustc/middle/typeck/check/alt.rs
  65. +1 −1  src/rustc/middle/typeck/check/regionmanip.rs
  66. +6 −6 src/rustc/middle/typeck/collect.rs
  67. +1 −2  src/rustc/middle/typeck/infer/region_var_bindings.rs
  68. +1 −4 src/rustc/middle/typeck/infer/sub.rs
  69. +2 −2 src/rustc/util/ppaux.rs
  70. +1 −1  src/rustdoc/attr_pass.rs
  71. +2 −2 src/rustdoc/extract.rs
  72. +3 −3 src/rustdoc/fold.rs
  73. +6 −6 src/rustdoc/markdown_pass.rs
  74. +2 −2 src/test/bench/core-vec-append.rs
  75. +10 −10 src/test/bench/graph500-bfs.rs
  76. +11 −11 src/test/bench/shootout-chameneos-redux.rs
  77. +1 −0  src/test/bench/shootout-k-nucleotide-pipes.rs
  78. +6 −5 src/test/bench/shootout-k-nucleotide.rs
  79. +4 −2 src/test/bench/task-perf-word-count-generic.rs
  80. +1 −1  src/test/run-pass/block-arg.rs
  81. +1 −1  src/test/run-pass/dvec-test.rs
  82. +1 −1  src/test/run-pass/issue-2804.rs
  83. +2 −2 src/test/run-pass/iter-eachi.rs
  84. +1 −1  src/test/run-pass/iter-map-to-vec.rs
View
6 doc/tutorial.md
@@ -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
View
6 src/cargo/cargo.rs
@@ -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;
}
}
View
7 src/libcore/dlist.rs
@@ -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
View
30 src/libcore/dvec.rs
@@ -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
+ }
}
}
View
9 src/libcore/io.rs
@@ -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;
View
4 src/libcore/iter-trait.rs
@@ -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) }
View
12 src/libcore/iter.rs
@@ -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));
}
}
}
View
5 src/libcore/os.rs
@@ -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 {
View
6 src/libcore/result.rs
@@ -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]) {
View
15 src/libcore/str.rs
@@ -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);
View
210 src/libcore/vec.rs
@@ -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;
}
View
3  src/libstd/base64.rs
@@ -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 {
View
12 src/libstd/deque.rs
@@ -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;
}
View
12 src/libstd/map.rs
@@ -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
View
2  src/libstd/net_ip.rs
@@ -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
}
View
6 src/libstd/par.rs
@@ -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)
})
}
});
View
2  src/libstd/rope.rs
@@ -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)) {
View
2  src/libstd/serialization.rs
@@ -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)
}
}
}
View
3  src/libstd/sort.rs
@@ -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);
View
4 src/libstd/sync.rs
@@ -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)]
View
2  src/libsyntax/ast_map.rs
@@ -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)
}
View
2  src/libsyntax/ast_util.rs
@@ -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)), ~"::")
}
View
4 src/libsyntax/attr.rs
@@ -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
}
}
View
10 src/libsyntax/ext/auto_serialize.rs
@@ -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}
View
2  src/libsyntax/ext/base.rs
@@ -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"
View
2  src/libsyntax/ext/pipes/ast_builder.rs
@@ -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: ~[],
View
4 src/libsyntax/ext/pipes/pipec.rs
@@ -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),
~", ") + ~")"
};
View
4 src/libsyntax/ext/pipes/proto.rs
@@ -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)
}
View
2  src/libsyntax/ext/qquote.rs
@@ -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)
View
6 src/libsyntax/ext/simplext.rs
@@ -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;
}
}
View
7 src/libsyntax/ext/source_util.rs
@@ -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);
}
View
2  src/libsyntax/ext/tt/macro_rules.rs
@@ -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;
View
5 src/libsyntax/ext/tt/transcribe.rs
@@ -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)
View
106 src/libsyntax/fold.rs
@@ -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))
}
}
View
2  src/libsyntax/parse/comments.rs
@@ -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 {
View
4 src/rustc/back/rpath.rs
@@ -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 {
View
2  src/rustc/driver/driver.rs
@@ -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 =
View
6 src/rustc/front/config.rs
@@ -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};
View
4 src/rustc/metadata/creader.rs
@@ -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)
}
}));
View
2  src/rustc/metadata/cstore.rs
@@ -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);
}
View
4 src/rustc/metadata/decoder.rs
@@ -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);
View
2  src/rustc/metadata/encoder.rs
@@ -1026,7 +1026,7 @@ fn encode_crate_deps(ecx: @encode_ctxt, ebml_w: ebml::Writer,
type numdep = decoder::crate_dep;