diff options
| author | bors <bors@rust-lang.org> | 2014-07-09 23:51:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-09 23:51:27 +0000 |
| commit | 1b8e671d748407a377da04f389518cd981418d2c (patch) | |
| tree | 27d36b78119308f4095479684be5db5188f7a576 /src/libsyntax | |
| parent | 942c72e1179bc2d3d351ea97235d65b39160cc18 (diff) | |
| parent | 5d39d0befaa567e1a438d6b0151390052931094c (diff) | |
| download | rust-1b8e671d748407a377da04f389518cd981418d2c.tar.gz rust-1b8e671d748407a377da04f389518cd981418d2c.zip | |
auto merge of #15514 : luqmana/rust/die-advance-die, r=cmr
Closes #15492.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 10 |
2 files changed, 6 insertions, 21 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 5aaf7ed3dba..8b01002831b 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<Abi> { - 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 13fe8a15064..cd38c9b3e98 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(_, _, _) | |
