diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index b2bb53d395f..fe42fe9e36c 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -2,17 +2,19 @@ // workaround our lack of traits and lack of macros. See core.{rc,rs} for // how this file is used. +#[warn(deprecated_mode)]; + use cmp::{Eq, Ord}; use inst::{IMPL_T, EACH, SIZE_HINT}; export extensions; impl IMPL_T: iter::BaseIter { - pure fn each(blk: fn(v: &A) -> bool) { EACH(self, blk) } - pure fn size_hint() -> Option { SIZE_HINT(self) } + pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) } + pure fn size_hint() -> Option { SIZE_HINT(&self) } } impl IMPL_T: iter::ExtendedIter { - pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } + pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) } pure fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) } pure fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) } pure fn foldl(+b0: B, blk: fn(B, A) -> B) -> B { @@ -24,8 +26,8 @@ impl IMPL_T: iter::ExtendedIter { } impl IMPL_T: iter::EqIter { - pure fn contains(x: A) -> bool { iter::contains(self, x) } - pure fn count(x: A) -> uint { iter::count(self, x) } + pure fn contains(x: &A) -> bool { iter::contains(self, x) } + pure fn count(x: &A) -> uint { iter::count(self, x) } } impl IMPL_T: iter::CopyableIter { diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index b6bbc1f70c0..1cf28f81dcc 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -8,7 +8,7 @@ type IMPL_T = dlist::DList; * e.g. breadth-first search with in-place enqueues), but removing the current * node is forbidden. */ -pure fn EACH(self: IMPL_T, f: fn(v: &A) -> bool) { +pure fn EACH(self: &IMPL_T, f: fn(v: &A) -> bool) { let mut link = self.peek_n(); while option::is_some(&link) { let nobe = option::get(&link); @@ -29,6 +29,6 @@ pure fn EACH(self: IMPL_T, f: fn(v: &A) -> bool) { } } -pure fn SIZE_HINT(self: IMPL_T) -> Option { +pure fn SIZE_HINT(self: &IMPL_T) -> Option { Some(self.len()) } diff --git a/src/libcore/iter-trait/dvec.rs b/src/libcore/iter-trait/dvec.rs index 0f51df7b545..049b13da265 100644 --- a/src/libcore/iter-trait/dvec.rs +++ b/src/libcore/iter-trait/dvec.rs @@ -6,7 +6,7 @@ type IMPL_T = dvec::DVec; * * Attempts to access this dvec during iteration will fail. */ -pure fn EACH(self: IMPL_T, f: fn(v: &A) -> bool) { +pure fn EACH(self: &IMPL_T, f: fn(v: &A) -> bool) { unsafe { do self.swap |v| { v.each(f); @@ -15,6 +15,6 @@ pure fn EACH(self: IMPL_T, f: fn(v: &A) -> bool) { } } -pure fn SIZE_HINT(self: IMPL_T) -> Option { +pure fn SIZE_HINT(self: &IMPL_T) -> Option { Some(self.len()) } diff --git a/src/libcore/iter-trait/option.rs b/src/libcore/iter-trait/option.rs index e1ffec0a7d7..2f7f7a4be7b 100644 --- a/src/libcore/iter-trait/option.rs +++ b/src/libcore/iter-trait/option.rs @@ -1,16 +1,16 @@ #[allow(non_camel_case_types)] type IMPL_T = Option; -pure fn EACH(self: IMPL_T, f: fn(v: &A) -> bool) { - match self { +pure fn EACH(self: &IMPL_T, f: fn(v: &A) -> bool) { + match *self { None => (), Some(ref a) => { f(a); } } } -pure fn SIZE_HINT(self: IMPL_T) -> Option { - match self { - None => Some(0u), - Some(_) => Some(1u) +pure fn SIZE_HINT(self: &IMPL_T) -> Option { + match *self { + None => Some(0), + Some(_) => Some(1) } } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 8af4ce3d0b1..dade851473b 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -23,8 +23,8 @@ trait ExtendedIter { } trait EqIter { - pure fn contains(x: A) -> bool; - pure fn count(x: A) -> uint; + pure fn contains(x: &A) -> bool; + pure fn count(x: &A) -> uint; } trait Times { @@ -66,11 +66,11 @@ trait Buildable { builder: fn(push: pure fn(+v: A))) -> self; } -pure fn eachi>(self: IA, blk: fn(uint, v: &A) -> bool) { - let mut i = 0u; +pure fn eachi>(self: &IA, blk: fn(uint, v: &A) -> bool) { + let mut i = 0; for self.each |a| { if !blk(i, a) { break; } - i += 1u; + i += 1; } } @@ -130,17 +130,17 @@ pure fn to_vec>(self: IA) -> ~[A] { foldl::(self, ~[], |r, a| vec::append(copy r, ~[a])) } -pure fn contains>(self: IA, x: A) -> bool { +pure fn contains>(self: IA, x: &A) -> bool { for self.each |a| { - if *a == x { return true; } + if *a == *x { return true; } } return false; } -pure fn count>(self: IA, x: A) -> uint { - do foldl(self, 0u) |count, value| { - if value == x { - count + 1u +pure fn count>(self: IA, x: &A) -> uint { + do foldl(self, 0) |count, value| { + if value == *x { + count + 1 } else { count } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index eaaf11dab5d..13fb2260045 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -377,7 +377,7 @@ fn unshift_char(s: &mut ~str, ch: char) { pure fn trim_left_chars(s: &str, chars_to_trim: &[char]) -> ~str { if chars_to_trim.is_empty() { return from_slice(s); } - match find(s, |c| !chars_to_trim.contains(c)) { + match find(s, |c| !chars_to_trim.contains(&c)) { None => ~"", Some(first) => unsafe { raw::slice_bytes(s, first, s.len()) } } @@ -395,7 +395,7 @@ pure fn trim_left_chars(s: &str, chars_to_trim: &[char]) -> ~str { pure fn trim_right_chars(s: &str, chars_to_trim: &[char]) -> ~str { if chars_to_trim.is_empty() { return str::from_slice(s); } - match rfind(s, |c| !chars_to_trim.contains(c)) { + match rfind(s, |c| !chars_to_trim.contains(&c)) { None => ~"", Some(last) => { let {next, _} = char_range_at(s, last); diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index e3df52b3cd6..7c5f242e8ba 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1873,7 +1873,7 @@ impl &[A]: iter::BaseIter { } impl &[A]: iter::ExtendedIter { - pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } + pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) } pure fn all(blk: fn(A) -> bool) -> bool { iter::all(self, blk) } pure fn any(blk: fn(A) -> bool) -> bool { iter::any(self, blk) } pure fn foldl(+b0: B, blk: fn(B, A) -> B) -> B { @@ -1885,8 +1885,8 @@ impl &[A]: iter::ExtendedIter { } impl &[A]: iter::EqIter { - pure fn contains(x: A) -> bool { iter::contains(self, x) } - pure fn count(x: A) -> uint { iter::count(self, x) } + pure fn contains(x: &A) -> bool { iter::contains(self, x) } + pure fn count(x: &A) -> uint { iter::count(self, x) } } impl &[A]: iter::CopyableIter { diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 2a27aed773d..8116bd4fb30 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -524,7 +524,7 @@ fn get_authority(rawurl: &str) -> let host_is_end_plus_one: &fn() -> bool = || { end+1 == len - && !['?', '#', '/'].contains(rawurl[end] as char) + && !['?', '#', '/'].contains(&(rawurl[end] as char)) }; // finish up diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 1b4b47f1014..0306d0dbb18 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -140,12 +140,12 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { let lint_flags = vec::append(getopts::opt_strs(matches, ~"W"), getopts::opt_strs(matches, ~"warn")); - if lint_flags.contains(~"help") { + if lint_flags.contains(&~"help") { describe_warnings(); return; } - if getopts::opt_strs(matches, ~"Z").contains(~"help") { + if getopts::opt_strs(matches, ~"Z").contains(&~"help") { describe_debug_flags(); return; } diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index c0aaa041d18..cedab91b04e 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -204,7 +204,7 @@ impl check_loan_ctxt { let did = ast_util::def_id_of_def(def); let is_fn_arg = did.crate == ast::local_crate && - (*self.fn_args).contains(did.node); + (*self.fn_args).contains(&(did.node)); if is_fn_arg { return; } // case (a) above } ast::expr_fn_block(*) | ast::expr_fn(*) | @@ -251,7 +251,7 @@ impl check_loan_ctxt { let def = self.tcx().def_map.get(expr.id); let did = ast_util::def_id_of_def(def); did.crate == ast::local_crate && - (*self.fn_args).contains(did.node) + (*self.fn_args).contains(&(did.node)) } ast::expr_fn_block(*) | ast::expr_fn(*) => { self.is_stack_closure(expr.id) diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 0d8d8b8dfe0..32801ed760c 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -275,7 +275,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option { let variants = ty::enum_variants(tcx, eid); if found.len() != (*variants).len() { for vec::each(*variants) |v| { - if !found.contains(variant(v.id)) { + if !found.contains(&(variant(v.id))) { return Some(variant(v.id)); } } diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index e194a907ffd..53bdf3db868 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -169,7 +169,7 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map, visitor.visit_item(it, env, visitor); fn visit_item(it: @item, &&env: env, v: visit::vt) { - if (*env.idstack).contains(it.id) { + if (*env.idstack).contains(&(it.id)) { env.sess.span_fatal(env.root_it.span, ~"recursive constant"); } (*env.idstack).push(it.id); diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 0f918ba92a9..4f9045ec77e 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -199,13 +199,13 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, let id = ast_util::def_id_of_def(fv.def).node; // skip over free variables that appear in the cap clause - if captured_vars.contains(id) { loop; } + if captured_vars.contains(&id) { loop; } // if this is the last use of the variable, then it will be // a move and not a copy let is_move = { match cx.last_use_map.find(fn_id) { - Some(vars) => (*vars).contains(id), + Some(vars) => (*vars).contains(&id), None => false } }; @@ -588,7 +588,7 @@ fn check_cast_for_escaping_regions( do ty::walk_ty(source_ty) |ty| { match ty::get(ty).sty { ty::ty_param(source_param) => { - if target_params.contains(source_param) { + if target_params.contains(&source_param) { /* case (2) */ } else { check_owned(cx.tcx, ty, source.span); /* case (3) */ diff --git a/src/rustc/middle/privacy.rs b/src/rustc/middle/privacy.rs index 6b0df4630da..4d291ceb590 100644 --- a/src/rustc/middle/privacy.rs +++ b/src/rustc/middle/privacy.rs @@ -56,7 +56,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { if method.vis == private && (impl_id.crate != local_crate || !privileged_items - .contains(impl_id.node)) { + .contains(&(impl_id.node))) { tcx.sess.span_err(span, fmt!("method `%s` is \ private", @@ -95,9 +95,9 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { } match methods[method_num] { provided(method) - if method.vis == private && - !privileged_items - .contains(trait_id.node) => { + if method.vis == private && + !privileged_items + .contains(&(trait_id.node)) => { tcx.sess.span_err(span, fmt!("method `%s` \ @@ -157,7 +157,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { match ty::get(ty::expr_ty(tcx, base)).sty { ty_class(id, _) if id.crate != local_crate || - !privileged_items.contains(id.node) => { + !privileged_items.contains(&(id.node)) => { match method_map.find(expr.id) { None => { debug!("(privacy checking) checking \ @@ -178,7 +178,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { match ty::get(ty::expr_ty(tcx, expr)).sty { ty_class(id, _) => { if id.crate != local_crate || - !privileged_items.contains(id.node) { + !privileged_items.contains(&(id.node)) { for fields.each |field| { debug!("(privacy checking) checking \ field in struct literal"); @@ -205,7 +205,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) { match ty::get(ty::pat_ty(tcx, pattern)).sty { ty_class(id, _) => { if id.crate != local_crate || - !privileged_items.contains(id.node) { + !privileged_items.contains(&(id.node)) { for fields.each |field| { debug!("(privacy checking) checking \ struct pattern"); diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index cf496ae6683..ae1c739b26b 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -485,7 +485,7 @@ impl determine_rp_ctxt { } }; let dep = {ambient_variance: self.ambient_variance, id: self.item_id}; - if !vec.contains(dep) { vec.push(dep); } + if !vec.contains(&dep) { vec.push(dep); } } // Determines whether a reference to a region that appears in the diff --git a/src/rustc/middle/trans/expr.rs b/src/rustc/middle/trans/expr.rs index 0a38e19a26c..17a1ff112cd 100644 --- a/src/rustc/middle/trans/expr.rs +++ b/src/rustc/middle/trans/expr.rs @@ -813,7 +813,7 @@ fn trans_local_var(bcx: block, ref_id: ast::node_id, def: ast::def) -> Datum { nid: ast::node_id) -> Datum { let is_last_use = match bcx.ccx().maps.last_use_map.find(ref_id) { None => false, - Some(vars) => (*vars).contains(nid) + Some(vars) => (*vars).contains(&nid) }; let source = if is_last_use {FromLastUseLvalue} else {FromLvalue}; diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 085ee51eff7..d08d3e9b847 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -182,7 +182,7 @@ impl LookupContext { ty_enum(did, _) => { // Watch out for newtype'd enums like "enum t = @T". // See discussion in typeck::check::do_autoderef(). - if enum_dids.contains(did) { + if enum_dids.contains(&did) { return None; } enum_dids.push(did); diff --git a/src/rustdoc/rustdoc.rs b/src/rustdoc/rustdoc.rs index 648d1d7a322..50ebef05afb 100755 --- a/src/rustdoc/rustdoc.rs +++ b/src/rustdoc/rustdoc.rs @@ -5,7 +5,7 @@ use config::Config; fn main(args: ~[~str]) { - if args.contains(~"-h") || args.contains(~"--help") { + if args.contains(&~"-h") || args.contains(&~"--help") { config::usage(); return; } diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 24faa53fda4..2bbbbf7ef17 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -9,7 +9,7 @@ fn foo_func>(x: B) -> Option { x.foo() } fn main() { - for iter::eachi(Some({a: 0})) |i, a| { + for iter::eachi(&(Some({a: 0}))) |i, a| { #debug["%u %d", i, a.a]; } diff --git a/src/test/run-pass/iter-contains.rs b/src/test/run-pass/iter-contains.rs index 43bce3e7dcb..6036b5b2d24 100644 --- a/src/test/run-pass/iter-contains.rs +++ b/src/test/run-pass/iter-contains.rs @@ -1,10 +1,10 @@ fn main() { - assert []/_.contains(22u) == false; - assert [1u, 3u]/_.contains(22u) == false; - assert [22u, 1u, 3u]/_.contains(22u) == true; - assert [1u, 22u, 3u]/_.contains(22u) == true; - assert [1u, 3u, 22u]/_.contains(22u) == true; - assert None.contains(22u) == false; - assert Some(1u).contains(22u) == false; - assert Some(22u).contains(22u) == true; + assert []/_.contains(&22u) == false; + assert [1u, 3u]/_.contains(&22u) == false; + assert [22u, 1u, 3u]/_.contains(&22u) == true; + assert [1u, 22u, 3u]/_.contains(&22u) == true; + assert [1u, 3u, 22u]/_.contains(&22u) == true; + assert None.contains(&22u) == false; + assert Some(1u).contains(&22u) == false; + assert Some(22u).contains(&22u) == true; } diff --git a/src/test/run-pass/iter-count.rs b/src/test/run-pass/iter-count.rs index ba22cc7710b..0b6f94367be 100644 --- a/src/test/run-pass/iter-count.rs +++ b/src/test/run-pass/iter-count.rs @@ -1,9 +1,9 @@ fn main() { - assert []/_.count(22u) == 0u; - assert [1u, 3u]/_.count(22u) == 0u; - assert [22u, 1u, 3u]/_.count(22u) == 1u; - assert [22u, 1u, 22u]/_.count(22u) == 2u; - assert None.count(22u) == 0u; - assert Some(1u).count(22u) == 0u; - assert Some(22u).count(22u) == 1u; + assert []/_.count(&22u) == 0u; + assert [1u, 3u]/_.count(&22u) == 0u; + assert [22u, 1u, 3u]/_.count(&22u) == 1u; + assert [22u, 1u, 22u]/_.count(&22u) == 2u; + assert None.count(&22u) == 0u; + assert Some(1u).count(&22u) == 0u; + assert Some(22u).count(&22u) == 1u; }