diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs
index 3d9de89aa6f..eed439823fc 100644
--- a/src/libcore/int-template.rs
+++ b/src/libcore/int-template.rs
@@ -98,12 +98,12 @@ impl T: iter::Times {
will execute the given function exactly x times. If we assume that \
`x` is an int, this is functionally equivalent to \
`for int::range(0, x) |_i| { /* anything */ }`."]
- pure fn times(it: fn() -> bool) {
- if self < 0 {
+ pure fn times(&self, it: fn() -> bool) {
+ if *self < 0 {
fail fmt!("The .times method expects a nonnegative number, \
but found %?", self);
}
- let mut i = self;
+ let mut i = *self;
while i > 0 {
if !it() { break }
i -= 1;
diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs
index e0bd4d5b7c8..644a0fd76b7 100644
--- a/src/libcore/iter-trait.rs
+++ b/src/libcore/iter-trait.rs
@@ -20,46 +20,53 @@ use cmp::{Eq, Ord};
use self::inst::{IMPL_T, EACH, SIZE_HINT};
impl IMPL_T: iter::BaseIter {
- pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) }
- pure fn size_hint() -> Option { SIZE_HINT(&self) }
+ pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
+ pure fn size_hint(&self) -> Option { SIZE_HINT(self) }
}
impl IMPL_T: iter::ExtendedIter {
- 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(b0: B, blk: fn(&B, &A) -> B) -> B {
- iter::foldl(&self, move b0, blk)
+ pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
+ iter::eachi(self, blk)
}
- pure fn position(f: fn(&A) -> bool) -> Option {
- iter::position(&self, f)
+ pure fn all(&self, blk: fn(&A) -> bool) -> bool {
+ iter::all(self, blk)
}
+ pure fn any(&self, blk: fn(&A) -> bool) -> bool {
+ iter::any(self, blk)
+ }
+ pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B {
+ iter::foldl(self, move b0, blk)
+ }
+ pure fn position(&self, f: fn(&A) -> bool) -> Option {
+ iter::position(self, f)
+ }
+ pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] {
+ iter::map_to_vec(self, op)
+ }
+ pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB)
+ -> ~[B] {
+ iter::flat_map_to_vec(self, op)
+ }
+
}
impl IMPL_T: iter::EqIter {
- pure fn contains(x: &A) -> bool { iter::contains(&self, x) }
- pure fn count(x: &A) -> uint { iter::count(&self, x) }
+ pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
+ pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
}
impl IMPL_T: iter::CopyableIter {
- pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
- iter::filter_to_vec(&self, pred)
+ pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
+ iter::filter_to_vec(self, pred)
}
- pure fn map_to_vec(op: fn(v: A) -> B) -> ~[B] {
- iter::map_to_vec(&self, op)
+ pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
+ pure fn find(&self, f: fn(&A) -> bool) -> Option {
+ iter::find(self, f)
}
- pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
-
- pure fn flat_map_to_vec>(op: fn(a: A) -> IB)
- -> ~[B] {
- iter::flat_map_to_vec(&self, op)
- }
-
- pure fn find(p: fn(a: A) -> bool) -> Option { iter::find(&self, p) }
}
impl IMPL_T: iter::CopyableOrderedIter {
- pure fn min() -> A { iter::min(&self) }
- pure fn max() -> A { iter::max(&self) }
+ pure fn min(&self) -> A { iter::min(self) }
+ pure fn max(&self) -> A { iter::max(self) }
}
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index 7685fe06ad9..a9b3401aa6f 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -23,38 +23,39 @@ use cmp::{Eq, Ord};
pub type InitOp = &fn(uint) -> T;
pub trait BaseIter {
- pure fn each(blk: fn(v: &A) -> bool);
- pure fn size_hint() -> Option;
+ pure fn each(&self, blk: fn(v: &A) -> bool);
+ pure fn size_hint(&self) -> Option;
}
pub trait ExtendedIter {
- 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(b0: B, blk: fn(&B, &A) -> B) -> B;
- pure fn position(f: fn(&A) -> bool) -> Option;
+ pure fn eachi(&self, blk: fn(uint, v: &A) -> bool);
+ pure fn all(&self, blk: fn(&A) -> bool) -> bool;
+ pure fn any(&self, blk: fn(&A) -> bool) -> bool;
+ pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B;
+ pure fn position(&self, f: fn(&A) -> bool) -> Option;
+ pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B];
+ pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB)
+ -> ~[B];
}
pub trait EqIter {
- pure fn contains(x: &A) -> bool;
- pure fn count(x: &A) -> uint;
+ pure fn contains(&self, x: &A) -> bool;
+ pure fn count(&self, x: &A) -> uint;
}
pub trait Times {
- pure fn times(it: fn() -> bool);
+ pure fn times(&self, it: fn() -> bool);
}
pub trait CopyableIter {
- pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A];
- pure fn map_to_vec(op: fn(v: A) -> B) -> ~[B];
- pure fn flat_map_to_vec>(op: fn(A) -> IB) -> ~[B];
- pure fn to_vec() -> ~[A];
- pure fn find(p: fn(a: A) -> bool) -> Option;
+ pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A];
+ pure fn to_vec(&self) -> ~[A];
+ pure fn find(&self, p: fn(&A) -> bool) -> Option;
}
pub trait CopyableOrderedIter {
- pure fn min() -> A;
- pure fn max() -> A;
+ pure fn min(&self) -> A;
+ pure fn max(&self) -> A;
}
pub trait CopyableNonstrictIter {
@@ -81,11 +82,11 @@ pub trait Buildable {
* onto the sequence being constructed.
*/
static pure fn build_sized(size: uint,
- builder: fn(push: pure fn(v: A))) -> self;
+ builder: fn(push: pure fn(A))) -> self;
}
pub pure fn eachi>(self: &IA,
- blk: fn(uint, v: &A) -> bool) {
+ blk: fn(uint, &A) -> bool) {
let mut i = 0;
for self.each |a| {
if !blk(i, a) { break; }
@@ -110,30 +111,30 @@ pub pure fn any>(self: &IA,
}
pub pure fn filter_to_vec>(
- self: &IA, prd: fn(a: A) -> bool) -> ~[A] {
+ self: &IA, prd: fn(&A) -> bool) -> ~[A] {
do vec::build_sized_opt(self.size_hint()) |push| {
for self.each |a| {
- if prd(*a) { push(*a); }
+ if prd(a) { push(*a); }
}
}
}
-pub pure fn map_to_vec>(self: &IA,
- op: fn(v: A) -> B)
+pub pure fn map_to_vec>(self: &IA,
+ op: fn(&A) -> B)
-> ~[B] {
do vec::build_sized_opt(self.size_hint()) |push| {
for self.each |a| {
- push(op(*a));
+ push(op(a));
}
}
}
-pub pure fn flat_map_to_vec,IB:BaseIter>(
- self: &IA, op: fn(a: A) -> IB) -> ~[B] {
+pub pure fn flat_map_to_vec,IB:BaseIter>(
+ self: &IA, op: fn(&A) -> IB) -> ~[B] {
do vec::build |push| {
for self.each |a| {
- for op(*a).each |b| {
- push(*b);
+ for op(a).each |&b| {
+ push(b);
}
}
}
@@ -222,9 +223,9 @@ pub pure fn max>(self: &IA) -> A {
}
pub pure fn find>(self: &IA,
- p: fn(a: A) -> bool) -> Option {
+ f: fn(&A) -> bool) -> Option {
for self.each |i| {
- if p(*i) { return Some(*i) }
+ if f(i) { return Some(*i) }
}
return None;
}
@@ -242,7 +243,7 @@ pub pure fn find>(self: &IA,
* onto the sequence being constructed.
*/
#[inline(always)]
-pub pure fn build>(builder: fn(push: pure fn(v: A)))
+pub pure fn build>(builder: fn(push: pure fn(A)))
-> B {
Buildable::build_sized(4, builder)
}
@@ -263,7 +264,7 @@ pub pure fn build>(builder: fn(push: pure fn(v: A)))
#[inline(always)]
pub pure fn build_sized_opt>(
size: Option,
- builder: fn(push: pure fn(v: A))) -> B {
+ builder: fn(push: pure fn(A))) -> B {
Buildable::build_sized(size.get_default(4), builder)
}
diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs
index da0c92021a4..1a9bca92d1f 100644
--- a/src/libcore/uint-template.rs
+++ b/src/libcore/uint-template.rs
@@ -92,8 +92,8 @@ impl T: iter::Times {
will execute the given function exactly x times. If we assume that \
`x` is an int, this is functionally equivalent to \
`for int::range(0, x) |_i| { /* anything */ }`."]
- pure fn times(it: fn() -> bool) {
- let mut i = self;
+ pure fn times(&self, it: fn() -> bool) {
+ let mut i = *self;
while i > 0 {
if !it() { break }
i -= 1;
diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs
index c568faccf89..c091f48728f 100644
--- a/src/libcore/vec.rs
+++ b/src/libcore/vec.rs
@@ -2013,57 +2013,60 @@ pub mod bytes {
// required in the slice.
impl &[A]: iter::BaseIter {
- pub pure fn each(blk: fn(v: &A) -> bool) {
+ pub pure fn each(&self, blk: fn(v: &A) -> bool) {
// FIXME(#2263)---should be able to call each(self, blk)
- for each(self) |e| {
+ for each(*self) |e| {
if (!blk(e)) {
return;
}
}
}
- pure fn size_hint() -> Option { Some(len(self)) }
+ pure fn size_hint(&self) -> Option { Some(len(*self)) }
}
impl &[A]: iter::ExtendedIter {
- pub pure fn eachi(blk: fn(uint, v: &A) -> bool) {
- iter::eachi(&self, blk)
+ pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
+ iter::eachi(self, blk)
}
- pub pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
- pub pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
- pub pure fn foldl(b0: B, blk: fn(&B, &A) -> B) -> B {
- iter::foldl(&self, b0, blk)
+ pub pure fn all(&self, blk: fn(&A) -> bool) -> bool {
+ iter::all(self, blk)
}
- pub pure fn position(f: fn(&A) -> bool) -> Option {
- iter::position(&self, f)
+ pub pure fn any(&self, blk: fn(&A) -> bool) -> bool {
+ iter::any(self, blk)
+ }
+ pub pure fn foldl(&self, b0: B, blk: fn(&B, &A) -> B) -> B {
+ iter::foldl(self, b0, blk)
+ }
+ pub pure fn position(&self, f: fn(&A) -> bool) -> Option {
+ iter::position(self, f)
+ }
+ pure fn map_to_vec(&self, op: fn(&A) -> B) -> ~[B] {
+ iter::map_to_vec(self, op)
+ }
+ pure fn flat_map_to_vec>(&self, op: fn(&A) -> IB)
+ -> ~[B] {
+ iter::flat_map_to_vec(self, op)
}
}
impl &[A]: iter::EqIter {
- pub pure fn contains(x: &A) -> bool { iter::contains(&self, x) }
- pub pure fn count(x: &A) -> uint { iter::count(&self, x) }
+ pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
+ pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
}
impl &[A]: iter::CopyableIter {
- pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
- iter::filter_to_vec(&self, pred)
+ pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
+ iter::filter_to_vec(self, pred)
}
- pure fn map_to_vec(op: fn(v: A) -> B) -> ~[B] {
- iter::map_to_vec(&self, op)
- }
- pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
-
- pure fn flat_map_to_vec>(op: fn(A) -> IB) -> ~[B] {
- iter::flat_map_to_vec(&self, op)
- }
-
- pub pure fn find(p: fn(a: A) -> bool) -> Option {
- iter::find(&self, p)
+ pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
+ pub pure fn find(&self, f: fn(&A) -> bool) -> Option {
+ iter::find(self, f)
}
}
impl &[A]: iter::CopyableOrderedIter {
- pure fn min() -> A { iter::min(&self) }
- pure fn max() -> A { iter::max(&self) }
+ pure fn min(&self) -> A { iter::min(self) }
+ pure fn max(&self) -> A { iter::max(self) }
}
impl &[A] : iter::CopyableNonstrictIter {
diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs
index bebddec94d3..e9b820d30db 100644
--- a/src/librustc/metadata/creader.rs
+++ b/src/librustc/metadata/creader.rs
@@ -70,7 +70,7 @@ fn warn_if_multiple_versions(e: env, diag: span_handler,
if crate_cache.len() != 0u {
let name = loader::crate_name_from_metas(*crate_cache.last().metas);
let (matches, non_matches) =
- partition(crate_cache.map_to_vec(|entry| {
+ partition(crate_cache.map_to_vec(|&entry| {
let othername = loader::crate_name_from_metas(*entry.metas);
if name == othername {
Left(entry)
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index c61ad39e333..765bf0cfdff 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -861,7 +861,7 @@ impl LookupContext {
-> Option
{
let relevant_candidates =
- candidates.filter_to_vec(|c| self.is_relevant(self_ty, &c));
+ candidates.filter_to_vec(|c| self.is_relevant(self_ty, c));
let relevant_candidates = self.merge_candidates(relevant_candidates);
diff --git a/src/librustdoc/attr_parser.rs b/src/librustdoc/attr_parser.rs
index 7ce4ef4f901..1a46b924147 100644
--- a/src/librustdoc/attr_parser.rs
+++ b/src/librustdoc/attr_parser.rs
@@ -115,7 +115,7 @@ fn parse_desc_should_parse_simple_doc_attributes() {
pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
do doc_metas(attrs).find |meta| {
- match attr::get_meta_item_list(meta) {
+ match attr::get_meta_item_list(*meta) {
Some(metas) => {
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
vec::is_not_empty(hiddens)
diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs
index 76757d027a5..b00a2aab69f 100644
--- a/src/libsyntax/ext/pipes/proto.rs
+++ b/src/libsyntax/ext/pipes/proto.rs
@@ -218,8 +218,8 @@ fn visit>(
proto: protocol, visitor: V) -> Tproto {
// 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 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;
visitor.visit_message(name, span, tys, this, next)
};
diff --git a/src/test/compile-fail/alt-vec-illegal-tail-element-loan.rs b/src/test/compile-fail/alt-vec-illegal-tail-element-loan.rs
index 70c7c33f691..36d019058ae 100644
--- a/src/test/compile-fail/alt-vec-illegal-tail-element-loan.rs
+++ b/src/test/compile-fail/alt-vec-illegal-tail-element-loan.rs
@@ -1,7 +1,7 @@
fn a() -> &int {
let vec = [1, 2, 3, 4];
let tail = match vec {
- [a, ..tail] => &tail[0], //~ ERROR illegal borrow
+ [_a, ..tail] => &tail[0], //~ ERROR illegal borrow
_ => fail ~"foo"
};
move tail
diff --git a/src/test/compile-fail/alt-vec-illegal-tail-loan.rs b/src/test/compile-fail/alt-vec-illegal-tail-loan.rs
index 69bc910669d..29c1d2a78a3 100644
--- a/src/test/compile-fail/alt-vec-illegal-tail-loan.rs
+++ b/src/test/compile-fail/alt-vec-illegal-tail-loan.rs
@@ -1,7 +1,7 @@
fn a() -> &[int] {
let vec = [1, 2, 3, 4];
let tail = match vec {
- [a, ..tail] => tail, //~ ERROR illegal borrow
+ [_a, ..tail] => tail, //~ ERROR illegal borrow
_ => fail ~"foo"
};
move tail
diff --git a/src/test/run-pass/issue-2611.rs b/src/test/run-pass/issue-2611.rs
index eb5f54abe8f..0a8bd250bb5 100644
--- a/src/test/run-pass/issue-2611.rs
+++ b/src/test/run-pass/issue-2611.rs
@@ -8,17 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// xfail-fast
-#[legacy_modes];
-
use iter::BaseIter;
trait FlatMapToVec {
- fn flat_map_to_vec>(op: fn(+a: A) -> IB) -> ~[B];
+ fn flat_map_to_vec>(op: fn(&A) -> IB) -> ~[B];
}
impl BaseIter: FlatMapToVec {
- fn flat_map_to_vec>(op: fn(+a: A) -> IB) -> ~[B] {
+ fn flat_map_to_vec>(op: fn(&A) -> IB) -> ~[B] {
iter::flat_map_to_vec(&self, op)
}
}
diff --git a/src/test/run-pass/iter-flat-map-to-vec.rs b/src/test/run-pass/iter-flat-map-to-vec.rs
index d95dac1e092..2177066a033 100644
--- a/src/test/run-pass/iter-flat-map-to-vec.rs
+++ b/src/test/run-pass/iter-flat-map-to-vec.rs
@@ -9,10 +9,9 @@
// except according to those terms.
// xfail-test -- flat_map_to_vec currently disable
+fn repeat(x: &uint) -> ~[uint] { ~[x, x] }
-fn repeat(&&x: uint) -> ~[uint] { ~[x, x] }
-
-fn incd_if_even(&&x: uint) -> option {
+fn incd_if_even(x: &uint) -> option {
if (x % 2u) == 0u {some(x + 1u)} else {none}
}
@@ -28,4 +27,4 @@ fn main() {
assert none.flat_map_to_vec(incd_if_even) == ~[];
assert some(1u).flat_map_to_vec(incd_if_even) == ~[];
assert some(2u).flat_map_to_vec(incd_if_even) == ~[3u];
-}
\ No newline at end of file
+}