Skip to content

Commit 4d32f4e

Browse files
committed
---
yaml --- r: 34191 b: refs/heads/snap-stage3 c: 0f5bd1e h: refs/heads/master i: 34189: 2a323df 34187: 4edf8f2 34183: 440aadd 34175: 899c6f4 v: v3
1 parent 1c6d50b commit 4d32f4e

File tree

15 files changed

+108
-115
lines changed

15 files changed

+108
-115
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 85bb1fc2c4e2060bc9b9800743c840c261e47fb3
4+
refs/heads/snap-stage3: 0f5bd1e50615faa89f9094ea69cc6b27cd6c2342
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/RELEASES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Version 0.5 (December 2012)
2828
* `use` statements now take crate-relative paths
2929

3030
* Improved support for language features
31-
* Trait constraints work in many scenarios
31+
* Trait inheritance works in many scenarios
3232
* More support for explicit self arguments in methods - `self`, `&self`
3333
`@self`, and `~self` all generally work as expected
3434
* Static methods work in more situations

branches/snap-stage3/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(&self, it: fn() -> bool) {
102-
if *self < 0 {
101+
pure fn times(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;

branches/snap-stage3/src/libcore/iter-trait.rs

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,53 +20,46 @@ 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(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
24-
pure fn size_hint(&self) -> Option<uint> { SIZE_HINT(self) }
23+
pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) }
24+
pure fn size_hint() -> Option<uint> { SIZE_HINT(&self) }
2525
}
2626

2727
impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
28-
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
29-
iter::eachi(self, blk)
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)
3033
}
31-
pure fn all(&self, blk: fn(&A) -> bool) -> bool {
32-
iter::all(self, blk)
34+
pure fn position(f: fn(&A) -> bool) -> Option<uint> {
35+
iter::position(&self, f)
3336
}
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-
5137
}
5238

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

5844
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
59-
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
60-
iter::filter_to_vec(self, pred)
45+
pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
46+
iter::filter_to_vec(&self, pred)
6147
}
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)
48+
pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B] {
49+
iter::map_to_vec(&self, op)
6550
}
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) }
6659
}
6760

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

branches/snap-stage3/src/libcore/iter.rs

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

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

3030
pub trait ExtendedIter<A> {
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];
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>;
3936
}
4037

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

4643
pub trait Times {
47-
pure fn times(&self, it: fn() -> bool);
44+
pure fn times(it: fn() -> bool);
4845
}
4946

5047
pub trait CopyableIter<A:Copy> {
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>;
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>;
5453
}
5554

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

6160
pub trait CopyableNonstrictIter<A:Copy> {
@@ -82,11 +81,11 @@ pub trait Buildable<A> {
8281
* onto the sequence being constructed.
8382
*/
8483
static pure fn build_sized(size: uint,
85-
builder: fn(push: pure fn(A))) -> self;
84+
builder: fn(push: pure fn(v: A))) -> self;
8685
}
8786

8887
pub pure fn eachi<A,IA:BaseIter<A>>(self: &IA,
89-
blk: fn(uint, &A) -> bool) {
88+
blk: fn(uint, v: &A) -> bool) {
9089
let mut i = 0;
9190
for self.each |a| {
9291
if !blk(i, a) { break; }
@@ -111,30 +110,30 @@ pub pure fn any<A,IA:BaseIter<A>>(self: &IA,
111110
}
112111

113112
pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(
114-
self: &IA, prd: fn(&A) -> bool) -> ~[A] {
113+
self: &IA, prd: fn(a: A) -> bool) -> ~[A] {
115114
do vec::build_sized_opt(self.size_hint()) |push| {
116115
for self.each |a| {
117-
if prd(a) { push(*a); }
116+
if prd(*a) { push(*a); }
118117
}
119118
}
120119
}
121120

122-
pub pure fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA,
123-
op: fn(&A) -> B)
121+
pub pure fn map_to_vec<A:Copy,B,IA:BaseIter<A>>(self: &IA,
122+
op: fn(v: A) -> B)
124123
-> ~[B] {
125124
do vec::build_sized_opt(self.size_hint()) |push| {
126125
for self.each |a| {
127-
push(op(a));
126+
push(op(*a));
128127
}
129128
}
130129
}
131130

132-
pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(
133-
self: &IA, op: fn(&A) -> IB) -> ~[B] {
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] {
134133
do vec::build |push| {
135134
for self.each |a| {
136-
for op(a).each |&b| {
137-
push(b);
135+
for op(*a).each |b| {
136+
push(*b);
138137
}
139138
}
140139
}
@@ -223,9 +222,9 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
223222
}
224223

225224
pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
226-
f: fn(&A) -> bool) -> Option<A> {
225+
p: fn(a: A) -> bool) -> Option<A> {
227226
for self.each |i| {
228-
if f(i) { return Some(*i) }
227+
if p(*i) { return Some(*i) }
229228
}
230229
return None;
231230
}
@@ -243,7 +242,7 @@ pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA,
243242
* onto the sequence being constructed.
244243
*/
245244
#[inline(always)]
246-
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(A)))
245+
pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(v: A)))
247246
-> B {
248247
Buildable::build_sized(4, builder)
249248
}
@@ -264,7 +263,7 @@ pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(A)))
264263
#[inline(always)]
265264
pub pure fn build_sized_opt<A,B: Buildable<A>>(
266265
size: Option<uint>,
267-
builder: fn(push: pure fn(A))) -> B {
266+
builder: fn(push: pure fn(v: A))) -> B {
268267

269268
Buildable::build_sized(size.get_default(4), builder)
270269
}

branches/snap-stage3/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(&self, it: fn() -> bool) {
96-
let mut i = *self;
95+
pure fn times(it: fn() -> bool) {
96+
let mut i = self;
9797
while i > 0 {
9898
if !it() { break }
9999
i -= 1;

branches/snap-stage3/src/libcore/vec.rs

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

20152015
impl<A> &[A]: iter::BaseIter<A> {
2016-
pub pure fn each(&self, blk: fn(v: &A) -> bool) {
2016+
pub pure fn each(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(&self) -> Option<uint> { Some(len(*self)) }
2024+
pure fn size_hint() -> Option<uint> { Some(len(self)) }
20252025
}
20262026

20272027
impl<A> &[A]: iter::ExtendedIter<A> {
2028-
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
2029-
iter::eachi(self, blk)
2028+
pub pure fn eachi(blk: fn(uint, v: &A) -> bool) {
2029+
iter::eachi(&self, blk)
20302030
}
2031-
pub pure fn all(&self, blk: fn(&A) -> bool) -> bool {
2032-
iter::all(self, blk)
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)
20332035
}
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)
2036+
pub pure fn position(f: fn(&A) -> bool) -> Option<uint> {
2037+
iter::position(&self, f)
20492038
}
20502039
}
20512040

20522041
impl<A: Eq> &[A]: iter::EqIter<A> {
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) }
2042+
pub pure fn contains(x: &A) -> bool { iter::contains(&self, x) }
2043+
pub pure fn count(x: &A) -> uint { iter::count(&self, x) }
20552044
}
20562045

20572046
impl<A: Copy> &[A]: iter::CopyableIter<A> {
2058-
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
2059-
iter::filter_to_vec(self, pred)
2047+
pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
2048+
iter::filter_to_vec(&self, pred)
20602049
}
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)
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)
20642061
}
20652062
}
20662063

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

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

branches/snap-stage3/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)

branches/snap-stage3/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

branches/snap-stage3/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)

branches/snap-stage3/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
};

0 commit comments

Comments
 (0)