Demode iter::foldl and friends

This commit is contained in:
Tim Chevalier
2012-09-28 16:37:14 -07:00
parent fdc6062136
commit a3a257cc3b
9 changed files with 42 additions and 47 deletions

View File

@@ -1014,7 +1014,7 @@ impl Liveness {
fn propagate_through_opt_expr(opt_expr: Option<@expr>,
succ: LiveNode) -> LiveNode {
do opt_expr.foldl(succ) |succ, expr| {
self.propagate_through_expr(expr, succ)
self.propagate_through_expr(*expr, *succ)
}
}

View File

@@ -364,8 +364,8 @@ fn combine_impl_and_methods_origins(bcx: block,
// Flatten out to find the number of vtables the method expects.
let m_vtables = m_boundss.foldl(0, |sum, m_bounds| {
m_bounds.foldl(sum, |sum, m_bound| {
sum + match m_bound {
m_bounds.foldl(*sum, |sum, m_bound| {
(*sum) + match (*m_bound) {
ty::bound_copy | ty::bound_owned |
ty::bound_send | ty::bound_const => 0,
ty::bound_trait(_) => 1

View File

@@ -2137,25 +2137,25 @@ fn type_size(cx: ctxt, ty: t) -> uint {
}
ty_rec(flds) => {
flds.foldl(0, |s, f| s + type_size(cx, f.mt.ty))
flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
}
ty_class(did, ref substs) => {
let flds = class_items_as_fields(cx, did, substs);
flds.foldl(0, |s, f| s + type_size(cx, f.mt.ty))
flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
}
ty_tup(tys) => {
tys.foldl(0, |s, t| s + type_size(cx, t))
tys.foldl(0, |s, t| *s + type_size(cx, *t))
}
ty_enum(did, ref substs) => {
let variants = substd_enum_variants(cx, did, substs);
variants.foldl( // find max size of any variant
0,
|m, v| uint::max(m,
|m, v| uint::max(*m,
// find size of this variant:
v.args.foldl(0, |s, a| s + type_size(cx, a))))
v.args.foldl(0, |s, a| *s + type_size(cx, *a))))
}
ty_param(_) | ty_self => {

View File

@@ -111,14 +111,14 @@ fn replace_bound_regions_in_fn_ty(
// For each type `ty` in `tys`...
do tys.foldl(isr) |isr, ty| {
let mut isr = isr;
let mut isr = *isr;
// Using fold_regions is inefficient, because it
// constructs new types, but it avoids code duplication in
// terms of locating all the regions within the various
// kinds of types. This had already caused me several
// bugs so I decided to switch over.
do ty::fold_regions(tcx, ty) |r, in_fn| {
do ty::fold_regions(tcx, *ty) |r, in_fn| {
if !in_fn { isr = append_isr(isr, to_r, r); }
r
};