Merge pull request #7595 from thestinger/iterator

remove some method resolve workarounds
This commit is contained in:
Daniel Micay 2013-07-08 01:42:07 -07:00
commit 44770ae3a8
51 changed files with 118 additions and 118 deletions

View file

@ -176,7 +176,7 @@ fn name_str(nm: &Name) -> ~str {
}
fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> {
opts.iter().position_(|opt| opt.name == nm)
opts.iter().position(|opt| opt.name == nm)
}
/**

View file

@ -950,7 +950,7 @@ impl serialize::Decoder for Decoder {
}
ref json => fail!("invalid variant: %?", *json),
};
let idx = match names.iter().position_(|n| str::eq_slice(*n, name)) {
let idx = match names.iter().position(|n| str::eq_slice(*n, name)) {
Some(idx) => idx,
None => fail!("Unknown variant name: %?", name),
};

View file

@ -203,7 +203,7 @@ pub mod v4 {
}).collect();
if parts.len() != 4 {
Err(fmt!("'%s' doesn't have 4 parts", ip))
} else if parts.iter().any_(|x| *x == 256u) {
} else if parts.iter().any(|x| *x == 256u) {
Err(fmt!("invalid octal in addr '%s'", ip))
} else {
Ok(Ipv4Rep {

View file

@ -522,7 +522,7 @@ fn get_authority(rawurl: &str) ->
let host_is_end_plus_one: &fn() -> bool = || {
let xs = ['?', '#', '/'];
end+1 == len
&& !xs.iter().any_(|x| *x == (rawurl[end] as char))
&& !xs.iter().any(|x| *x == (rawurl[end] as char))
};
// finish up

View file

@ -136,8 +136,8 @@ pub fn any<A:Copy + Send>(
fn_factory: &fn() -> ~fn(&A) -> bool) -> bool {
let mapped = map_slices(xs, || {
let f = fn_factory();
let result: ~fn(uint, &[A]) -> bool = |_, slice| slice.iter().any_(f);
let result: ~fn(uint, &[A]) -> bool = |_, slice| slice.iter().any(f);
result
});
mapped.iter().any_(|&x| x)
mapped.iter().any(|&x| x)
}

View file

@ -294,7 +294,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
// Find the offset of the NUL we want to go to
let nulpos = string_table.slice(offset as uint, string_table_bytes as uint)
.iter().position_(|&b| b == 0);
.iter().position(|&b| b == 0);
match nulpos {
Some(len) => {
string_map.insert(name.to_owned(),

View file

@ -844,7 +844,7 @@ mod test_treemap {
for 90.times {
let k = rng.gen();
let v = rng.gen();
if !ctrl.iter().any_(|x| x == &(k, v)) {
if !ctrl.iter().any(|x| x == &(k, v)) {
assert!(map.insert(k, v));
ctrl.push((k, v));
check_structure(&map);

View file

@ -194,7 +194,7 @@ pub fn metas_in_cfg(cfg: &[@ast::meta_item],
if cfg_metas.iter().all(|c| c.is_empty()) { return true; }
cfg_metas.iter().any_(|cfg_meta| {
cfg_metas.iter().any(|cfg_meta| {
cfg_meta.iter().all(|cfg_mi| {
match cfg_mi.node {
ast::meta_list(s, ref it) if "not" == s

View file

@ -102,7 +102,7 @@ pub fn get_used_crate_files(cstore: &CStore) -> ~[Path] {
pub fn add_used_library(cstore: &mut CStore, lib: @str) -> bool {
assert!(!lib.is_empty());
if cstore.used_libraries.iter().any_(|x| x == &lib) { return false; }
if cstore.used_libraries.iter().any(|x| x == &lib) { return false; }
cstore.used_libraries.push(lib);
true
}

View file

@ -506,7 +506,7 @@ impl FlowedMoveData {
for self.dfcx_moves.each_bit_on_entry_frozen(id) |index| {
let move = &self.move_data.moves[index];
let moved_path = move.path;
if base_indices.iter().any_(|x| x == &moved_path) {
if base_indices.iter().any(|x| x == &moved_path) {
// Scenario 1 or 2: `loan_path` or some base path of
// `loan_path` was moved.
if !f(move, self.move_data.path(moved_path).loan_path) {
@ -535,7 +535,7 @@ impl FlowedMoveData {
-> bool {
//! True if `id` is the id of the LHS of an assignment
self.move_data.assignee_ids.iter().any_(|x| x == &id)
self.move_data.assignee_ids.iter().any(|x| x == &id)
}
pub fn each_assignment_of(&self,

View file

@ -224,7 +224,7 @@ pub fn check_item_recursion(sess: Session,
(visitor.visit_item)(it, (env, visitor));
fn visit_item(it: @item, (env, v): (env, visit::vt<env>)) {
if env.idstack.iter().any_(|x| x == &(it.id)) {
if env.idstack.iter().any(|x| x == &(it.id)) {
env.sess.span_fatal(env.root_it.span, "recursive constant");
}
env.idstack.push(it.id);

View file

@ -371,7 +371,7 @@ pub fn missing_ctor(cx: &MatchCheckCtxt,
let variants = ty::enum_variants(cx.tcx, eid);
if found.len() != (*variants).len() {
for (*variants).iter().advance |v| {
if !found.iter().any_(|x| x == &(variant(v.id))) {
if !found.iter().any(|x| x == &(variant(v.id))) {
return Some(variant(v.id));
}
}
@ -805,13 +805,13 @@ pub fn is_refutable(cx: &MatchCheckCtxt, pat: &pat) -> bool {
}
pat_lit(_) | pat_range(_, _) => { true }
pat_struct(_, ref fields, _) => {
fields.iter().any_(|f| is_refutable(cx, f.pat))
fields.iter().any(|f| is_refutable(cx, f.pat))
}
pat_tup(ref elts) => {
elts.iter().any_(|elt| is_refutable(cx, *elt))
elts.iter().any(|elt| is_refutable(cx, *elt))
}
pat_enum(_, Some(ref args)) => {
args.iter().any_(|a| is_refutable(cx, *a))
args.iter().any(|a| is_refutable(cx, *a))
}
pat_enum(_,_) => { false }
pat_vec(*) => { true }

View file

@ -341,14 +341,14 @@ impl<O:DataFlowOperator+Copy+'static> DataFlowContext<O> {
let entry_str = bits_to_str(on_entry);
let gens = self.gens.slice(start, end);
let gens_str = if gens.iter().any_(|&u| u != 0) {
let gens_str = if gens.iter().any(|&u| u != 0) {
fmt!(" gen: %s", bits_to_str(gens))
} else {
~""
};
let kills = self.kills.slice(start, end);
let kills_str = if kills.iter().any_(|&u| u != 0) {
let kills_str = if kills.iter().any(|&u| u != 0) {
fmt!(" kill: %s", bits_to_str(kills))
} else {
~""
@ -643,7 +643,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
self.walk_opt_expr(o_e, in_out, loop_scopes);
// is this a return from a `for`-loop closure?
match loop_scopes.iter().position_(|s| s.loop_kind == ForLoop) {
match loop_scopes.iter().position(|s| s.loop_kind == ForLoop) {
Some(i) => {
// if so, add the in_out bits to the state
// upon exit. Remember that we cannot count
@ -916,7 +916,7 @@ impl<'self, O:DataFlowOperator> PropagationContext<'self, O> {
Some(_) => {
match self.tcx().def_map.find(&expr.id) {
Some(&ast::def_label(loop_id)) => {
match loop_scopes.iter().position_(|l| l.loop_id == loop_id) {
match loop_scopes.iter().position(|l| l.loop_id == loop_id) {
Some(i) => i,
None => {
self.tcx().sess.span_bug(

View file

@ -536,7 +536,7 @@ pub fn check_cast_for_escaping_regions(
// Check, based on the region associated with the trait, whether it can
// possibly escape the enclosing fn item (note that all type parameters
// must have been declared on the enclosing fn item).
if target_regions.iter().any_(|r| is_re_scope(*r)) {
if target_regions.iter().any(|r| is_re_scope(*r)) {
return; /* case (1) */
}
@ -551,7 +551,7 @@ pub fn check_cast_for_escaping_regions(
|_r| {
// FIXME(#5723) --- turn this check on once &Objects are usable
//
// if !target_regions.iter().any_(|t_r| is_subregion_of(cx, *t_r, r)) {
// if !target_regions.iter().any(|t_r| is_subregion_of(cx, *t_r, r)) {
// cx.tcx.sess.span_err(
// source.span,
// fmt!("source contains borrowed pointer with lifetime \
@ -565,7 +565,7 @@ pub fn check_cast_for_escaping_regions(
|ty| {
match ty::get(ty).sty {
ty::ty_param(source_param) => {
if target_params.iter().any_(|x| x == &source_param) {
if target_params.iter().any(|x| x == &source_param) {
/* case (2) */
} else {
check_durable(cx.tcx, ty, source.span); /* case (3) */

View file

@ -898,7 +898,7 @@ fn check_item_non_uppercase_statics(cx: &Context, it: &ast::item) {
// check for lowercase letters rather than non-uppercase
// ones (some scripts don't have a concept of
// upper/lowercase)
if s.iter().any_(|c| c.is_lowercase()) {
if s.iter().any(|c| c.is_lowercase()) {
cx.span_lint(non_uppercase_statics, it.span,
"static constant should have an uppercase identifier");
}
@ -1038,7 +1038,7 @@ fn lint_missing_doc() -> visit::vt<@mut Context> {
// If we have doc(hidden), nothing to do
if cx.doc_hidden { return }
// If we're documented, nothing to do
if attrs.iter().any_(|a| a.node.is_sugared_doc) { return }
if attrs.iter().any(|a| a.node.is_sugared_doc) { return }
// otherwise, warn!
cx.span_lint(missing_doc, sp, msg);

View file

@ -390,8 +390,8 @@ impl VisitContext {
// any fields which (1) were not explicitly
// specified and (2) have a type that
// moves-by-default:
let consume_with = with_fields.iter().any_(|tf| {
!fields.iter().any_(|f| f.node.ident == tf.ident) &&
let consume_with = with_fields.iter().any(|tf| {
!fields.iter().any(|f| f.node.ident == tf.ident) &&
ty::type_moves_by_default(self.tcx, tf.mt.ty)
});

View file

@ -259,7 +259,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
method_id.node);
if is_private &&
(container_id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &(container_id.node))) {
!privileged_items.iter().any(|x| x == &(container_id.node))) {
tcx.sess.span_err(span,
fmt!("method `%s` is private",
token::ident_to_str(name)));
@ -287,7 +287,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
def_fn(def_id, _) => {
if def_id.crate == local_crate {
if local_item_is_private(span, def_id.node) &&
!privileged_items.iter().any_(|x| x == &def_id.node) {
!privileged_items.iter().any(|x| x == &def_id.node) {
tcx.sess.span_err(span,
fmt!("function `%s` is private",
token::ident_to_str(path.idents.last())));
@ -332,7 +332,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
provided(method)
if method.vis == private &&
!privileged_items.iter()
.any_(|x| x == &(trait_id.node)) => {
.any(|x| x == &(trait_id.node)) => {
tcx.sess.span_err(span,
fmt!("method `%s` is private",
token::ident_to_str(&method
@ -417,7 +417,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
base))).sty {
ty_struct(id, _)
if id.crate != local_crate || !privileged_items.iter()
.any_(|x| x == &(id.node)) => {
.any(|x| x == &(id.node)) => {
debug!("(privacy checking) checking field access");
check_field(expr.span, id, ident);
}
@ -430,7 +430,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
base))).sty {
ty_struct(id, _)
if id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &(id.node)) => {
!privileged_items.iter().any(|x| x == &(id.node)) => {
match method_map.find(&expr.id) {
None => {
tcx.sess.span_bug(expr.span,
@ -456,7 +456,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
match ty::get(ty::expr_ty(tcx, expr)).sty {
ty_struct(id, _) => {
if id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &(id.node)) {
!privileged_items.iter().any(|x| x == &(id.node)) {
for (*fields).iter().advance |field| {
debug!("(privacy checking) checking \
field in struct literal");
@ -467,7 +467,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
}
ty_enum(id, _) => {
if id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &(id.node)) {
!privileged_items.iter().any(|x| x == &(id.node)) {
match tcx.def_map.get_copy(&expr.id) {
def_variant(_, variant_id) => {
for (*fields).iter().advance |field| {
@ -504,7 +504,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
match ty::get(ty::expr_ty(tcx, operand)).sty {
ty_enum(id, _) => {
if id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &(id.node)) {
!privileged_items.iter().any(|x| x == &(id.node)) {
check_variant(expr.span, id);
}
}
@ -522,7 +522,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
match ty::get(ty::pat_ty(tcx, pattern)).sty {
ty_struct(id, _) => {
if id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &(id.node)) {
!privileged_items.iter().any(|x| x == &(id.node)) {
for fields.iter().advance |field| {
debug!("(privacy checking) checking \
struct pattern");
@ -533,7 +533,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
}
ty_enum(enum_id, _) => {
if enum_id.crate != local_crate ||
!privileged_items.iter().any_(|x| x == &enum_id.node) {
!privileged_items.iter().any(|x| x == &enum_id.node) {
match tcx.def_map.find(&pattern.id) {
Some(&def_variant(_, variant_id)) => {
for fields.iter().advance |field| {

View file

@ -78,7 +78,7 @@ impl RegionMaps {
pub fn relate_free_regions(&mut self, sub: FreeRegion, sup: FreeRegion) {
match self.free_region_map.find_mut(&sub) {
Some(sups) => {
if !sups.iter().any_(|x| x == &sup) {
if !sups.iter().any(|x| x == &sup) {
sups.push(sup);
}
return;
@ -202,7 +202,7 @@ impl RegionMaps {
return true;
}
if !queue.iter().any_(|x| x == parent) {
if !queue.iter().any(|x| x == parent) {
queue.push(*parent);
}
}
@ -612,7 +612,7 @@ impl DetermineRpCtxt {
ambient_variance: self.ambient_variance,
id: self.item_id
};
if !vec.iter().any_(|x| x == &dep) { vec.push(dep); }
if !vec.iter().any(|x| x == &dep) { vec.push(dep); }
}
// Determines whether a reference to a region that appears in the

View file

@ -796,7 +796,7 @@ pub fn enter_region<'r>(bcx: block,
pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
let ccx = bcx.ccx();
fn add_to_set(tcx: ty::ctxt, set: &mut ~[Opt], val: Opt) {
if set.iter().any_(|l| opt_eq(tcx, l, &val)) {return;}
if set.iter().any(|l| opt_eq(tcx, l, &val)) {return;}
set.push(val);
}
@ -963,7 +963,7 @@ pub fn collect_record_or_struct_fields(bcx: block,
fn extend(idents: &mut ~[ast::ident], field_pats: &[ast::field_pat]) {
for field_pats.iter().advance |field_pat| {
let field_ident = field_pat.ident;
if !idents.iter().any_(|x| *x == field_ident) {
if !idents.iter().any(|x| *x == field_ident) {
idents.push(field_ident);
}
}
@ -974,7 +974,7 @@ pub fn pats_require_rooting(bcx: block,
m: &[@Match],
col: uint)
-> bool {
do m.iter().any_ |br| {
do m.iter().any |br| {
let pat_id = br.pats[col].id;
let key = root_map_key {id: pat_id, derefs: 0u };
bcx.ccx().maps.root_map.contains_key(&key)
@ -1003,7 +1003,7 @@ pub fn root_pats_as_necessary(mut bcx: block,
// matches may be wildcards like _ or identifiers).
macro_rules! any_pat (
($m:expr, $pattern:pat) => (
do ($m).iter().any_ |br| {
do ($m).iter().any |br| {
match br.pats[col].node {
$pattern => true,
_ => false
@ -1029,7 +1029,7 @@ pub fn any_tup_pat(m: &[@Match], col: uint) -> bool {
}
pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
do m.iter().any_ |br| {
do m.iter().any |br| {
let pat = br.pats[col];
match pat.node {
ast::pat_enum(_, Some(_)) => {

View file

@ -147,7 +147,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
mk_struct(cx, self.tys, false).size == 0
}
fn find_ptr(&self) -> Option<uint> {
self.tys.iter().position_(|&ty| mono_data_classify(ty) == MonoNonNull)
self.tys.iter().position(|&ty| mono_data_classify(ty) == MonoNonNull)
}
}

View file

@ -413,7 +413,7 @@ pub fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
// drop glue checks whether it is zero.
pub fn revoke_clean(cx: block, val: ValueRef) {
do in_scope_cx(cx, None) |scope_info| {
let cleanup_pos = scope_info.cleanups.iter().position_(
let cleanup_pos = scope_info.cleanups.iter().position(
|cu| match *cu {
clean_temp(v, _, _) if v == val => true,
_ => false

View file

@ -91,7 +91,7 @@ pub fn const_vec(cx: @mut CrateContext, e: &ast::expr, es: &[@ast::expr])
let sz = llvm::LLVMConstMul(C_uint(cx, es.len()), unit_sz);
let vs = es.map(|e| const_expr(cx, *e));
// If the vector contains enums, an LLVM array won't work.
let v = if vs.iter().any_(|vi| val_ty(*vi) != llunitty) {
let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
C_struct(vs)
} else {
C_array(llunitty, vs)

View file

@ -1147,7 +1147,7 @@ fn trans_rec_or_struct(bcx: block,
let mut need_base = vec::from_elem(field_tys.len(), true);
let numbered_fields = do fields.map |field| {
let opt_pos = field_tys.iter().position_(|field_ty| field_ty.ident == field.node.ident);
let opt_pos = field_tys.iter().position(|field_ty| field_ty.ident == field.node.ident);
match opt_pos {
Some(i) => {
need_base[i] = false;
@ -1171,7 +1171,7 @@ fn trans_rec_or_struct(bcx: block,
fields: leftovers })
}
None => {
if need_base.iter().any_(|b| *b) {
if need_base.iter().any(|b| *b) {
tcx.sess.span_bug(expr_span, "missing fields and no base expr")
}
None

View file

@ -84,7 +84,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
let hash_id = make_mono_id(ccx, fn_id, impl_did_opt,
&*psubsts,
Some(param_uses));
if hash_id.params.iter().any_(
if hash_id.params.iter().any(
|p| match *p { mono_precise(_, _) => false, _ => true }) {
must_cast = true;
}

View file

@ -1485,8 +1485,8 @@ pub fn type_needs_subst(ty: t) -> bool {
}
pub fn trait_ref_contains_error(tref: &ty::TraitRef) -> bool {
tref.substs.self_ty.iter().any_(|&t| type_is_error(t)) ||
tref.substs.tps.iter().any_(|&t| type_is_error(t))
tref.substs.self_ty.iter().any(|&t| type_is_error(t)) ||
tref.substs.tps.iter().any(|&t| type_is_error(t))
}
pub fn type_is_ty_var(ty: t) -> bool {
@ -2342,13 +2342,13 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
ty_struct(did, ref substs) => {
seen.push(did);
let fields = struct_fields(cx, did, substs);
let r = fields.iter().any_(|f| type_requires(cx, seen, r_ty, f.mt.ty));
let r = fields.iter().any(|f| type_requires(cx, seen, r_ty, f.mt.ty));
seen.pop();
r
}
ty_tup(ref ts) => {
ts.iter().any_(|t| type_requires(cx, seen, r_ty, *t))
ts.iter().any(|t| type_requires(cx, seen, r_ty, *t))
}
ty_enum(ref did, _) if seen.contains(did) => {
@ -2359,7 +2359,7 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
seen.push(did);
let vs = enum_variants(cx, did);
let r = !vs.is_empty() && do vs.iter().all |variant| {
do variant.args.iter().any_ |aty| {
do variant.args.iter().any |aty| {
let sty = subst(cx, substs, *aty);
type_requires(cx, seen, r_ty, sty)
}
@ -3241,7 +3241,7 @@ pub fn field_idx_strict(tcx: ty::ctxt, id: ast::ident, fields: &[field])
}
pub fn method_idx(id: ast::ident, meths: &[@Method]) -> Option<uint> {
meths.iter().position_(|m| m.ident == id)
meths.iter().position(|m| m.ident == id)
}
/// Returns a vector containing the indices of all type parameters that appear

View file

@ -553,7 +553,7 @@ pub fn bound_lifetimes<AC:AstConv>(
let special_idents = [special_idents::statik, special_idents::self_];
let mut bound_lifetime_names = opt_vec::Empty;
ast_lifetimes.map_to_vec(|ast_lifetime| {
if special_idents.iter().any_(|&i| i == ast_lifetime.ident) {
if special_idents.iter().any(|&i| i == ast_lifetime.ident) {
this.tcx().sess.span_err(
ast_lifetime.span,
fmt!("illegal lifetime parameter name: `%s`",

View file

@ -253,7 +253,7 @@ impl<'self> LookupContext<'self> {
ty_enum(did, _) => {
// Watch out for newtype'd enums like "enum t = @T".
// See discussion in typeck::check::do_autoderef().
if enum_dids.iter().any_(|x| x == &did) {
if enum_dids.iter().any(|x| x == &did) {
return None;
}
enum_dids.push(did);
@ -368,7 +368,7 @@ impl<'self> LookupContext<'self> {
let trait_methods = ty::trait_methods(tcx, bound_trait_ref.def_id);
let pos = {
match trait_methods.iter().position_(|m| {
match trait_methods.iter().position(|m| {
m.explicit_self != ast::sty_static &&
m.ident == self.m_name })
{
@ -412,7 +412,7 @@ impl<'self> LookupContext<'self> {
let tcx = self.tcx();
let ms = ty::trait_methods(tcx, did);
let index = match ms.iter().position_(|m| m.ident == self.m_name) {
let index = match ms.iter().position(|m| m.ident == self.m_name) {
Some(i) => i,
None => { return; } // no method with the right name
};
@ -466,7 +466,7 @@ impl<'self> LookupContext<'self> {
// First, try self methods
let mut method_info: Option<MethodInfo> = None;
let methods = ty::trait_methods(tcx, did);
match methods.iter().position_(|m| m.ident == self.m_name) {
match methods.iter().position(|m| m.ident == self.m_name) {
Some(i) => {
method_info = Some(MethodInfo {
method_ty: methods[i],
@ -482,7 +482,7 @@ impl<'self> LookupContext<'self> {
for ty::trait_supertraits(tcx, did).iter().advance |trait_ref| {
let supertrait_methods =
ty::trait_methods(tcx, trait_ref.def_id);
match supertrait_methods.iter().position_(|m| m.ident == self.m_name) {
match supertrait_methods.iter().position(|m| m.ident == self.m_name) {
Some(i) => {
method_info = Some(MethodInfo {
method_ty: supertrait_methods[i],
@ -538,7 +538,7 @@ impl<'self> LookupContext<'self> {
impl_info.methods.map(|m| m.ident).repr(self.tcx()));
let idx = {
match impl_info.methods.iter().position_(|m| m.ident == self.m_name) {
match impl_info.methods.iter().position(|m| m.ident == self.m_name) {
Some(idx) => idx,
None => { return; } // No method with the right name.
}

View file

@ -67,7 +67,7 @@ impl VtableContext {
}
fn has_trait_bounds(type_param_defs: &[ty::TypeParameterDef]) -> bool {
type_param_defs.iter().any_(
type_param_defs.iter().any(
|type_param_def| !type_param_def.bounds.trait_bounds.is_empty())
}

View file

@ -391,7 +391,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
generics, self_ty);
// FIXME(#5527) Could have same trait multiple times
if ty_trait_refs.iter().any_(|other_trait| other_trait.def_id == trait_ref.def_id) {
if ty_trait_refs.iter().any(|other_trait| other_trait.def_id == trait_ref.def_id) {
// This means a trait inherited from the same supertrait more
// than once.
tcx.sess.span_err(sp, "Duplicate supertrait in trait declaration");

View file

@ -540,7 +540,7 @@ pub fn var_ids<T:Combine>(this: &T, isr: isr_alist) -> ~[RegionVid] {
pub fn is_var_in_set(new_vars: &[RegionVid], r: ty::Region) -> bool {
match r {
ty::re_infer(ty::ReVar(ref v)) => new_vars.iter().any_(|x| x == v),
ty::re_infer(ty::ReVar(ref v)) => new_vars.iter().any(|x| x == v),
_ => false
}
}

View file

@ -184,7 +184,7 @@ impl Combine for Lub {
// with.
for list::each(a_isr) |pair| {
let (a_br, a_r) = *pair;
if tainted.iter().any_(|x| x == &a_r) {
if tainted.iter().any(|x| x == &a_r) {
debug!("generalize_region(r0=%?): \
replacing with %?, tainted=%?",
r0, a_br, tainted);

View file

@ -454,7 +454,7 @@ impl RegionVarBindings {
{
let mut result_set = result_set;
if r == r1 { // Clearly, this is potentially inefficient.
if !result_set.iter().any_(|x| *x == r2) {
if !result_set.iter().any(|x| *x == r2) {
result_set.push(r2);
}
}

View file

@ -199,7 +199,7 @@ impl Combine for Sub {
// or new variables:
match *tainted_region {
ty::re_infer(ty::ReVar(ref vid)) => {
if new_vars.iter().any_(|x| x == vid) { loop; }
if new_vars.iter().any(|x| x == vid) { loop; }
}
_ => {
if *tainted_region == skol { loop; }

View file

@ -212,7 +212,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
let lint_flags = vec::append(getopts::opt_strs(matches, "W"),
getopts::opt_strs(matches, "warn"));
let show_lint_options = lint_flags.iter().any_(|x| x == &~"help") ||
let show_lint_options = lint_flags.iter().any(|x| x == &~"help") ||
(opt_present(matches, "W") && lint_flags.is_empty());
if show_lint_options {
@ -221,7 +221,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
}
let r = getopts::opt_strs(matches, "Z");
if r.iter().any_(|x| x == &~"help") {
if r.iter().any(|x| x == &~"help") {
describe_debug_flags();
return;
}

View file

@ -57,7 +57,7 @@ pub fn parse_desc(attrs: ~[ast::attribute]) -> Option<~str> {
pub fn parse_hidden(attrs: ~[ast::attribute]) -> bool {
let r = doc_metas(attrs);
do r.iter().any_ |meta| {
do r.iter().any |meta| {
match attr::get_meta_item_list(*meta) {
Some(metas) => {
let hiddens = attr::find_meta_items_by_name(metas, "hidden");

View file

@ -64,7 +64,7 @@ pub mod util;
pub fn main() {
let args = os::args();
if args.iter().any_(|x| "-h" == *x) || args.iter().any_(|x| "--help" == *x) {
if args.iter().any(|x| "-h" == *x) || args.iter().any(|x| "--help" == *x) {
config::usage();
return;
}

View file

@ -381,7 +381,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
let crate_path = Path(*crate);
let crate_dir = crate_path.dirname();
repl.program.record_extern(fmt!("extern mod %s;", *crate));
if !repl.lib_search_paths.iter().any_(|x| x == &crate_dir) {
if !repl.lib_search_paths.iter().any(|x| x == &crate_dir) {
repl.lib_search_paths.push(crate_dir);
}
}

View file

@ -626,14 +626,14 @@ fn install_remove() {
command_line_test([~"install", ~"bar"], &dir);
command_line_test([~"install", ~"quux"], &dir);
let list_output = command_line_test_output([~"list"]);
assert!(list_output.iter().any_(|x| x == &~"foo"));
assert!(list_output.iter().any_(|x| x == &~"bar"));
assert!(list_output.iter().any_(|x| x == &~"quux"));
assert!(list_output.iter().any(|x| x == &~"foo"));
assert!(list_output.iter().any(|x| x == &~"bar"));
assert!(list_output.iter().any(|x| x == &~"quux"));
command_line_test([~"remove", ~"foo"], &dir);
let list_output = command_line_test_output([~"list"]);
assert!(!list_output.iter().any_(|x| x == &~"foo"));
assert!(list_output.iter().any_(|x| x == &~"bar"));
assert!(list_output.iter().any_(|x| x == &~"quux"));
assert!(!list_output.iter().any(|x| x == &~"foo"));
assert!(list_output.iter().any(|x| x == &~"bar"));
assert!(list_output.iter().any(|x| x == &~"quux"));
}
#[test]
@ -699,7 +699,7 @@ fn test_versions() {
command_line_test([~"install", ~"foo#0.1"], &workspace);
let output = command_line_test_output([~"list"]);
// make sure output includes versions
assert!(!output.iter().any_(|x| x == &~"foo#0.2"));
assert!(!output.iter().any(|x| x == &~"foo#0.2"));
}
#[test]

View file

@ -55,7 +55,7 @@ pub fn root() -> Path {
}
pub fn is_cmd(cmd: &str) -> bool {
COMMANDS.iter().any_(|&c| c == cmd)
COMMANDS.iter().any(|&c| c == cmd)
}
struct ListenerFn {

View file

@ -338,16 +338,16 @@ pub trait IteratorUtil<A> {
/// ~~~ {.rust}
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter();
/// assert!(it.any_(|&x| *x == 3));
/// assert!(!it.any_(|&x| *x == 3));
/// assert!(it.any(|&x| *x == 3));
/// assert!(!it.any(|&x| *x == 3));
/// ~~~
fn any_(&mut self, f: &fn(A) -> bool) -> bool;
fn any(&mut self, f: &fn(A) -> bool) -> bool;
/// Return the first element satisfying the specified predicate
fn find_(&mut self, predicate: &fn(&A) -> bool) -> Option<A>;
/// Return the index of the first element satisfying the specified predicate
fn position_(&mut self, predicate: &fn(A) -> bool) -> Option<uint>;
fn position(&mut self, predicate: &fn(A) -> bool) -> Option<uint>;
/// Count the number of elements satisfying the specified predicate
fn count(&mut self, predicate: &fn(A) -> bool) -> uint;
@ -504,7 +504,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
}
#[inline]
fn any_(&mut self, f: &fn(A) -> bool) -> bool {
fn any(&mut self, f: &fn(A) -> bool) -> bool {
for self.advance |x| { if f(x) { return true; } }
false
}
@ -520,7 +520,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
/// Return the index of the first element satisfying the specified predicate
#[inline]
fn position_(&mut self, predicate: &fn(A) -> bool) -> Option<uint> {
fn position(&mut self, predicate: &fn(A) -> bool) -> Option<uint> {
let mut i = 0;
for self.advance |x| {
if predicate(x) {
@ -1368,10 +1368,10 @@ mod tests {
#[test]
fn test_any() {
let v = ~&[1, 2, 3, 4, 5];
assert!(v.iter().any_(|&x| x < 10));
assert!(v.iter().any_(|&x| x.is_even()));
assert!(!v.iter().any_(|&x| x > 100));
assert!(!v.slice(0, 0).iter().any_(|_| fail!()));
assert!(v.iter().any(|&x| x < 10));
assert!(v.iter().any(|&x| x.is_even()));
assert!(!v.iter().any(|&x| x > 100));
assert!(!v.slice(0, 0).iter().any(|_| fail!()));
}
#[test]
@ -1385,9 +1385,9 @@ mod tests {
#[test]
fn test_position() {
let v = &[1, 3, 9, 27, 103, 14, 11];
assert_eq!(v.iter().position_(|x| *x & 1 == 0).unwrap(), 5);
assert_eq!(v.iter().position_(|x| *x % 3 == 0).unwrap(), 1);
assert!(v.iter().position_(|x| *x % 12 == 0).is_none());
assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5);
assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1);
assert!(v.iter().position(|x| *x % 12 == 0).is_none());
}
#[test]

View file

@ -587,7 +587,7 @@ pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
return cmd;
fn append_arg(cmd: &mut ~str, arg: &str) {
let quote = arg.iter().any_(|c| c == ' ' || c == '\t');
let quote = arg.iter().any(|c| c == ' ' || c == '\t');
if quote {
cmd.push_char('"');
}

View file

@ -278,7 +278,7 @@ impl CharEq for extern "Rust" fn(char) -> bool {
impl<'self, C: CharEq> CharEq for &'self [C] {
#[inline]
fn matches(&self, c: char) -> bool {
self.iter().any_(|m| m.matches(c))
self.iter().any(|m| m.matches(c))
}
fn only_ascii(&self) -> bool {

View file

@ -142,7 +142,7 @@ unsafe fn local_data_lookup<T: 'static>(
-> Option<(uint, *libc::c_void)> {
let key_value = key_to_key_value(key);
let map_pos = (*map).iter().position_(|entry|
let map_pos = (*map).iter().position(|entry|
match *entry {
Some((k,_,_)) => k == key_value,
None => false
@ -215,7 +215,7 @@ pub unsafe fn local_set<T: 'static>(
}
None => {
// Find an empty slot. If not, grow the vector.
match (*map).iter().position_(|x| x.is_none()) {
match (*map).iter().position(|x| x.is_none()) {
Some(empty_index) => { map[empty_index] = new_entry; }
None => { map.push(new_entry); }
}

View file

@ -191,7 +191,7 @@ impl<'self, T> Iterator<&'self [T]> for VecSplitIterator<'self, T> {
return Some(self.v);
}
match self.v.iter().position_(|x| (self.pred)(x)) {
match self.v.iter().position(|x| (self.pred)(x)) {
None => {
self.finished = true;
Some(self.v)
@ -1010,7 +1010,7 @@ impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] {
/// Find the first index containing a matching value
#[inline]
fn position_elem(&self, x: &T) -> Option<uint> {
self.iter().position_(|y| *x == *y)
self.iter().position(|y| *x == *y)
}
/// Find the last index containing a matching value

View file

@ -192,7 +192,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
ast::meta_list(ref nb, ref misb) => {
if na != nb { return false; }
for misa.iter().advance |mi| {
if !misb.iter().any_(|x| x == mi) { return false; }
if !misb.iter().any(|x| x == mi) { return false; }
}
true
}

View file

@ -198,7 +198,7 @@ pub fn expand_item(extsbox: @mut SyntaxEnv,
// does this attribute list contain "macro_escape" ?
pub fn contains_macro_escape (attrs: &[ast::attribute]) -> bool {
attrs.iter().any_(|attr| "macro_escape" == attr::get_attr_name(attr))
attrs.iter().any(|attr| "macro_escape" == attr::get_attr_name(attr))
}
// Support for item-position macro invocations, exactly the same

View file

@ -3914,7 +3914,7 @@ impl Parser {
};
let full_path = full_path.normalize();
let maybe_i = do self.sess.included_mod_stack.iter().position_ |&p| { p == full_path };
let maybe_i = do self.sess.included_mod_stack.iter().position |&p| { p == full_path };
match maybe_i {
Some(i) => {
let stack = &self.sess.included_mod_stack;

View file

@ -44,7 +44,7 @@ fn maybe_run_test(argv: &[~str], name: ~str, test: &fn()) {
if os::getenv(~"RUST_BENCH").is_some() {
run_test = true
} else if argv.len() > 0 {
run_test = argv.iter().any_(|x| x == &~"all") || argv.iter().any_(|x| x == &name)
run_test = argv.iter().any(|x| x == &~"all") || argv.iter().any(|x| x == &name)
}
if !run_test {

View file

@ -111,7 +111,7 @@ fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {
while keys.len() < n {
let k = r.gen_uint_range(0u, graph.len());
if graph[k].len() > 0u && graph[k].iter().any_(|i| {
if graph[k].len() > 0u && graph[k].iter().any(|i| {
*i != k as node_id
}) {
keys.insert(k as node_id);
@ -187,7 +187,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
}
let mut i = 0;
while colors.iter().any_(is_gray) {
while colors.iter().any(is_gray) {
// Do the BFS.
info!("PBFS iteration %?", i);
i += 1;
@ -402,7 +402,7 @@ fn validate(edges: ~[(node_id, node_id)],
if *v == -1i64 || u == root {
true
} else {
edges.iter().any_(|x| x == &(u, *v)) || edges.iter().any_(|x| x == &(*v, u))
edges.iter().any(|x| x == &(u, *v)) || edges.iter().any(|x| x == &(*v, u))
}
};
result

View file

@ -20,20 +20,20 @@ pub fn main() {
}
// Usable at all:
let mut any_negative = do v.iter().any_ |e| { e.is_negative() };
let mut any_negative = do v.iter().any |e| { e.is_negative() };
assert!(any_negative);
// Higher precedence than assignments:
any_negative = do v.iter().any_ |e| { e.is_negative() };
any_negative = do v.iter().any |e| { e.is_negative() };
assert!(any_negative);
// Higher precedence than unary operations:
let abs_v = do v.iter().transform |e| { e.abs() }.collect::<~[float]>();
assert!(do abs_v.iter().all |e| { e.is_positive() });
assert!(!do abs_v.iter().any_ |e| { e.is_negative() });
assert!(!do abs_v.iter().any |e| { e.is_negative() });
// Usable in funny statement-like forms:
if !do v.iter().any_ |e| { e.is_positive() } {
if !do v.iter().any |e| { e.is_positive() } {
assert!(false);
}
match do v.iter().all |e| { e.is_negative() } {
@ -41,7 +41,7 @@ pub fn main() {
false => { }
}
match 3 {
_ if do v.iter().any_ |e| { e.is_negative() } => {
_ if do v.iter().any |e| { e.is_negative() } => {
}
_ => {
fail!("wrong answer.");
@ -58,7 +58,7 @@ pub fn main() {
// In the tail of a block
let w =
if true { do abs_v.iter().any_ |e| { e.is_positive() } }
if true { do abs_v.iter().any |e| { e.is_positive() } }
else { false };
assert!(w);
}

View file

@ -29,8 +29,8 @@ fn checktests() {
let tests = __test::TESTS;
assert!(
tests.iter().any_(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldignore" && t.desc.ignore));
assert!(
tests.iter().any_(|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore));
tests.iter().any(|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore));
}