diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 5aaf7ed3dba5d..8b01002831b7e 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -87,24 +87,9 @@ static AbiDatas: &'static [AbiData] = &[ AbiData {abi: RustIntrinsic, name: "rust-intrinsic", abi_arch: RustArch}, ]; -/// Iterates through each of the defined ABIs. -fn each_abi(op: |abi: Abi| -> bool) -> bool { - AbiDatas.iter().advance(|abi_data| op(abi_data.abi)) -} - /// Returns the ABI with the given name (if any). pub fn lookup(name: &str) -> Option { - let mut res = None; - - each_abi(|abi| { - if name == abi.data().name { - res = Some(abi); - false - } else { - true - } - }); - res + AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi) } pub fn all_names() -> Vec<&'static str> { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 13fe8a1506459..cd38c9b3e98c1 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -611,18 +611,18 @@ pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool { match pat.node { PatIdent(_, _, Some(ref p)) => walk_pat(&**p, it), PatStruct(_, ref fields, _) => { - fields.iter().advance(|f| walk_pat(&*f.pat, |p| it(p))) + fields.iter().all(|field| walk_pat(&*field.pat, |p| it(p))) } PatEnum(_, Some(ref s)) | PatTup(ref s) => { - s.iter().advance(|p| walk_pat(&**p, |p| it(p))) + s.iter().all(|p| walk_pat(&**p, |p| it(p))) } PatBox(ref s) | PatRegion(ref s) => { walk_pat(&**s, it) } PatVec(ref before, ref slice, ref after) => { - before.iter().advance(|p| walk_pat(&**p, |p| it(p))) && - slice.iter().advance(|p| walk_pat(&**p, |p| it(p))) && - after.iter().advance(|p| walk_pat(&**p, |p| it(p))) + before.iter().all(|p| walk_pat(&**p, |p| it(p))) && + slice.iter().all(|p| walk_pat(&**p, |p| it(p))) && + after.iter().all(|p| walk_pat(&**p, |p| it(p))) } PatMac(_) => fail!("attempted to analyze unexpanded pattern"), PatWild | PatWildMulti | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |