Skip to content

Commit b46e25b

Browse files
committed
Merge commit 'erickt/incoming^' into kind-names
2 parents 807ce62 + 85bb1fc commit b46e25b

File tree

13 files changed

+113
-106
lines changed

13 files changed

+113
-106
lines changed

src/libcore/int-template.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ impl T: iter::Times {
9898
will execute the given function exactly x times. If we assume that \
9999
`x` is an int, this is functionally equivalent to \
100100
`for int::range(0, x) |_i| { /* anything */ }`."]
101-
pure fn times(it: fn() -> bool) {
102-
if self < 0 {
101+
pure fn times(&self, it: fn() -> bool) {
102+
if *self < 0 {
103103
fail fmt!("The .times method expects a nonnegative number, \
104104
but found %?", self);
105105
}
106-
let mut i = self;
106+
let mut i = *self;
107107
while i > 0 {
108108
if !it() { break }
109109
i -= 1;

src/libcore/iter-trait.rs

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,53 @@ use cmp::{Eq, Ord};
2020
use self::inst::{IMPL_T, EACH, SIZE_HINT};
2121

2222
impl<A> IMPL_T<A>: iter::BaseIter<A> {
23-
pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) }
24-
pure fn size_hint() -> Option<uint> { SIZE_HINT(&self) }
23+
pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
24+
pure fn size_hint(&self) -> Option<uint> { SIZE_HINT(self) }
2525
}
2626

2727
impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
28-
pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) }
29-
pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
30-
pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
31-
pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B {
32-
iter::foldl(&self, move b0, blk)
28+
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
29+
iter::eachi(self, blk)
3330
}
34-
pure fn position(f: fn(&A) -> bool) -> Option<uint> {
35-
iter::position(&self, f)
31+
pure fn all(&self, blk: fn(&A) -> bool) -> bool {
32+
iter::all(self, blk)
3633
}
34+
pure fn any(&self, blk: fn(&A) -> bool) -> bool {
35+
iter::any(self, blk)
36+
}
37+
pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B {
38+
iter::foldl(self, move b0, blk)
39+
}
40+
pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> {
41+
iter::position(self, f)
42+
}
43+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] {
44+
iter::map_to_vec(self, op)
45+
}
46+
pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB)
47+
-> ~[B] {
48+
iter::flat_map_to_vec(self, op)
49+
}
50+
3751
}
3852

3953
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
40-
pure fn contains(x: &A) -> bool { iter::contains(&self, x) }
41-
pure fn count(x: &A) -> uint { iter::count(&self, x) }
54+
pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
55+
pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
4256
}
4357

4458
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
45-
pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
46-
iter::filter_to_vec(&self, pred)
59+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
60+
iter::filter_to_vec(self, pred)
4761
}
48-
pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B] {
49-
iter::map_to_vec(&self, op)
62+
pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
63+
pure fn find(&self, f: fn(&A) -> bool) -> Option<A> {
64+
iter::find(self, f)
5065
}
51-
pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
52-
53-
pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(op: fn(a: A) -> IB)
54-
-> ~[B] {
55-
iter::flat_map_to_vec(&self, op)
56-
}
57-
58-
pure fn find(p: fn(a: A) -> bool) -> Option<A> { iter::find(&self, p) }
5966
}
6067

6168
impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
62-
pure fn min() -> A { iter::min(&self) }
63-
pure fn max() -> A { iter::max(&self) }
69+
pure fn min(&self) -> A { iter::min(self) }
70+
pure fn max(&self) -> A { iter::max(self) }
6471
}
6572

src/libcore/iter.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,39 @@ use cmp::{Eq, Ord};
2323
pub type InitOp<T> = &fn(uint) -> T;
2424

2525
pub trait BaseIter<A> {
26-
pure fn each(blk: fn(v: &A) -> bool);
27-
pure fn size_hint() -> Option<uint>;
26+
pure fn each(&self, blk: fn(v: &A) -> bool);
27+
pure fn size_hint(&self) -> Option<uint>;
2828
}
2929

3030
pub trait ExtendedIter<A> {
31-
pure fn eachi(blk: fn(uint, v: &A) -> bool);
32-
pure fn all(blk: fn(&A) -> bool) -> bool;
33-
pure fn any(blk: fn(&A) -> bool) -> bool;
34-
pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B;
35-
pure fn position(f: fn(&A) -> bool) -> Option<uint>;
31+
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool);
32+
pure fn all(&self, blk: fn(&A) -> bool) -> bool;
33+
pure fn any(&self, blk: fn(&A) -> bool) -> bool;
34+
pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B;
35+
pure fn position(&self, f: fn(&A) -> bool) -> Option<uint>;
36+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B];
37+
pure fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: fn(&A) -> IB)
38+
-> ~[B];
3639
}
3740

3841
pub trait EqIter<A:Eq> {
39-
pure fn contains(x: &A) -> bool;
40-
pure fn count(x: &A) -> uint;
42+
pure fn contains(&self, x: &A) -> bool;
43+
pure fn count(&self, x: &A) -> uint;
4144
}
4245

4346
pub trait Times {
44-
pure fn times(it: fn() -> bool);
47+
pure fn times(&self, it: fn() -> bool);
4548
}
4649

4750
pub trait CopyableIter<A:Copy> {
48-
pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A];
49-
pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B];
50-
pure fn flat_map_to_vec<B:Copy,IB: BaseIter<B>>(op: fn(A) -> IB) -> ~[B];
51-
pure fn to_vec() -> ~[A];
52-
pure fn find(p: fn(a: A) -> bool) -> Option<A>;
51+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A];
52+
pure fn to_vec(&self) -> ~[A];
53+
pure fn find(&self, p: fn(&A) -> bool) -> Option<A>;
5354
}
5455

5556
pub trait CopyableOrderedIter<A:Copy Ord> {
56-
pure fn min() -> A;
57-
pure fn max() -> A;
57+
pure fn min(&self) -> A;
58+
pure fn max(&self) -> A;
5859
}
5960

6061
pub trait CopyableNonstrictIter<A:Copy> {
@@ -81,11 +82,11 @@ pub trait Buildable<A> {
8182
* onto the sequence being constructed.
8283
*/
8384
static pure fn build_sized(size: uint,
84-
builder: fn(push: pure fn(v: A))) -> self;
85+
builder: fn(push: pure fn(A))) -> self;
8586
}
8687

8788
pub pure fn eachi<A,IA:BaseIter<A>>(self: &IA,
88-
blk: fn(uint, v: &A) -> bool) {
89+
blk: fn(uint, &A) -> bool) {
8990
let mut i = 0;
9091
for self.each |a| {
9192
if !blk(i, a) { break; }
@@ -110,30 +111,30 @@ pub pure fn any<A,IA:BaseIter<A>>(self: &IA,
110111
}
111112

112113
pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(
113-
self: &IA, prd: fn(a: A) -> bool) -> ~[A] {
114+
self: &IA, prd: fn(&A) -> bool) -> ~[A] {
114115
do vec::build_sized_opt(self.size_hint()) |push| {
115116
for self.each |a| {
116-
if prd(*a) { push(*a); }
117+
if prd(a) { push(*a); }
117118
}
118119
}
119120
}
120121

121-
pub pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: &IA,
122-
op: fn(v: A) -> B)
122+
pub pure fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA,
123+
op: fn(&A) -> B)
123124
-> ~[B] {
124125
do vec::build_sized_opt(self.size_hint()) |push| {
125126
for self.each |a| {
126-
push(op(*a));
127+
push(op(a));
127128
}
128129
}
129130
}
130131

131-
pub pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
132-
self: &IA, op: fn(a: A) -> IB) -> ~[B] {
132+
pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(
133+
self: &IA, op: fn(&A) -> IB) -> ~[B] {
133134
do vec::build |push| {
134135
for self.each |a| {
135-
for op(*a).each |b| {
136-
push(*b);
136+
for op(a).each |&b| {
137+
push(b);
137138
}
138139
}
139140
}
@@ -222,9 +223,9 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
222223
}
223224

224225
pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
225-
p: fn(a: A) -> bool) -> Option<A> {
226+
f: fn(&A) -> bool) -> Option<A> {
226227
for self.each |i| {
227-
if p(*i) { return Some(*i) }
228+
if f(i) { return Some(*i) }
228229
}
229230
return None;
230231
}
@@ -242,7 +243,7 @@ pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
242243
* onto the sequence being constructed.
243244
*/
244245
#[inline(always)]
245-
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A)))
246+
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(A)))
246247
-> B {
247248
Buildable::build_sized(4, builder)
248249
}
@@ -263,7 +264,7 @@ pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A)))
263264
#[inline(always)]
264265
pub pure fn build_sized_opt<A,B: Buildable<A>>(
265266
size: Option<uint>,
266-
builder: fn(push: pure fn(v: A))) -> B {
267+
builder: fn(push: pure fn(A))) -> B {
267268

268269
Buildable::build_sized(size.get_default(4), builder)
269270
}

src/libcore/uint-template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl T: iter::Times {
9292
will execute the given function exactly x times. If we assume that \
9393
`x` is an int, this is functionally equivalent to \
9494
`for int::range(0, x) |_i| { /* anything */ }`."]
95-
pure fn times(it: fn() -> bool) {
96-
let mut i = self;
95+
pure fn times(&self, it: fn() -> bool) {
96+
let mut i = *self;
9797
while i > 0 {
9898
if !it() { break }
9999
i -= 1;

src/libcore/vec.rs

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,57 +2013,60 @@ pub mod bytes {
20132013
// required in the slice.
20142014

20152015
impl<A> &[A]: iter::BaseIter<A> {
2016-
pub pure fn each(blk: fn(v: &A) -> bool) {
2016+
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
20172017
// FIXME(#2263)---should be able to call each(self, blk)
2018-
for each(self) |e| {
2018+
for each(*self) |e| {
20192019
if (!blk(e)) {
20202020
return;
20212021
}
20222022
}
20232023
}
2024-
pure fn size_hint() -> Option<uint> { Some(len(self)) }
2024+
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
20252025
}
20262026

20272027
impl<A> &[A]: iter::ExtendedIter<A> {
2028-
pub pure fn eachi(blk: fn(uint, v: &A) -> bool) {
2029-
iter::eachi(&self, blk)
2028+
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
2029+
iter::eachi(self, blk)
20302030
}
2031-
pub pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
2032-
pub pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
2033-
pub pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B {
2034-
iter::foldl(&self, b0, blk)
2031+
pub pure fn all(&self, blk: fn(&A) -> bool) -> bool {
2032+
iter::all(self, blk)
20352033
}
2036-
pub pure fn position(f: fn(&A) -> bool) -> Option<uint> {
2037-
iter::position(&self, f)
2034+
pub pure fn any(&self, blk: fn(&A) -> bool) -> bool {
2035+
iter::any(self, blk)
2036+
}
2037+
pub pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B {
2038+
iter::foldl(self, b0, blk)
2039+
}
2040+
pub pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> {
2041+
iter::position(self, f)
2042+
}
2043+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] {
2044+
iter::map_to_vec(self, op)
2045+
}
2046+
pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB)
2047+
-> ~[B] {
2048+
iter::flat_map_to_vec(self, op)
20382049
}
20392050
}
20402051

20412052
impl<A: Eq> &[A]: iter::EqIter<A> {
2042-
pub pure fn contains(x: &A) -> bool { iter::contains(&self, x) }
2043-
pub pure fn count(x: &A) -> uint { iter::count(&self, x) }
2053+
pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
2054+
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
20442055
}
20452056

20462057
impl<A: Copy> &[A]: iter::CopyableIter<A> {
2047-
pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
2048-
iter::filter_to_vec(&self, pred)
2058+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
2059+
iter::filter_to_vec(self, pred)
20492060
}
2050-
pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B] {
2051-
iter::map_to_vec(&self, op)
2052-
}
2053-
pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
2054-
2055-
pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(op: fn(A) -> IB) -> ~[B] {
2056-
iter::flat_map_to_vec(&self, op)
2057-
}
2058-
2059-
pub pure fn find(p: fn(a: A) -> bool) -> Option<A> {
2060-
iter::find(&self, p)
2061+
pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
2062+
pub pure fn find(&self, f: fn(&A) -> bool) -> Option<A> {
2063+
iter::find(self, f)
20612064
}
20622065
}
20632066

20642067
impl<A: Copy Ord> &[A]: iter::CopyableOrderedIter<A> {
2065-
pure fn min() -> A { iter::min(&self) }
2066-
pure fn max() -> A { iter::max(&self) }
2068+
pure fn min(&self) -> A { iter::min(self) }
2069+
pure fn max(&self) -> A { iter::max(self) }
20672070
}
20682071

20692072
impl<A:Copy> &[A] : iter::CopyableNonstrictIter<A> {

src/librustc/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn warn_if_multiple_versions(e: env, diag: span_handler,
7070
if crate_cache.len() != 0u {
7171
let name = loader::crate_name_from_metas(*crate_cache.last().metas);
7272
let (matches, non_matches) =
73-
partition(crate_cache.map_to_vec(|entry| {
73+
partition(crate_cache.map_to_vec(|&entry| {
7474
let othername = loader::crate_name_from_metas(*entry.metas);
7575
if name == othername {
7676
Left(entry)

src/librustc/middle/typeck/check/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ impl LookupContext {
861861
-> Option<method_map_entry>
862862
{
863863
let relevant_candidates =
864-
candidates.filter_to_vec(|c| self.is_relevant(self_ty, &c));
864+
candidates.filter_to_vec(|c| self.is_relevant(self_ty, c));
865865

866866
let relevant_candidates = self.merge_candidates(relevant_candidates);
867867

src/librustdoc/attr_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn parse_desc_should_parse_simple_doc_attributes() {
115115

116116
pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
117117
do doc_metas(attrs).find |meta| {
118-
match attr::get_meta_item_list(meta) {
118+
match attr::get_meta_item_list(*meta) {
119119
Some(metas) => {
120120
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
121121
vec::is_not_empty(hiddens)

src/libsyntax/ext/pipes/proto.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ fn visit<Tproto, Tstate, Tmessage, V: visitor<Tproto, Tstate, Tmessage>>(
218218
proto: protocol, visitor: V) -> Tproto {
219219

220220
// the copy keywords prevent recursive use of dvec
221-
let states = do (copy proto.states).map_to_vec |s| {
222-
let messages = do (copy s.messages).map_to_vec |m| {
221+
let states = do (copy proto.states).map_to_vec |&s| {
222+
let messages = do (copy s.messages).map_to_vec |&m| {
223223
let message(name, span, tys, this, next) = m;
224224
visitor.visit_message(name, span, tys, this, next)
225225
};

src/test/compile-fail/alt-vec-illegal-tail-element-loan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn a() -> &int {
22
let vec = [1, 2, 3, 4];
33
let tail = match vec {
4-
[a, ..tail] => &tail[0], //~ ERROR illegal borrow
4+
[_a, ..tail] => &tail[0], //~ ERROR illegal borrow
55
_ => fail ~"foo"
66
};
77
move tail

src/test/compile-fail/alt-vec-illegal-tail-loan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn a() -> &[int] {
22
let vec = [1, 2, 3, 4];
33
let tail = match vec {
4-
[a, ..tail] => tail, //~ ERROR illegal borrow
4+
[_a, ..tail] => tail, //~ ERROR illegal borrow
55
_ => fail ~"foo"
66
};
77
move tail

0 commit comments

Comments
 (0)