diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index 79bf85021d8..db976b580c7 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo { need_dir(&c.libdir); need_dir(&c.bindir); - for sources.each_key_ref |&k| { + for sources.each_key |&k| { let mut s = sources.get(&k); load_source_packages(&c, s); sources.insert(k, s); @@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo { } pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { for v.packages.each |p| { b(v, p); } @@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &mut Cargo) { } pub fn sync(c: &Cargo) { - for c.sources.each_key_ref |&k| { + for c.sources.each_key |&k| { let mut s = c.sources.get(&k); sync_one(c, s); c.sources.insert(k, s); @@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) { } } } else { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { print_source(v); } } @@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) { result::Ok(writer) => { let mut hash = ~LinearMap::new(); - for c.sources.each_ref |&k, &v| { + for c.sources.each |&k, &v| { let mut chash = ~LinearMap::new(); chash.insert(~"url", json::String(v.url)); @@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) { pub fn cmd_sources(c: &Cargo) { if vec::len(c.opts.free) < 3u { - for c.sources.each_value_ref |&v| { + for c.sources.each_value |&v| { info(fmt!("%s (%s) via %s", v.name, v.url, v.method)); } @@ -1686,7 +1686,7 @@ pub fn cmd_sources(c: &Cargo) { match action { ~"clear" => { - for c.sources.each_key_ref |&k| { + for c.sources.each_key |&k| { c.sources.remove(&k); } @@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key_ref(&name) { + if c.sources.contains_key(&name) { error(fmt!("source already exists: %s", name)); } else { c.sources.insert(name, @Source { @@ -1733,7 +1733,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key_ref(&name) { + if c.sources.contains_key(&name) { c.sources.remove(&name); info(fmt!("removed source: %s", name)); } else { diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index f6a5fec75ad..4cca6757cc3 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -18,8 +18,7 @@ use core::os; use core::uint; use core::util; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; +use core::hashmap::linear::LinearSet; pure fn not_win32(os: session::os) -> bool { match os { @@ -187,16 +186,14 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path { } pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { - let set = oldmap::HashMap(); + let mut set = LinearSet::new(); let mut minimized = ~[]; for rpaths.each |rpath| { - let s = rpath.to_str(); - if !set.contains_key_ref(&s) { - minimized.push(/*bad*/copy *rpath); - set.insert(s, ()); + if set.insert(rpath.to_str()) { + minimized.push(copy *rpath); } } - return minimized; + minimized } #[cfg(unix)] diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index c144d2d8804..73ec872b6a6 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -86,13 +86,13 @@ pub fn set_crate_data(cstore: @mut CStore, } pub fn have_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> bool { - return cstore.metas.contains_key_ref(&cnum); + cstore.metas.contains_key(&cnum) } pub fn iter_crate_data(cstore: @mut CStore, i: fn(ast::crate_num, crate_metadata)) { let metas = cstore.metas; - for metas.each_ref |&k, &v| { + for metas.each |&k, &v| { i(k, v); } } @@ -148,7 +148,7 @@ pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] { let mut result = ~[]; let use_crate_map = cstore.use_crate_map; - for use_crate_map.each_value_ref |&cnum| { + for use_crate_map.each_value |&cnum| { let cdata = cstore::get_crate_data(cstore, cnum); let hash = decoder::get_crate_hash(cdata.data); debug!("Add hash[%s]: %s", cdata.name, hash); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 89b491a867b..fcc1a4e806d 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -99,7 +99,7 @@ pub enum encode_ctxt = { }; pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool { - ecx.reachable.contains_key_ref(&id) + ecx.reachable.contains_key(&id) } fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) { diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 8d439f4ee9f..251fec68486 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -689,7 +689,7 @@ fn check_loans_in_expr(expr: @ast::expr, self.check_for_conflicting_loans(expr.id); - if self.bccx.moves_map.contains_key_ref(&expr.id) { + if self.bccx.moves_map.contains_key(&expr.id) { self.check_move_out_from_expr(expr); } @@ -710,7 +710,7 @@ fn check_loans_in_expr(expr: @ast::expr, } ast::expr_index(_, rval) | ast::expr_binary(_, _, rval) - if self.bccx.method_map.contains_key_ref(&expr.id) => { + if self.bccx.method_map.contains_key(&expr.id) => { self.check_call(expr, None, expr.callee_id, @@ -718,7 +718,7 @@ fn check_loans_in_expr(expr: @ast::expr, ~[rval]); } ast::expr_unary(*) | ast::expr_index(*) - if self.bccx.method_map.contains_key_ref(&expr.id) => { + if self.bccx.method_map.contains_key(&expr.id) => { self.check_call(expr, None, expr.callee_id, diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 6a61b2e2ee7..d4c45828858 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -207,7 +207,7 @@ fn req_loans_in_expr(ex: @ast::expr, ast::expr_binary(_, rcvr, _) | ast::expr_unary(_, rcvr) | ast::expr_assign_op(_, rcvr, _) - if self.bccx.method_map.contains_key_ref(&ex.id) => { + if self.bccx.method_map.contains_key(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, in an overloaded operator, the call is this expression, @@ -244,7 +244,7 @@ fn req_loans_in_expr(ex: @ast::expr, // } ast::expr_field(rcvr, _, _) - if self.bccx.method_map.contains_key_ref(&ex.id) => { + if self.bccx.method_map.contains_key(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, the field a.b is in fact a closure. Eventually, this diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 1946ba09ec7..097f0579362 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -375,7 +375,7 @@ impl PreserveCtxt { // scope_id;`. Though that would potentially re-introduce // the ICE. See #3511 for more details. let scope_to_use = if - self.bccx.stmt_map.contains_key_ref(&scope_id) { + self.bccx.stmt_map.contains_key(&scope_id) { // Root it in its parent scope, b/c // trans won't introduce a new scope for the // stmt diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index ad46d3b6f4d..6cca576fa13 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -102,7 +102,7 @@ pub fn check_expr(sess: Session, } expr_lit(@codemap::spanned {node: lit_str(_), _}) => { } expr_binary(_, _, _) | expr_unary(_, _) => { - if method_map.contains_key_ref(&e.id) { + if method_map.contains_key(&e.id) { sess.span_err(e.span, ~"user-defined operators are not \ allowed in constant expressions"); } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 6f9fe1edca5..1a3e4251129 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -59,7 +59,7 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool { return false; } - !cx.moves_map.contains_key_ref(&expr.id) + !cx.moves_map.contains_key(&expr.id) } pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { @@ -734,7 +734,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, by_ref_span = Some(span); } bind_infer => { - if cx.moves_map.contains_key_ref(&id) { + if cx.moves_map.contains_key(&id) { any_by_move = true; } } @@ -774,7 +774,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, if pat_is_binding(def_map, p) { match p.node { pat_ident(_, _, sub) => { - if cx.moves_map.contains_key_ref(&p.id) { + if cx.moves_map.contains_key(&p.id) { check_move(p, sub); } } @@ -800,7 +800,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, behind_bad_pointer); if behind_bad_pointer && - cx.moves_map.contains_key_ref(&pat.id) + cx.moves_map.contains_key(&pat.id) { cx.tcx.sess.span_err( pat.span, diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index e6091077210..0d3b7c36f6d 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -69,7 +69,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) } if i == depth { // Made it to end of loop let dnum = ast_util::def_id_of_def(def).node; - if !seen.contains_key_ref(&dnum) { + if !seen.contains_key(&dnum) { refs.push(@freevar_entry { def: def, span: expr.span, diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index b4500f87eb0..6bcc71514d4 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -391,7 +391,7 @@ impl LanguageItemCollector { } fn check_completeness() { - for self.item_refs.each_ref |&key, &item_ref| { + for self.item_refs.each |&key, &item_ref| { match self.items.items[item_ref] { None => { self.session.err(fmt!("no item found for `%s`", key)); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 843b01bdb35..487148ddd97 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -400,7 +400,7 @@ pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) { sess: sess}); // Install defaults. - for cx.dict.each_value_ref |&spec| { + for cx.dict.each_value |&spec| { cx.set_level(spec.lint, spec.default); } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 07de9987096..fd9271af6c6 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -340,7 +340,7 @@ pub impl &mem_categorization_ctxt { let expr_ty = tcx.ty(expr); match expr.node { ast::expr_unary(ast::deref, e_base) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_rvalue(expr, expr_ty); } @@ -349,7 +349,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_field(base, f_name, _) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_method_ref(expr, expr_ty); } @@ -358,7 +358,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_index(base, _) => { - if self.method_map.contains_key_ref(&expr.id) { + if self.method_map.contains_key(&expr.id) { return self.cat_rvalue(expr, expr_ty); } diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 0d32bb7ecf6..b23066c1d96 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -668,7 +668,7 @@ impl VisitContext { arg_exprs: &[@expr], visitor: vt) -> bool { - if !self.method_map.contains_key_ref(&expr.id) { + if !self.method_map.contains_key(&expr.id) { return false; } @@ -799,7 +799,7 @@ impl VisitContext { for arm.pats.each |pat| { let mut found = false; do pat_bindings(self.tcx.def_map, *pat) |_, node_id, _, _| { - if moves_map.contains_key_ref(&node_id) { + if moves_map.contains_key(&node_id) { found = true; } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 49b373fe6b1..5b2d3c9bb96 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -296,7 +296,7 @@ pub fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt) { _ => {} }; - if new_cx.root_exprs.contains_key_ref(&expr.id) { + if new_cx.root_exprs.contains_key(&expr.id) { new_cx.parent = Some(expr.id); } @@ -840,7 +840,7 @@ pub fn determine_rp_in_crate(sess: Session, debug!("%s", { debug!("Region variance results:"); let region_paramd_items = cx.region_paramd_items; - for region_paramd_items.each_ref |&key, &value| { + for region_paramd_items.each |&key, &value| { debug!("item %? (%s) is parameterized with variance %?", key, ast_map::node_id_to_str(ast_map, key, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 51df1d05d9e..ba550dbbde8 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1942,7 +1942,7 @@ pub impl Resolver { self.module_to_str(module_)); self.resolve_imports_for_module(module_); - for module_.children.each_value_ref |&child_node| { + for module_.children.each_value |&child_node| { match child_node.get_module_if_available() { None => { // Nothing to do. @@ -1953,7 +1953,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.resolve_imports_for_module_subtree(child_module); } } @@ -2241,7 +2241,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key_ref(&target); + assert module_.import_resolutions.contains_key(&target); let import_resolution = module_.import_resolutions.get(&target); match value_result { @@ -2400,7 +2400,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key_ref(&target); + assert module_.import_resolutions.contains_key(&target); let import_resolution = module_.import_resolutions.get(&target); match module_result { @@ -2461,7 +2461,7 @@ pub impl Resolver { assert containing_module.glob_count == 0; // Add all resolved imports from the containing module. - for containing_module.import_resolutions.each_ref + for containing_module.import_resolutions.each |&ident, &target_import_resolution| { debug!("(resolving glob import) writing module resolution \ @@ -2512,7 +2512,7 @@ pub impl Resolver { } // Add all children from the containing module. - for containing_module.children.each_ref |&ident, &name_bindings| { + for containing_module.children.each |&ident, &name_bindings| { let mut dest_import_resolution; match module_.import_resolutions.find(&ident) { None => { @@ -3182,7 +3182,7 @@ pub impl Resolver { } // Descend into children and anonymous children. - for module_.children.each_value_ref |&child_node| { + for module_.children.each_value |&child_node| { match child_node.get_module_if_available() { None => { // Continue. @@ -3193,7 +3193,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&module_| { + for module_.anonymous_children.each_value |&module_| { self.report_unresolved_imports(module_); } } @@ -3238,7 +3238,7 @@ pub impl Resolver { self.record_exports_for_module(module_); - for module_.children.each_value_ref |&child_name_bindings| { + for module_.children.each_value |&child_name_bindings| { match child_name_bindings.get_module_if_available() { None => { // Nothing to do. @@ -3249,7 +3249,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.record_exports_for_module_subtree(child_module); } } @@ -3297,7 +3297,7 @@ pub impl Resolver { } fn add_exports_for_module(exports2: &mut ~[Export2], module_: @Module) { - for module_.children.each_ref |ident, namebindings| { + for module_.children.each |ident, namebindings| { debug!("(computing exports) maybe export '%s'", self.session.str_of(*ident)); self.add_exports_of_namebindings(&mut *exports2, @@ -3312,7 +3312,7 @@ pub impl Resolver { false); } - for module_.import_resolutions.each_ref |ident, importresolution| { + for module_.import_resolutions.each |ident, importresolution| { if importresolution.privacy != Public { debug!("(computing exports) not reexporting private `%s`", self.session.str_of(*ident)); @@ -4102,7 +4102,7 @@ pub impl Resolver { for arm.pats.eachi() |i, p| { let map_i = self.binding_mode_map(*p); - for map_0.each_ref |&key, &binding_0| { + for map_0.each |&key, &binding_0| { match map_i.find(&key) { None => { self.session.span_err( @@ -4123,8 +4123,8 @@ pub impl Resolver { } } - for map_i.each_ref |&key, &binding| { - if !map_0.contains_key_ref(&key) { + for map_i.each |&key, &binding| { + if !map_0.contains_key(&key) { self.session.span_err( binding.span, fmt!("variable `%s` from pattern #%u is \ @@ -4353,7 +4353,7 @@ pub impl Resolver { match bindings_list { Some(bindings_list) - if !bindings_list.contains_key_ref(&ident) + if !bindings_list.contains_key(&ident) => { let last_rib = (*self.value_ribs).last(); last_rib.bindings.insert(ident, @@ -4426,18 +4426,18 @@ pub impl Resolver { pat_struct(path, _, _) => { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) - if self.structs.contains_key_ref(&class_id) + if self.structs.contains_key(&class_id) => { let class_def = def_struct(class_id); self.record_def(pattern.id, class_def); } Some(definition @ def_struct(class_id)) - if self.structs.contains_key_ref(&class_id) + if self.structs.contains_key(&class_id) => { self.record_def(pattern.id, definition); } Some(definition @ def_variant(_, variant_id)) - if self.structs.contains_key_ref(&variant_id) + if self.structs.contains_key(&variant_id) => { self.record_def(pattern.id, definition); } @@ -4886,12 +4886,12 @@ pub impl Resolver { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) | Some(def_struct(class_id)) - if self.structs.contains_key_ref(&class_id) => { + if self.structs.contains_key(&class_id) => { let class_def = def_struct(class_id); self.record_def(expr.id, class_def); } Some(definition @ def_variant(_, class_id)) - if self.structs.contains_key_ref(&class_id) => { + if self.structs.contains_key(&class_id) => { self.record_def(expr.id, definition); } _ => { @@ -5035,7 +5035,7 @@ pub impl Resolver { } // Look for trait children. - for search_module.children.each_value_ref |&child_name_bindings| { + for search_module.children.each_value |&child_name_bindings| { match child_name_bindings.def_for_namespace(TypeNS) { Some(def) => { match def { @@ -5055,7 +5055,7 @@ pub impl Resolver { } // Look for imports. - for search_module.import_resolutions.each_value_ref + for search_module.import_resolutions.each_value |&import_resolution| { match import_resolution.target_for_namespace(TypeNS) { @@ -5115,7 +5115,7 @@ pub impl Resolver { self.session.str_of(name)); match self.trait_info.find(&trait_def_id) { - Some(trait_info) if trait_info.contains_key_ref(&name) => { + Some(trait_info) if trait_info.contains_key(&name) => { debug!("(adding trait info if containing method) found trait \ %d:%d for method '%s'", trait_def_id.crate, @@ -5223,7 +5223,7 @@ pub impl Resolver { self.check_for_unused_imports_in_module(module_); - for module_.children.each_value_ref |&child_name_bindings| { + for module_.children.each_value |&child_name_bindings| { match (*child_name_bindings).get_module_if_available() { None => { // Nothing to do. @@ -5235,13 +5235,13 @@ pub impl Resolver { } } - for module_.anonymous_children.each_value_ref |&child_module| { + for module_.anonymous_children.each_value |&child_module| { self.check_for_unused_imports_in_module_subtree(child_module); } } fn check_for_unused_imports_in_module(module_: @Module) { - for module_.import_resolutions.each_value_ref |&import_resolution| { + for module_.import_resolutions.each_value |&import_resolution| { // Ignore dummy spans for things like automatically injected // imports for the prelude, and also don't warn about the same // import statement being unused more than once. @@ -5306,12 +5306,12 @@ pub impl Resolver { debug!("Dump of module `%s`:", self.module_to_str(module_)); debug!("Children:"); - for module_.children.each_key_ref |&name| { + for module_.children.each_key |&name| { debug!("* %s", self.session.str_of(name)); } debug!("Import resolutions:"); - for module_.import_resolutions.each_ref |&name, &import_resolution| { + for module_.import_resolutions.each |&name, &import_resolution| { let mut value_repr; match (*import_resolution).target_for_namespace(ValueNS) { None => { value_repr = ~""; } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index ebd6d9f9056..2369a63e544 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1096,7 +1096,7 @@ pub fn store_non_ref_bindings(bcx: block, */ let mut bcx = bcx; - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { match binding_info.trmode { TrByValue(is_move, lldest) => { let llval = Load(bcx, binding_info.llmatch); // get a T* @@ -1130,7 +1130,7 @@ pub fn insert_lllocals(bcx: block, * the `fcx.lllocals` map. If add_cleans is true, then adds cleanups for * the bindings. */ - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { let llval = match binding_info.trmode { // By value bindings: use the stack slot that we // copied/moved the value into @@ -1203,7 +1203,7 @@ pub fn compile_guard(bcx: block, fn drop_bindings(bcx: block, data: &ArmData) -> block { let mut bcx = bcx; - for data.bindings_map.each_value_ref |&binding_info| { + for data.bindings_map.each_value |&binding_info| { match binding_info.trmode { TrByValue(_, llval) => { bcx = glue::drop_ty(bcx, llval, binding_info.ty); @@ -1598,7 +1598,7 @@ pub fn trans_match_inner(scope_cx: block, // but during matching we need to store a *T as explained // above let is_move = - scope_cx.ccx().maps.moves_map.contains_key_ref(&p_id); + scope_cx.ccx().maps.moves_map.contains_key(&p_id); llmatch = alloca(bcx, T_ptr(llvariable_ty)); trmode = TrByValue(is_move, alloca(bcx, llvariable_ty)); } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index acf33434b2f..ced47bb5681 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -169,7 +169,7 @@ pub fn get_extern_fn(externs: ExternMap, name: @str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { - if externs.contains_key_ref(&name) { return externs.get(&name); } + if externs.contains_key(&name) { return externs.get(&name); } let f = decl_fn(llmod, name, cc, ty); externs.insert(name, f); return f; @@ -178,7 +178,7 @@ pub fn get_extern_fn(externs: ExternMap, pub fn get_extern_const(externs: ExternMap, llmod: ModuleRef, name: @str, ty: TypeRef) -> ValueRef { unsafe { - if externs.contains_key_ref(&name) { return externs.get(&name); } + if externs.contains_key(&name) { return externs.get(&name); } let c = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(llmod, ty, buf) }); @@ -448,7 +448,7 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) { // silently mangles such symbols, breaking our linkage model. pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) { // XXX: Bad copy. - if ccx.all_llvm_symbols.contains_key_ref(&sym) { + if ccx.all_llvm_symbols.contains_key(&sym) { ccx.sess.bug(~"duplicate LLVM symbol: " + sym); } ccx.all_llvm_symbols.insert(sym, ()); @@ -2477,7 +2477,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ccx.sess.bug(~"get_item_val(): unexpected variant") } }; - if !(exprt || ccx.reachable.contains_key_ref(&id)) { + if !(exprt || ccx.reachable.contains_key(&id)) { lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage); } ccx.item_vals.insert(id, val); @@ -2800,7 +2800,7 @@ pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef { lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); } let mut elts: ~[ValueRef] = ~[]; - for ccx.module_data.each_ref |&key, &val| { + for ccx.module_data.each |&key, &val| { let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)), p2i(ccx, val)]); elts.push(elt); @@ -3084,7 +3084,7 @@ pub fn trans_crate(sess: session::Session, } if ccx.sess.count_llvm_insns() { - for ccx.stats.llvm_insns.each_ref |&k, &v| { + for ccx.stats.llvm_insns.each |&k, &v| { io::println(fmt!("%-7u %s", v, k)); } } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 08bab21daaf..81fa221aac4 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -674,8 +674,7 @@ pub fn trans_arg_expr(bcx: block, // FIXME(#3548) use the adjustments table match autoref_arg { DoAutorefArg => { - assert !bcx.ccx().maps.moves_map.contains_key_ref( - &arg_expr.id); + assert !bcx.ccx().maps.moves_map.contains_key(&arg_expr.id); val = arg_datum.to_ref_llval(bcx); } DontAutorefArg => { @@ -685,7 +684,7 @@ pub fn trans_arg_expr(bcx: block, // the explicit self code currently passes by-ref, it // does not hold. // - //assert !bcx.ccx().maps.moves_map.contains_key_ref( + //assert !bcx.ccx().maps.moves_map.contains_key( // &arg_expr.id); val = arg_datum.to_ref_llval(bcx); } @@ -693,7 +692,7 @@ pub fn trans_arg_expr(bcx: block, ast::by_val => { // NB: avoid running the take glue. - assert !bcx.ccx().maps.moves_map.contains_key_ref( + assert !bcx.ccx().maps.moves_map.contains_key( &arg_expr.id); val = arg_datum.to_value_llval(bcx); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 515239883e2..bcf796caa7a 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -132,7 +132,7 @@ pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef { if !ast_util::is_local(def_id) { cx.tcx.sess.bug(~"cross-crate constants"); } - if !cx.const_values.contains_key_ref(&def_id.node) { + if !cx.const_values.contains_key(&def_id.node) { match cx.tcx.items.get(&def_id.node) { ast_map::node_item(@ast::item { node: ast::item_const(_, subexpr), _ diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 0933eedd5e4..792c5958822 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -186,7 +186,7 @@ pub fn trans_log(log_ex: @ast::expr, // XXX: Bad copy. let modname = path_str(ccx.sess, copy modpath); - let global = if ccx.module_data.contains_key_ref(&modname) { + let global = if ccx.module_data.contains_key(&modname) { ccx.module_data.get(&modname) } else { let s = link::mangle_internal_name_by_path_and_seq( diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index af966e4df82..d301a31357b 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -223,7 +223,7 @@ pub impl Datum { * `id` is located in the move table, but copies otherwise. */ - if bcx.ccx().maps.moves_map.contains_key_ref(&id) { + if bcx.ccx().maps.moves_map.contains_key(&id) { self.move_to(bcx, action, dst) } else { self.copy_to(bcx, action, dst) diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 8556bee7e84..f50cadc9671 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -117,7 +117,7 @@ pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt { } fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { - let existing = if cache.contains_key_ref(&mdtag) { + let existing = if cache.contains_key(&mdtag) { cache.get(&mdtag) } else { ~[] @@ -176,7 +176,7 @@ fn cached_metadata(cache: metadata_cache, eq_fn: fn(md: T) -> bool) -> Option { unsafe { - if cache.contains_key_ref(&mdtag) { + if cache.contains_key(&mdtag) { let items = cache.get(&mdtag); for items.each |item| { let md: T = md_from_metadata::(*item); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index f2da47eb0ec..cab2adc43fa 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -265,7 +265,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock { } pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block { - if bcx.tcx().adjustments.contains_key_ref(&expr.id) { + if bcx.tcx().adjustments.contains_key(&expr.id) { // use trans_to_datum, which is mildly less efficient but // which will perform the adjustments: let datumblock = trans_to_datum(bcx, expr); @@ -426,7 +426,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { } ast::expr_binary(op, lhs, rhs) => { // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key_ref(&expr.id); + assert !bcx.ccx().maps.method_map.contains_key(&expr.id); return trans_binary(bcx, expr, op, lhs, rhs); } @@ -1215,7 +1215,7 @@ fn trans_unary_datum(bcx: block, assert op != ast::deref; // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key_ref(&un_expr.id); + assert !bcx.ccx().maps.method_map.contains_key(&un_expr.id); let un_ty = expr_ty(bcx, un_expr); let sub_ty = expr_ty(bcx, sub_expr); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 3cbc575b7c1..08d22a4fbf0 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -384,7 +384,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_visit_glue"); let mut bcx = bcx; let ty_visitor_name = special_idents::ty_visitor; - assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(&ty_visitor_name); let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(&ty_visitor_name); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id); @@ -762,7 +762,7 @@ pub fn emit_tydescs(ccx: @crate_ctxt) { let _icx = ccx.insn_ctxt("emit_tydescs"); // As of this point, allow no more tydescs to be created. ccx.finished_tydescs = true; - for ccx.tydescs.each_value_ref |&val| { + for ccx.tydescs.each_value |&val| { let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx)); let ti = val; diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index dfbc75376c7..75e494f7bfc 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -180,7 +180,7 @@ pub fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // Computes the size of the data part of an enum. pub fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { - if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(&t); } + if cx.enum_sizes.contains_key(&t) { return cx.enum_sizes.get(&t); } match ty::get(t).sty { ty::ty_enum(tid, ref substs) => { // Compute max(variant sizes). diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 1d48d2dde6b..fb487b98e15 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -871,7 +871,7 @@ pub fn trans_trait_cast(bcx: block, match vstore { ty::vstore_slice(*) | ty::vstore_box => { let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]); - if bcx.tcx().legacy_boxed_traits.contains_key_ref(&id) { + if bcx.tcx().legacy_boxed_traits.contains_key(&id) { // Allocate an @ box and store the value into it let {bcx: new_bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 112b9ac4d07..f77aa33407d 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -95,7 +95,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: _mod) { } fn traverse_public_item(cx: ctx, item: @item) { - if cx.rmap.contains_key_ref(&item.id) { return; } + if cx.rmap.contains_key(&item.id) { return; } cx.rmap.insert(item.id, ()); match /*bad*/copy item.node { item_mod(m) => traverse_public_mod(cx, item.id, m), @@ -145,7 +145,7 @@ fn mk_ty_visitor() -> visit::vt { } fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt) { - if cx.rmap.contains_key_ref(&ty.id) { return; } + if cx.rmap.contains_key(&ty.id) { return; } cx.rmap.insert(ty.id, ()); match ty.node { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 3cd6a5d1836..16677530ecd 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -331,7 +331,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block, -> block { use syntax::parse::token::special_idents::tydesc; let final = sub_block(bcx, ~"final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&tydesc); + assert bcx.ccx().tcx.intrinsic_defs.contains_key(&tydesc); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(&tydesc); let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); let mut r = Reflector { diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index f727b5a2de0..84a19cd4c04 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -93,7 +93,7 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { debug!("type_of %?: %?", t, ty::get(t)); // Check the cache. - if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(&t); } + if cx.lltypes.contains_key(&t) { return cx.lltypes.get(&t); } // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2a43fc8a601..4350c62af6f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2778,7 +2778,7 @@ pub fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] { } fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { - return cx.node_type_substs.contains_key_ref(&id); + cx.node_type_substs.contains_key(&id) } // Type accessors for substructures of types @@ -3082,7 +3082,7 @@ pub enum ExprKind { pub fn expr_kind(tcx: ctxt, method_map: typeck::method_map, expr: @ast::expr) -> ExprKind { - if method_map.contains_key_ref(&expr.id) { + if method_map.contains_key(&expr.id) { // Overloaded operations are generally calls, and hence they are // generated via DPS. However, assign_op (e.g., `x += y`) is an // exception, as its result is always unit. @@ -4338,7 +4338,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt, let super_t = supertrait.tpt.ty; let d_id = ty_to_def_id(super_t).expect("supertrait \ should be a trait ty"); - if !supertrait_map.contains_key_ref(&d_id) { + if !supertrait_map.contains_key(&d_id) { supertrait_map.insert(d_id, super_t); trait_ty = super_t; seen_def_ids.push(d_id); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 3cd2be6450d..95bed114050 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -239,7 +239,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt, // Report an error if not all the fields were specified. if !etc { for class_fields.eachi |i, field| { - if found_fields.contains_key_ref(&i) { + if found_fields.contains_key(&i) { loop; } tcx.sess.span_err(span, diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 12e3778020a..463ae3201a4 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1172,12 +1172,11 @@ pub impl LookupContext { match candidate.origin { method_static(method_id) | method_self(method_id, _) | method_super(method_id, _) => { - bad = self.tcx().destructors.contains_key_ref(&method_id); + bad = self.tcx().destructors.contains_key(&method_id); } method_param(method_param { trait_id: trait_id, _ }) | method_trait(trait_id, _, _) => { - bad = self.tcx().destructor_for_type.contains_key_ref( - &trait_id); + bad = self.tcx().destructor_for_type.contains_key(&trait_id); } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 80be81a33b3..fda9702d582 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3208,8 +3208,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) { ~"visit_tydesc" => { let tydesc_name = special_idents::tydesc; let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor"); - assert tcx.intrinsic_defs.contains_key_ref(&tydesc_name); - assert ccx.tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); + assert tcx.intrinsic_defs.contains_key(&tydesc_name); + assert ccx.tcx.intrinsic_defs.contains_key(&ty_visitor_name); let (_, tydesc_ty) = tcx.intrinsic_defs.get(&tydesc_name); let (_, visitor_trait) = tcx.intrinsic_defs.get(&ty_visitor_name); let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 9ceace00385..c91607489ec 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -213,7 +213,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { // `constrain_auto_ref()` on all exprs. But that causes a // lot of spurious errors because of how the region // hierarchy is setup. - if rcx.fcx.ccx.method_map.contains_key_ref(&callee.id) { + if rcx.fcx.ccx.method_map.contains_key(&callee.id) { match callee.node { ast::expr_field(base, _, _) => { constrain_auto_ref(rcx, base); @@ -749,7 +749,7 @@ pub mod guarantor { let _i = ::util::common::indenter(); let guarantor = { - if rcx.fcx.ccx.method_map.contains_key_ref(&expr.id) { + if rcx.fcx.ccx.method_map.contains_key(&expr.id) { None } else { guarantor(rcx, expr) diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index b72c42f6af7..410b4a3e33d 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -268,7 +268,7 @@ pub fn lookup_vtable(vcx: &VtableContext, // im is one specific impl of trait_ty. // First, ensure we haven't processed this impl yet. - if impls_seen.contains_key_ref(&im.did) { + if impls_seen.contains_key(&im.did) { loop; } impls_seen.insert(im.did, ()); diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 835e0557e2e..1b276199381 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -141,7 +141,7 @@ fn maybe_resolve_type_vars_for_node(wbcx: @mut WbCtxt, sp: span, id: ast::node_id) -> Option { - if wbcx.fcx.inh.node_types.contains_key_ref(&id) { + if wbcx.fcx.inh.node_types.contains_key(&id) { resolve_type_vars_for_node(wbcx, sp, id) } else { None diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 1790bd19925..5e51c216093 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -418,7 +418,7 @@ pub impl CoherenceChecker { let coherence_info = &mut self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; - for extension_methods.each_key_ref |&trait_id| { + for extension_methods.each_key |&trait_id| { self.check_implementation_coherence_of(trait_id); } } @@ -503,7 +503,7 @@ pub impl CoherenceChecker { } for ty::trait_methods(tcx, trait_did).each |method| { - if provided_method_idents.contains_key_ref(&method.ident) { + if provided_method_idents.contains_key(&method.ident) { if !f(method) { break; } @@ -911,7 +911,7 @@ pub impl CoherenceChecker { let tcx = self.crate_context.tcx; let pmm = tcx.provided_methods; - if pmm.contains_key_ref(&trait_def_id) { return; } + if pmm.contains_key(&trait_def_id) { return; } debug!("(adding default methods for trait) processing trait"); diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 68a0ca3890e..982a8d7d957 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -304,7 +304,7 @@ pub fn ensure_supertraits(ccx: @mut CrateCtxt, rp: Option, trait_refs: &[@ast::trait_ref]) { let tcx = ccx.tcx; - if tcx.supertraits.contains_key_ref(&local_def(id)) { return; } + if tcx.supertraits.contains_key(&local_def(id)) { return; } let instantiated = dvec::DVec(); for trait_refs.each |trait_ref| { diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 60f5f440658..027b99cc421 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -1242,7 +1242,7 @@ impl RegionVarBindings { // It would be nice to write this using map(): let mut edges = vec::with_capacity(num_edges); - for self.constraints.each_ref |constraint, span| { + for self.constraints.each |constraint, span| { edges.push(GraphEdge { next_edge: [uint::max_value, uint::max_value], constraint: *constraint, diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index e91fd1c31ca..5273dbd3049 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -177,7 +177,7 @@ Available lint options: let lint_dict = lint::get_lint_dict(); let mut max_key = 0; - for lint_dict.each_key_ref |&k| { max_key = uint::max(k.len(), max_key); } + for lint_dict.each_key |&k| { max_key = uint::max(k.len(), max_key); } fn padded(max: uint, s: &str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } @@ -186,7 +186,7 @@ Available lint options: padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(fmt!(" %s %7.7s %s\n", padded(max_key, ~"----"), ~"-------", ~"-------")); - for lint_dict.each_ref |&k, &v| { + for lint_dict.each |&k, &v| { let k = str::replace(k, ~"_", ~"-"); io::println(fmt!(" %s %7.7s %s", padded(max_key, k), diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index ad7e8e50e38..cea6d17e35d 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -76,7 +76,7 @@ pub mod chained { FoundAfter(@Entry, @Entry) } - priv impl T { + priv impl T { pure fn search_rem(k: &K, h: uint, idx: uint, e_root: @Entry) -> SearchResult { let mut e0 = e_root; @@ -90,15 +90,13 @@ pub mod chained { } Some(e1) => { comp += 1u; - unsafe { - if e1.hash == h && e1.key == *k { - debug!("search_tbl: present, comp %u, \ - hash %u, idx %u", - comp, h, idx); - return FoundAfter(e0, e1); - } else { - e0 = e1; - } + if e1.hash == h && e1.key == *k { + debug!( + "search_tbl: present, comp %u, hash %u, idx %u", + comp, h, idx); + return FoundAfter(e0, e1); + } else { + e0 = e1; } } } @@ -114,14 +112,12 @@ pub mod chained { return NotFound; } Some(e) => { - unsafe { - if e.hash == h && e.key == *k { - debug!("search_tbl: present, comp %u, hash %u, \ - idx %u", 1u, h, idx); - return FoundFirst(idx, e); - } else { - return self.search_rem(k, h, idx, e); - } + if e.hash == h && e.key == *k { + debug!("search_tbl: present, comp %u, hash %u, \ + idx %u", 1u, h, idx); + return FoundFirst(idx, e); + } else { + return self.search_rem(k, h, idx, e); } } } @@ -172,8 +168,8 @@ pub mod chained { } } - impl T { - pure fn contains_key_ref(&self, k: &K) -> bool { + impl T { + pure fn contains_key(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { NotFound => false, @@ -225,13 +221,43 @@ pub mod chained { } } + fn remove(k: &K) -> bool { + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { + NotFound => false, + FoundFirst(idx, entry) => { + self.count -= 1u; + self.chains[idx] = entry.next; + true + } + FoundAfter(eprev, entry) => { + self.count -= 1u; + eprev.next = entry.next; + true + } + } + } + + pure fn each(&self, blk: fn(key: &K, value: &V) -> bool) { + for self.each_entry |entry| { + if !blk(&entry.key, &entry.value) { break; } + } + } + + pure fn each_key(&self, blk: fn(key: &K) -> bool) { + self.each(|k, _v| blk(k)) + } + + pure fn each_value(&self, blk: fn(value: &V) -> bool) { + self.each(|_k, v| blk(v)) + } + } + + impl T { pure fn find(&self, k: &K) -> Option { - unsafe { - match self.search_tbl(k, k.hash_keyed(0,0) as uint) { - NotFound => None, - FoundFirst(_, entry) => Some(entry.value), - FoundAfter(_, entry) => Some(entry.value) - } + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { + NotFound => None, + FoundFirst(_, entry) => Some(entry.value), + FoundAfter(_, entry) => Some(entry.value) } } @@ -297,36 +323,6 @@ pub mod chained { } option::unwrap(move opt_v) } - - fn remove(k: &K) -> bool { - match self.search_tbl(k, k.hash_keyed(0,0) as uint) { - NotFound => false, - FoundFirst(idx, entry) => { - self.count -= 1u; - self.chains[idx] = entry.next; - true - } - FoundAfter(eprev, entry) => { - self.count -= 1u; - eprev.next = entry.next; - true - } - } - } - - pure fn each_ref(&self, blk: fn(key: &K, value: &V) -> bool) { - for self.each_entry |entry| { - if !blk(&entry.key, &entry.value) { break; } - } - } - - pure fn each_key_ref(&self, blk: fn(key: &K) -> bool) { - self.each_ref(|k, _v| blk(k)) - } - - pure fn each_value_ref(&self, blk: fn(value: &V) -> bool) { - self.each_ref(|_k, v| blk(v)) - } } impl T { @@ -362,9 +358,7 @@ pub mod chained { impl T: ops::Index { pure fn index(&self, k: K) -> V { - unsafe { - self.get(&k) - } + self.get(&k) } } @@ -397,7 +391,7 @@ pub fn set_add(set: Set, key: K) -> bool { /// Convert a set into a vector. pub pure fn vec_from_set(s: Set) -> ~[T] { do vec::build_sized(s.len()) |push| { - for s.each_key_ref() |&k| { + for s.each_key() |&k| { push(k); } } @@ -628,9 +622,9 @@ mod tests { fn test_contains_key() { let key = ~"k"; let map = HashMap::<~str, ~str>(); - assert (!map.contains_key_ref(&key)); + assert (!map.contains_key(&key)); map.insert(key, ~"val"); - assert (map.contains_key_ref(&key)); + assert (map.contains_key(&key)); } #[test] @@ -648,10 +642,10 @@ mod tests { let mut map = HashMap::<~str, ~str>(); map.insert(key, ~"val"); assert (map.len() == 1); - assert (map.contains_key_ref(&key)); + assert (map.contains_key(&key)); map.clear(); assert (map.len() == 0); - assert (!map.contains_key_ref(&key)); + assert (!map.contains_key(&key)); } #[test] diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index c347c04641f..d258393e3b9 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -24,8 +24,7 @@ use core::either::Either; use core::either; use core::option; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; +use core::hashmap::linear::LinearSet; use std; /* Constructors */ @@ -358,16 +357,15 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { pub fn require_unique_names(diagnostic: span_handler, metas: &[@ast::meta_item]) { - let map = oldmap::HashMap(); + let mut set = LinearSet::new(); for metas.each |meta| { let name = get_meta_item_name(*meta); // FIXME: How do I silence the warnings? --pcw (#2619) - if map.contains_key_ref(&name) { + if !set.insert(name) { diagnostic.span_fatal(meta.span, fmt!("duplicate meta item `%s`", name)); } - map.insert(name, ()); } } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 9548db70b94..4b1194bb5f1 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -197,7 +197,7 @@ pub fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) codemap::spanned { node: match_nonterminal(bind_name, _, idx), span: sp } => { - if ret_val.contains_key_ref(&bind_name) { + if ret_val.contains_key(&bind_name) { p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+ *p_s.interner.get(bind_name)) } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index d82a5a18039..e0d53fadfa0 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -96,7 +96,7 @@ pub impl Parser { // A sanity check that the word we are asking for is a known keyword fn require_keyword(word: ~str) { - if !self.keywords.contains_key_ref(&word) { + if !self.keywords.contains_key(&word) { self.bug(fmt!("unknown keyword: %s", word)); } } @@ -120,7 +120,7 @@ pub impl Parser { fn is_any_keyword(tok: token::Token) -> bool { match tok { token::IDENT(sid, false) => { - self.keywords.contains_key_ref(self.id_to_str(sid)) + self.keywords.contains_key(self.id_to_str(sid)) } _ => false } @@ -146,7 +146,7 @@ pub impl Parser { } fn is_strict_keyword(word: ~str) -> bool { - self.strict_keywords.contains_key_ref(&word) + self.strict_keywords.contains_key(&word) } fn check_strict_keywords() { @@ -166,7 +166,7 @@ pub impl Parser { } fn is_reserved_keyword(word: ~str) -> bool { - self.reserved_keywords.contains_key_ref(&word) + self.reserved_keywords.contains_key(&word) } fn check_reserved_keywords() { diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index cdde542bb1f..9b2040fed1a 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -137,7 +137,7 @@ pub impl Parser { desc: &str) { self.span_err(sp, fmt!("obsolete syntax: %s", kind_str)); - if !self.obsolete_set.contains_key_ref(&kind) { + if !self.obsolete_set.contains_key(&kind) { self.sess.span_diagnostic.handler().note(fmt!("%s", desc)); self.obsolete_set.insert(kind, ()); } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 49de7264d2c..b8d756d893a 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -455,13 +455,13 @@ pub fn mk_fake_ident_interner() -> @ident_interner { */ pub fn keyword_table() -> HashMap<~str, ()> { let keywords = HashMap(); - for temporary_keyword_table().each_key_ref |&word| { + for temporary_keyword_table().each_key |&word| { keywords.insert(word, ()); } - for strict_keyword_table().each_key_ref |&word| { + for strict_keyword_table().each_key |&word| { keywords.insert(word, ()); } - for reserved_keyword_table().each_key_ref |&word| { + for reserved_keyword_table().each_key |&word| { keywords.insert(word, ()); } keywords diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 811f39e4343..62341f08ce3 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -49,7 +49,7 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { let mut pairs = ~[]; // map -> [(k,%)] - for mm.each_ref |&key, &val| { + for mm.each |&key, &val| { pairs.push((key, pct(val, total))); } diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 5888dab3bb9..b19454ec230 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -134,7 +134,7 @@ fn writer(path: ~str, pport: pipes::Port, size: uint) done += 1_u; let mut prev = done; while prev <= i { - if lines.contains_key_ref(&prev) { + if lines.contains_key(&prev) { debug!("WS %u", prev); cout.write(lines.get(&prev)); done += 1_u;