Skip to content

Commit 60bdf06

Browse files
committed
---
yaml --- r: 32951 b: refs/heads/dist-snap c: a3a257c h: refs/heads/master i: 32949: 952e7b0 32947: 5247e50 32943: 46b04d1 v: v3
1 parent a992f51 commit 60bdf06

File tree

10 files changed

+43
-48
lines changed

10 files changed

+43
-48
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: fdc60621364eef2fc20974ff4411f31099ed9595
10+
refs/heads/dist-snap: a3a257cc3b29cb134b05a72adbfeff08f1e7a98c
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libcore/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ mod tests {
675675
#[test]
676676
fn test_dlist_foldl() {
677677
let l = from_vec(vec::from_fn(101, |x|x));
678-
assert iter::foldl(l, 0, |accum,elem| accum+elem) == 5050;
678+
assert iter::foldl(&l, 0, |accum,elem| *accum+*elem) == 5050;
679679
}
680680
#[test]
681681
fn test_dlist_break_early() {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
1616
pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) }
1717
pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
1818
pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
19-
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
20-
iter::foldl(self, move b0, blk)
19+
pure fn foldl<B>(+b0: B, blk: fn(&B, &A) -> B) -> B {
20+
iter::foldl(&self, move b0, blk)
2121
}
2222
pure fn position(f: fn(A) -> bool) -> Option<uint> {
2323
iter::position(self, f)
@@ -26,7 +26,7 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
2626

2727
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
2828
pure fn contains(x: &A) -> bool { iter::contains(self, x) }
29-
pure fn count(x: &A) -> uint { iter::count(self, x) }
29+
pure fn count(x: &A) -> uint { iter::count(&self, x) }
3030
}
3131

3232
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
@@ -36,7 +36,7 @@ impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
3636
pure fn map_to_vec<B>(op: fn(+v: A) -> B) -> ~[B] {
3737
iter::map_to_vec(&self, op)
3838
}
39-
pure fn to_vec() -> ~[A] { iter::to_vec(self) }
39+
pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
4040

4141
pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(op: fn(+a: A) -> IB)
4242
-> ~[B] {
@@ -47,7 +47,7 @@ impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
4747
}
4848

4949
impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
50-
pure fn min() -> A { iter::min(self) }
51-
pure fn max() -> A { iter::max(self) }
50+
pure fn min() -> A { iter::min(&self) }
51+
pure fn max() -> A { iter::max(&self) }
5252
}
5353

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait ExtendedIter<A> {
1818
pure fn eachi(blk: fn(uint, v: &A) -> bool);
1919
pure fn all(blk: fn(&A) -> bool) -> bool;
2020
pure fn any(blk: fn(&A) -> bool) -> bool;
21-
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B;
21+
pure fn foldl<B>(+b0: B, blk: fn(&B, &A) -> B) -> B;
2222
pure fn position(f: fn(A) -> bool) -> Option<uint>;
2323
}
2424

@@ -118,16 +118,17 @@ pure fn flat_map_to_vec<A:Copy,B:Copy,IA:BaseIter<A>,IB:BaseIter<B>>(
118118
}
119119
}
120120

121-
pure fn foldl<A,B,IA:BaseIter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
121+
pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, +b0: B, blk: fn(&B, &A) -> B)
122+
-> B {
122123
let mut b <- b0;
123124
for self.each |a| {
124-
b = blk(b, *a);
125+
b = blk(&b, a);
125126
}
126127
move b
127128
}
128129

129-
pure fn to_vec<A:Copy,IA:BaseIter<A>>(self: IA) -> ~[A] {
130-
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(copy r, ~[a]))
130+
pure fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
131+
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(*r, ~[*a]))
131132
}
132133

133134
pure fn contains<A:Eq,IA:BaseIter<A>>(self: IA, x: &A) -> bool {
@@ -137,12 +138,12 @@ pure fn contains<A:Eq,IA:BaseIter<A>>(self: IA, x: &A) -> bool {
137138
return false;
138139
}
139140

140-
pure fn count<A:Eq,IA:BaseIter<A>>(self: IA, x: &A) -> uint {
141+
pure fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
141142
do foldl(self, 0) |count, value| {
142-
if value == *x {
143-
count + 1
143+
if *value == *x {
144+
*count + 1
144145
} else {
145-
count
146+
*count
146147
}
147148
}
148149
}
@@ -170,33 +171,27 @@ pure fn repeat(times: uint, blk: fn() -> bool) {
170171
}
171172
}
172173

173-
// XXX bad copies
174-
pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: IA) -> A {
174+
pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
175175
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
176176
match a {
177-
Some(copy a_) if a_ < b => {
178-
// FIXME (#2005): Not sure if this is successfully optimized to
179-
// a move
180-
a
177+
&Some(a_) if a_ < *b => {
178+
*(move a)
181179
}
182-
_ => Some(b)
180+
_ => Some(*b)
183181
}
184182
} {
185183
Some(move val) => val,
186184
None => fail ~"min called on empty iterator"
187185
}
188186
}
189187

190-
// XXX bad copies
191-
pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: IA) -> A {
188+
pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
192189
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
193190
match a {
194-
Some(copy a_) if a_ > b => {
195-
// FIXME (#2005): Not sure if this is successfully optimized to
196-
// a move.
197-
a
191+
&Some(a_) if a_ > *b => {
192+
*(move a)
198193
}
199-
_ => Some(b)
194+
_ => Some(*b)
200195
}
201196
} {
202197
Some(move val) => val,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,8 +1993,8 @@ impl<A> &[A]: iter::ExtendedIter<A> {
19931993
pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) }
19941994
pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
19951995
pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
1996-
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
1997-
iter::foldl(self, move b0, blk)
1996+
pure fn foldl<B>(+b0: B, blk: fn(&B, &A) -> B) -> B {
1997+
iter::foldl(&self, move b0, blk)
19981998
}
19991999
pure fn position(f: fn(A) -> bool) -> Option<uint> {
20002000
iter::position(self, f)
@@ -2003,7 +2003,7 @@ impl<A> &[A]: iter::ExtendedIter<A> {
20032003

20042004
impl<A: Eq> &[A]: iter::EqIter<A> {
20052005
pure fn contains(x: &A) -> bool { iter::contains(self, x) }
2006-
pure fn count(x: &A) -> uint { iter::count(self, x) }
2006+
pure fn count(x: &A) -> uint { iter::count(&self, x) }
20072007
}
20082008

20092009
impl<A: Copy> &[A]: iter::CopyableIter<A> {
@@ -2013,7 +2013,7 @@ impl<A: Copy> &[A]: iter::CopyableIter<A> {
20132013
pure fn map_to_vec<B>(op: fn(+v: A) -> B) -> ~[B] {
20142014
iter::map_to_vec(&self, op)
20152015
}
2016-
pure fn to_vec() -> ~[A] { iter::to_vec(self) }
2016+
pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
20172017

20182018
// FIXME--bug in resolve prevents this from working (#2611)
20192019
// fn flat_map_to_vec<B:copy,IB:base_iter<B>>(op: fn(A) -> IB) -> ~[B] {
@@ -2024,8 +2024,8 @@ impl<A: Copy> &[A]: iter::CopyableIter<A> {
20242024
}
20252025

20262026
impl<A: Copy Ord> &[A]: iter::CopyableOrderedIter<A> {
2027-
pure fn min() -> A { iter::min(self) }
2028-
pure fn max() -> A { iter::max(self) }
2027+
pure fn min() -> A { iter::min(&self) }
2028+
pure fn max() -> A { iter::max(&self) }
20292029
}
20302030
// ___________________________________________________________________________
20312031

branches/dist-snap/src/rustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ impl Liveness {
10141014
fn propagate_through_opt_expr(opt_expr: Option<@expr>,
10151015
succ: LiveNode) -> LiveNode {
10161016
do opt_expr.foldl(succ) |succ, expr| {
1017-
self.propagate_through_expr(expr, succ)
1017+
self.propagate_through_expr(*expr, *succ)
10181018
}
10191019
}
10201020

branches/dist-snap/src/rustc/middle/trans/meth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ fn combine_impl_and_methods_origins(bcx: block,
364364

365365
// Flatten out to find the number of vtables the method expects.
366366
let m_vtables = m_boundss.foldl(0, |sum, m_bounds| {
367-
m_bounds.foldl(sum, |sum, m_bound| {
368-
sum + match m_bound {
367+
m_bounds.foldl(*sum, |sum, m_bound| {
368+
(*sum) + match (*m_bound) {
369369
ty::bound_copy | ty::bound_owned |
370370
ty::bound_send | ty::bound_const => 0,
371371
ty::bound_trait(_) => 1

branches/dist-snap/src/rustc/middle/ty.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,25 +2137,25 @@ fn type_size(cx: ctxt, ty: t) -> uint {
21372137
}
21382138
21392139
ty_rec(flds) => {
2140-
flds.foldl(0, |s, f| s + type_size(cx, f.mt.ty))
2140+
flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
21412141
}
21422142
21432143
ty_class(did, ref substs) => {
21442144
let flds = class_items_as_fields(cx, did, substs);
2145-
flds.foldl(0, |s, f| s + type_size(cx, f.mt.ty))
2145+
flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
21462146
}
21472147
21482148
ty_tup(tys) => {
2149-
tys.foldl(0, |s, t| s + type_size(cx, t))
2149+
tys.foldl(0, |s, t| *s + type_size(cx, *t))
21502150
}
21512151
21522152
ty_enum(did, ref substs) => {
21532153
let variants = substd_enum_variants(cx, did, substs);
21542154
variants.foldl( // find max size of any variant
21552155
0,
2156-
|m, v| uint::max(m,
2156+
|m, v| uint::max(*m,
21572157
// find size of this variant:
2158-
v.args.foldl(0, |s, a| s + type_size(cx, a))))
2158+
v.args.foldl(0, |s, a| *s + type_size(cx, *a))))
21592159
}
21602160
21612161
ty_param(_) | ty_self => {

branches/dist-snap/src/rustc/middle/typeck/check/regionmanip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ fn replace_bound_regions_in_fn_ty(
111111

112112
// For each type `ty` in `tys`...
113113
do tys.foldl(isr) |isr, ty| {
114-
let mut isr = isr;
114+
let mut isr = *isr;
115115

116116
// Using fold_regions is inefficient, because it
117117
// constructs new types, but it avoids code duplication in
118118
// terms of locating all the regions within the various
119119
// kinds of types. This had already caused me several
120120
// bugs so I decided to switch over.
121-
do ty::fold_regions(tcx, ty) |r, in_fn| {
121+
do ty::fold_regions(tcx, *ty) |r, in_fn| {
122122
if !in_fn { isr = append_isr(isr, to_r, r); }
123123
r
124124
};

branches/dist-snap/src/test/run-pass/iter-foldl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fn add(&&x: float, &&y: uint) -> float { x + (y as float) }
1+
fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) }
22

33
fn main() {
44
assert [1u, 3u]/_.foldl(20f, add) == 24f;

0 commit comments

Comments
 (0)