From 1697cc6c0f6ffcb60ddc9447487eadb63952db71 Mon Sep 17 00:00:00 2001 From: Jihyun Yu Date: Tue, 5 Mar 2013 10:20:10 +0900 Subject: [PATCH] remove some oldmap::Hashmap from librustc --- src/librustc/back/link.rs | 1 - src/librustc/driver/driver.rs | 1 - src/librustc/metadata/creader.rs | 4 +- src/librustc/metadata/csearch.rs | 1 - src/librustc/metadata/cstore.rs | 28 ++-- src/librustc/metadata/decoder.rs | 5 +- src/librustc/metadata/encoder.rs | 30 ++-- src/librustc/metadata/tydecode.rs | 1 - src/librustc/metadata/tyencode.rs | 6 +- src/librustc/middle/astencode.rs | 7 +- src/librustc/middle/borrowck/check_loans.rs | 8 +- src/librustc/middle/borrowck/gather_loans.rs | 8 +- src/librustc/middle/borrowck/mod.rs | 23 ++- src/librustc/middle/check_const.rs | 1 - src/librustc/middle/check_match.rs | 1 - src/librustc/middle/freevars.rs | 11 +- src/librustc/middle/kind.rs | 4 +- src/librustc/middle/lang_items.rs | 21 ++- src/librustc/middle/lint.rs | 97 ++++++------ src/librustc/middle/liveness.rs | 2 +- src/librustc/middle/moves.rs | 13 +- src/librustc/middle/pat_util.rs | 8 +- src/librustc/middle/trans/_match.rs | 8 +- src/librustc/middle/trans/base.rs | 145 +++++++++--------- src/librustc/middle/trans/build.rs | 8 +- src/librustc/middle/trans/closure.rs | 3 +- src/librustc/middle/trans/common.rs | 34 ++-- src/librustc/middle/trans/consts.rs | 6 +- src/librustc/middle/trans/datum.rs | 2 +- src/librustc/middle/trans/debuginfo.rs | 44 +++--- src/librustc/middle/trans/expr.rs | 16 +- src/librustc/middle/trans/foreign.rs | 96 ++++++------ src/librustc/middle/trans/meth.rs | 3 +- src/librustc/middle/trans/monomorphize.rs | 7 +- src/librustc/middle/trans/reachable.rs | 6 +- src/librustc/middle/trans/reflect.rs | 1 - src/librustc/middle/trans/shape.rs | 1 - src/librustc/middle/trans/type_of.rs | 1 - src/librustc/middle/trans/type_use.rs | 3 +- src/librustc/middle/ty.rs | 9 +- src/librustc/middle/typeck/check/_match.rs | 12 +- src/librustc/middle/typeck/check/method.rs | 6 +- src/librustc/middle/typeck/check/mod.rs | 15 +- src/librustc/middle/typeck/check/vtable.rs | 9 +- src/librustc/middle/typeck/check/writeback.rs | 1 - src/librustc/middle/typeck/coherence.rs | 37 ++--- src/librustc/middle/typeck/infer/mod.rs | 1 - .../middle/typeck/infer/region_inference.rs | 30 ++-- src/librustc/middle/typeck/mod.rs | 1 - src/librustc/rustc.rc | 4 +- src/librustc/util/common.rs | 6 +- src/librustc/util/ppaux.rs | 1 - .../compile-fail/regions-glb-free-free.rs | 2 + 53 files changed, 394 insertions(+), 405 deletions(-) diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 446b83af425a7..d5fa6f944b360 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -35,7 +35,6 @@ use core::ptr; use core::run; use core::str; use core::vec; -use std::oldmap::HashMap; use std::sha1::sha1; use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index b24cdf9c602c4..6d13c3e46479e 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -36,7 +36,6 @@ use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; use std::getopts::groups; use std::getopts::{opt_present}; use std::getopts; -use std::oldmap::HashMap; use std; use syntax::ast; use syntax::ast_map; diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 307a58135e138..14ee217763325 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -20,6 +20,7 @@ use metadata::filesearch::FileSearch; use metadata::loader; use core::either; +use core::hashmap::linear::LinearMap; use core::option; use core::vec; use syntax::attr; @@ -29,7 +30,6 @@ use syntax::parse::token::ident_interner; use syntax::print::pprust; use syntax::visit; use syntax::{ast, ast_util}; -use std::oldmap::HashMap; // Traverses an AST, reading all the information about use'd crates and extern // libraries necessary for later resolving, typechecking, linking, etc. @@ -306,7 +306,7 @@ fn resolve_crate_deps(e: @mut Env, cdata: @~[u8]) -> cstore::cnum_map { debug!("resolving deps of external crate"); // The map from crate numbers in the crate we're resolving to local crate // numbers - let cnum_map = HashMap(); + let cnum_map = @mut LinearMap::new(); for decoder::get_crate_deps(e.intr, cdata).each |dep| { let extrn_cnum = dep.cnum; let cname = dep.name; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index ae4a223c1ae75..9f1766238eb4c 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -23,7 +23,6 @@ use core::dvec::DVec; use core::vec; use reader = std::ebml::reader; use std::ebml; -use std::oldmap::HashMap; use syntax::ast; use syntax::ast_map; use syntax::codemap::dummy_sp; diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 667a9c200580f..37c29134e9653 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -18,11 +18,10 @@ use metadata::creader; use metadata::cstore; use metadata::decoder; +use core::hashmap::linear::LinearMap; use core::option; use core::str; use core::vec; -use std::oldmap::HashMap; -use std::oldmap; use std; use syntax::{ast, attr}; use syntax::parse::token::ident_interner; @@ -31,7 +30,7 @@ use syntax::parse::token::ident_interner; // local crate numbers (as generated during this session). Each external // crate may refer to types in other external crates, and each has their // own crate numbers. -pub type cnum_map = oldmap::HashMap; +pub type cnum_map = @mut LinearMap; pub struct crate_metadata { name: @~str, @@ -41,7 +40,7 @@ pub struct crate_metadata { } pub struct CStore { - priv metas: oldmap::HashMap, + priv metas: @mut LinearMap, priv extern_mod_crate_map: extern_mod_crate_map, priv used_crate_files: ~[Path], priv used_libraries: ~[~str], @@ -50,11 +49,11 @@ pub struct CStore { } // Map from node_id's of local extern mod statements to crate numbers -type extern_mod_crate_map = oldmap::HashMap; +type extern_mod_crate_map = @mut LinearMap; pub fn mk_cstore(intr: @ident_interner) -> CStore { - let meta_cache = oldmap::HashMap(); - let crate_map = oldmap::HashMap(); + let meta_cache = @mut LinearMap::new(); + let crate_map = @mut LinearMap::new(); return CStore { metas: meta_cache, extern_mod_crate_map: crate_map, @@ -67,7 +66,7 @@ pub fn mk_cstore(intr: @ident_interner) -> CStore { pub fn get_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> @crate_metadata { - return cstore.metas.get(&cnum); + return *cstore.metas.get(&cnum); } pub fn get_crate_hash(cstore: @mut CStore, cnum: ast::crate_num) -> @~str { @@ -94,8 +93,8 @@ pub fn have_crate_data(cstore: @mut CStore, cnum: ast::crate_num) -> bool { pub fn iter_crate_data(cstore: @mut CStore, i: fn(ast::crate_num, @crate_metadata)) { let metas = cstore.metas; - for metas.each |&k, &v| { - i(k, v); + for metas.each |&(k, v)| { + i(*k, *v); } } @@ -132,15 +131,16 @@ pub fn get_used_link_args(cstore: @mut CStore) -> ~[~str] { pub fn add_extern_mod_stmt_cnum(cstore: @mut CStore, emod_id: ast::node_id, cnum: ast::crate_num) { - let extern_mod_crate_map = cstore.extern_mod_crate_map; - extern_mod_crate_map.insert(emod_id, cnum); + cstore.extern_mod_crate_map.insert(emod_id, cnum); } pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore, emod_id: ast::node_id) -> Option { - let extern_mod_crate_map = cstore.extern_mod_crate_map; - extern_mod_crate_map.find(&emod_id) + match cstore.extern_mod_crate_map.find(&emod_id) { + Some(&a) => Some(a), + None => None, + } } // returns hashes of crates directly used by this crate. Hashes are diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index f660c796fa3b8..0e4754f09c6c4 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -36,7 +36,6 @@ use core::str; use core::vec; use std::ebml::reader; use std::ebml; -use std::oldmap::HashMap; use std::oldmap; use std::serialize::Decodable; use syntax::ast_map; @@ -1129,8 +1128,8 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { } match cdata.cnum_map.find(&did.crate) { - option::Some(n) => ast::def_id { crate: n, node: did.node }, - option::None => fail!(~"didn't find a crate in the cnum_map") + Some(&n) => ast::def_id { crate: n, node: did.node }, + None => fail!(~"didn't find a crate in the cnum_map") } } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 403cc1cf97845..dda17621f976a 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -28,6 +28,7 @@ use core::dvec; use core::flate; use core::float; use core::hash::{Hash, HashUtil}; +use core::hashmap::linear::LinearMap; use core::int; use core::io::WriterUtil; use core::io; @@ -36,7 +37,6 @@ use core::str; use core::to_bytes::IterBytes; use core::uint; use core::vec; -use std::oldmap::HashMap; use std::serialize::Encodable; use std::{ebml, oldmap}; use std; @@ -55,7 +55,7 @@ use syntax; use writer = std::ebml::writer; // used by astencode: -type abbrev_map = oldmap::HashMap; +type abbrev_map = @mut LinearMap; pub type encode_inlined_item = @fn(ecx: @EncodeContext, ebml_w: writer::Encoder, @@ -65,10 +65,10 @@ pub type encode_inlined_item = @fn(ecx: @EncodeContext, pub struct EncodeParams { diag: span_handler, tcx: ty::ctxt, - reachable: HashMap, + reachable: @mut LinearMap, reexports2: middle::resolve::ExportMap2, - item_symbols: HashMap, - discrim_symbols: HashMap, + item_symbols: @mut LinearMap, + discrim_symbols: @mut LinearMap, link_meta: LinkMeta, cstore: @mut cstore::CStore, encode_inlined_item: encode_inlined_item @@ -91,10 +91,10 @@ pub struct EncodeContext { diag: span_handler, tcx: ty::ctxt, stats: @mut Stats, - reachable: HashMap, + reachable: @mut LinearMap, reexports2: middle::resolve::ExportMap2, - item_symbols: HashMap, - discrim_symbols: HashMap, + item_symbols: @mut LinearMap, + discrim_symbols: @mut LinearMap, link_meta: LinkMeta, cstore: @mut cstore::CStore, encode_inlined_item: encode_inlined_item, @@ -234,11 +234,11 @@ fn encode_type(ecx: @EncodeContext, ebml_w: writer::Encoder, typ: ty::t) { fn encode_symbol(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); let sym = match ecx.item_symbols.find(&id) { - Some(ref x) => (/*bad*/copy *x), - None => { - ecx.diag.handler().bug( - fmt!("encode_symbol: id not found %d", id)); - } + Some(&ref x) => (/*bad*/copy *x), + None => { + ecx.diag.handler().bug( + fmt!("encode_symbol: id not found %d", id)); + } }; ebml_w.writer.write(str::to_bytes(sym)); ebml_w.end_tag(); @@ -247,7 +247,7 @@ fn encode_symbol(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) { fn encode_discriminant(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); - ebml_w.writer.write(str::to_bytes(ecx.discrim_symbols.get(&id))); + ebml_w.writer.write(str::to_bytes(*ecx.discrim_symbols.get(&id))); ebml_w.end_tag(); } @@ -1307,7 +1307,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] { link_meta: /*bad*/copy parms.link_meta, cstore: parms.cstore, encode_inlined_item: parms.encode_inlined_item, - type_abbrevs: ty::new_ty_hash() + type_abbrevs: @mut LinearMap::new() }; let ebml_w = writer::Encoder(wr as io::Writer); diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 233c0949fa66a..bce8d28f7aeb7 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -25,7 +25,6 @@ use core::vec; use syntax::ast; use syntax::ast::*; use syntax::codemap::{respan, dummy_sp}; -use std::oldmap::HashMap; // Compact string representation for ty::t values. API ty_str & // parse_from_str. Extra parameters are for converting to/from def_ids in the diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 8fd1d176b6593..d6519f39f2dd1 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -16,11 +16,11 @@ use core::prelude::*; use middle::ty::{Vid, param_ty}; use middle::ty; +use core::hashmap::linear::LinearMap; use core::io::WriterUtil; use core::io; use core::uint; use core::vec; -use std::oldmap::HashMap; use syntax::ast::*; use syntax::diagnostic::span_handler; use syntax::print::pprust::*; @@ -47,7 +47,7 @@ pub struct ty_abbrev { pub enum abbrev_ctxt { ac_no_abbrevs, - ac_use_abbrevs(HashMap), + ac_use_abbrevs(@mut LinearMap), } fn cx_uses_abbrevs(cx: @ctxt) -> bool { @@ -74,7 +74,7 @@ pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) { } ac_use_abbrevs(abbrevs) => { match abbrevs.find(&t) { - Some(a) => { w.write_str(*a.s); return; } + Some(&a) => { w.write_str(*a.s); return; } None => { let pos = w.tell(); match ty::type_def_id(t) { diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index b52a2d0bb093c..50d3b7a19612e 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -31,7 +31,6 @@ use std::ebml::reader::get_doc; use std::ebml::reader; use std::ebml::writer::Encoder; use std::ebml; -use std::oldmap::HashMap; use std::prettyprint; use std::serialize; use std::serialize::{Encodable, EncoderHelpers, DecoderHelpers}; @@ -890,7 +889,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, do ebml_w.tag(c::tag_table_freevars) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - do ebml_w.emit_from_vec(**fv) |fv_entry| { + do ebml_w.emit_from_vec(***fv) |fv_entry| { encode_freevar_entry(ebml_w, *fv_entry) } } @@ -930,7 +929,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, // } //} - do option::iter(&maps.mutbl_map.find(&id)) |_m| { + do option::iter(&maps.mutbl_map.find(&id)) |&_m| { do ebml_w.tag(c::tag_table_mutbl) { ebml_w.id(id); } @@ -984,7 +983,7 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext, do ebml_w.tag(c::tag_table_capture_map) { ebml_w.id(id); do ebml_w.tag(c::tag_table_val) { - do ebml_w.emit_from_vec(*cap_vars) |cap_var| { + do ebml_w.emit_from_vec(**cap_vars) |cap_var| { cap_var.encode(&ebml_w); } } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index d6af2f7862644..910f2065f305d 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -33,9 +33,9 @@ use util::ppaux::ty_to_str; use core::cmp; use core::dvec::DVec; +use core::hashmap::linear::LinearMap; use core::uint; use core::vec; -use std::oldmap::HashMap; use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast; use syntax::ast_util; @@ -47,7 +47,7 @@ struct CheckLoanCtxt { bccx: @BorrowckCtxt, req_maps: ReqMaps, - reported: HashMap, + reported: @mut LinearMap, declared_purity: @mut ast::purity, fn_args: @mut @~[ast::node_id] @@ -71,7 +71,7 @@ pub fn check_loans(bccx: @BorrowckCtxt, let clcx = @mut CheckLoanCtxt { bccx: bccx, req_maps: req_maps, - reported: HashMap(), + reported: @mut LinearMap::new(), declared_purity: @mut ast::impure_fn, fn_args: @mut @~[] }; @@ -130,7 +130,7 @@ pub impl CheckLoanCtxt { loop { match pure_map.find(&scope_id) { None => (), - Some(ref e) => return Some(pc_cmt((*e))) + Some(&e) => return Some(pc_cmt((e))) } match region_map.find(&scope_id) { diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index 457701e659a69..531843dfd4469 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -34,9 +34,10 @@ use util::common::indenter; use util::ppaux::{expr_repr, region_to_str}; use core::dvec; +use core::hashmap::linear::LinearMap; use core::hashmap::linear::LinearSet; use core::vec; -use std::oldmap::HashMap; + use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast; use syntax::codemap::span; @@ -82,7 +83,10 @@ struct GatherLoanCtxt { pub fn gather_loans(bccx: @BorrowckCtxt, crate: @ast::crate) -> ReqMaps { let glcx = @mut GatherLoanCtxt { bccx: bccx, - req_maps: ReqMaps { req_loan_map: HashMap(), pure_map: HashMap() }, + req_maps: ReqMaps { + req_loan_map: @mut LinearMap::new(), + pure_map: @mut LinearMap::new() + }, item_ub: 0, root_ub: 0, ignore_adjustments: LinearSet::new() diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index e0f3aad4bc25e..7da7aec038322 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -238,12 +238,12 @@ use util::ppaux::{ty_to_str, region_to_str, explain_region}; use core::cmp; use core::dvec::DVec; +use core::hashmap::linear::LinearMap; use core::io; use core::result::{Result, Ok, Err}; use core::to_bytes; use std::list::{List, Cons, Nil}; use std::list; -use std::oldmap::{HashMap, Set}; use syntax::ast::{mutability, m_mutbl, m_imm, m_const}; use syntax::ast; use syntax::ast_map; @@ -269,10 +269,10 @@ pub fn check_crate( method_map: method_map, moves_map: moves_map, capture_map: capture_map, - root_map: root_map(), - mutbl_map: HashMap(), - write_guard_map: HashMap(), - stmt_map: HashMap(), + root_map: @mut LinearMap::new(), + mutbl_map: @mut LinearMap::new(), + write_guard_map: @mut LinearMap::new(), + stmt_map: @mut LinearMap::new(), stats: @mut BorrowStats { loaned_paths_same: 0, loaned_paths_imm: 0, @@ -343,7 +343,7 @@ pub struct RootInfo { // a map mapping id's of expressions of gc'd type (@T, @[], etc) where // the box needs to be kept live to the id of the scope for which they // must stay live. -pub type root_map = HashMap; +pub type root_map = @mut LinearMap; // the keys to the root map combine the `id` of the expression with // the number of types that it is autodereferenced. So, for example, @@ -358,11 +358,11 @@ pub struct root_map_key { // set of ids of local vars / formal arguments that are modified / moved. // this is used in trans for optimization purposes. -pub type mutbl_map = HashMap; +pub type mutbl_map = @mut LinearMap; // A set containing IDs of expressions of gc'd type that need to have a write // guard. -pub type write_guard_map = HashMap; +pub type write_guard_map = @mut LinearMap; // Errors that can occur #[deriving_eq] @@ -415,8 +415,8 @@ pub struct Loan { /// - `pure_map`: map from block/expr that must be pure to the error message /// that should be reported if they are not pure pub struct ReqMaps { - req_loan_map: HashMap>, - pure_map: HashMap + req_loan_map: @mut LinearMap>, + pure_map: @mut LinearMap } pub fn save_and_restore(save_and_restore_t: &mut T, @@ -459,9 +459,6 @@ impl to_bytes::IterBytes for root_map_key { } } -pub fn root_map() -> root_map { - return HashMap(); -} // ___________________________________________________________________________ // Misc diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index c86f7ea5a922f..c5676dcfe1844 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -17,7 +17,6 @@ use middle::typeck; use util::ppaux; use core::option; -use std::oldmap::HashMap; use syntax::ast::*; use syntax::codemap; use syntax::{visit, ast_util, ast_map}; diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index f736c403cfccd..9567551a780b3 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -23,7 +23,6 @@ use core::cmp; use core::option; use core::uint; use core::vec; -use std::oldmap::HashMap; use std::sort; use syntax::ast::*; use syntax::ast_util::{variant_def_ids, unguarded_pat, walk_pat}; diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 52520b59b446e..fc637371b70be 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -15,6 +15,7 @@ use middle::resolve; use middle::ty; +use core::hashmap::linear::LinearMap; use core::int; use core::option::*; use core::vec; @@ -32,7 +33,7 @@ pub struct freevar_entry { span: span //< First span where it is accessed (there can be multiple) } pub type freevar_info = @~[@freevar_entry]; -pub type freevar_map = HashMap; +pub type freevar_map = @mut LinearMap; // Searches through part of the AST for all references to locals or // upvars in this frame and returns the list of definition IDs thus found. @@ -41,7 +42,7 @@ pub type freevar_map = HashMap; // in order to start the search. fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk) -> freevar_info { - let seen = HashMap(); + let seen = @mut LinearMap::new(); let refs = @mut ~[]; fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt) { } @@ -94,7 +95,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk) // one pass. This could be improved upon if it turns out to matter. pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) -> freevar_map { - let freevars = HashMap(); + let freevars = @mut LinearMap::new(); let walk_fn: @fn(&visit::fn_kind, &ast::fn_decl, @@ -116,8 +117,8 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) -> pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { match tcx.freevars.find(&fid) { - None => fail!(~"get_freevars: "+int::to_str(fid)+~" has no freevars"), - Some(d) => return d + None => fail!(~"get_freevars: "+int::to_str(fid)+~" has no freevars"), + Some(&d) => d } } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index aca5675aa151d..ab496616ba118 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -20,10 +20,10 @@ use middle::typeck; use middle; use util::ppaux::{ty_to_str, tys_to_str}; +use core::hashmap::linear::LinearMap; use core::option; use core::str; use core::vec; -use std::oldmap::HashMap; use syntax::ast::*; use syntax::codemap::{span, spanned}; use syntax::print::pprust::expr_to_str; @@ -60,7 +60,7 @@ use syntax::{visit, ast_util}; pub const try_adding: &str = "Try adding a move"; -pub type rval_map = HashMap; +pub type rval_map = @mut LinearMap; pub struct Context { tcx: ty::ctxt, diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index c0ce6ee515fab..646ffd6f9500f 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -32,8 +32,8 @@ use syntax::ast_util::{local_def}; use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor}; use syntax::visit::{visit_crate, visit_item}; +use core::hashmap::linear::LinearMap; use core::ptr; -use std::oldmap::HashMap; use str_eq = core::str::eq; pub enum LangItem { @@ -261,7 +261,7 @@ fn LanguageItemCollector(crate: @crate, session: Session, items: &r/mut LanguageItems) -> LanguageItemCollector/&r { - let item_refs = HashMap(); + let item_refs = @mut LinearMap::new(); item_refs.insert(@~"const", ConstTraitLangItem as uint); item_refs.insert(@~"copy", CopyTraitLangItem as uint); @@ -319,7 +319,8 @@ struct LanguageItemCollector { crate: @crate, session: Session, - item_refs: HashMap<@~str, uint>, + //XXX: maybe immutable? + item_refs: @mut LinearMap<@~str, uint>, } pub impl LanguageItemCollector { @@ -361,12 +362,8 @@ pub impl LanguageItemCollector { } match self.item_refs.find(&value) { - None => { - // Didn't match. - } - Some(item_index) => { - self.collect_item(item_index, item_def_id) - } + None => (), + Some(&item_index) => self.collect_item(item_index, item_def_id) } } @@ -399,10 +396,10 @@ pub impl LanguageItemCollector { } fn check_completeness(&self) { - for self.item_refs.each |&key, &item_ref| { - match self.items.items[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)); + self.session.err(fmt!("no item found for `%s`", **key)); } Some(_) => { // OK. diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 8bcc573ac36cb..715fa7c4e2abe 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -19,6 +19,7 @@ use util::ppaux::{ty_to_str}; use core::char; use core::cmp; use core::either; +use core::hashmap::linear::LinearMap; use core::i8; use core::i16; use core::i32; @@ -32,7 +33,7 @@ use core::u32; use core::u64; use core::uint; use core::vec; -use std::oldmap::{Map, HashMap}; +use std::oldmap::Map; use std::oldmap; use std::smallintmap::SmallIntMap; use syntax::ast_util::{path_to_ident}; @@ -113,154 +114,155 @@ struct LintSpec { default: level } -pub type LintDict = HashMap<@~str, @LintSpec>; +pub type LintDict = @mut LinearMap<@~str, @LintSpec>; /* Pass names should not contain a '-', as the compiler normalizes '-' to '_' in command-line flags */ pub fn get_lint_dict() -> LintDict { - let v = ~[ - (@~"ctypes", + let map = @mut LinearMap::new(); + + map.insert(@~"ctypes", @LintSpec { lint: ctypes, desc: "proper use of core::libc types in foreign modules", default: warn - }), + }); - (@~"unused_imports", + map.insert(@~"unused_imports", @LintSpec { lint: unused_imports, desc: "imports that are never used", default: allow - }), + }); - (@~"while_true", + map.insert(@~"while_true", @LintSpec { lint: while_true, desc: "suggest using loop { } instead of while(true) { }", default: warn - }), + }); - (@~"path_statement", + map.insert(@~"path_statement", @LintSpec { lint: path_statement, desc: "path statements with no effect", default: warn - }), + }); - (@~"unrecognized_lint", + map.insert(@~"unrecognized_lint", @LintSpec { lint: unrecognized_lint, desc: "unrecognized lint attribute", default: warn - }), + }); - (@~"non_implicitly_copyable_typarams", + map.insert(@~"non_implicitly_copyable_typarams", @LintSpec { lint: non_implicitly_copyable_typarams, desc: "passing non implicitly copyable types as copy type params", default: warn - }), + }); - (@~"vecs_implicitly_copyable", + map.insert(@~"vecs_implicitly_copyable", @LintSpec { lint: vecs_implicitly_copyable, desc: "make vecs and strs not implicitly copyable \ (only checked at top level)", default: warn - }), + }); - (@~"implicit_copies", + map.insert(@~"implicit_copies", @LintSpec { lint: implicit_copies, desc: "implicit copies of non implicitly copyable data", default: warn - }), + }); - (@~"deprecated_mode", + map.insert(@~"deprecated_mode", @LintSpec { lint: deprecated_mode, desc: "warn about deprecated uses of modes", default: warn - }), + }); - (@~"deprecated_pattern", + map.insert(@~"deprecated_pattern", @LintSpec { lint: deprecated_pattern, desc: "warn about deprecated uses of pattern bindings", default: allow - }), + }); - (@~"non_camel_case_types", + map.insert(@~"non_camel_case_types", @LintSpec { lint: non_camel_case_types, desc: "types, variants and traits should have camel case names", default: allow - }), + }); - (@~"managed_heap_memory", + map.insert(@~"managed_heap_memory", @LintSpec { lint: managed_heap_memory, desc: "use of managed (@ type) heap memory", default: allow - }), + }); - (@~"owned_heap_memory", + map.insert(@~"owned_heap_memory", @LintSpec { lint: owned_heap_memory, desc: "use of owned (~ type) heap memory", default: allow - }), + }); - (@~"heap_memory", + map.insert(@~"heap_memory", @LintSpec { lint: heap_memory, desc: "use of any (~ type or @ type) heap memory", default: allow - }), + }); - (@~"structural_records", + map.insert(@~"structural_records", @LintSpec { lint: structural_records, desc: "use of any structural records", default: deny - }), + }); - (@~"legacy modes", + map.insert(@~"legacy modes", @LintSpec { lint: legacy_modes, desc: "allow legacy modes", default: forbid - }), + }); - (@~"type_limits", + map.insert(@~"type_limits", @LintSpec { lint: type_limits, desc: "comparisons made useless by limits of the types involved", default: warn - }), + }); - (@~"default_methods", + map.insert(@~"default_methods", @LintSpec { lint: default_methods, desc: "allow default methods", default: deny - }), + }); - (@~"deprecated_self", + map.insert(@~"deprecated_self", @LintSpec { lint: deprecated_self, desc: "warn about deprecated uses of `self`", default: warn - }), + }); - (@~"deprecated_mutable_fields", + map.insert(@~"deprecated_mutable_fields", @LintSpec { lint: deprecated_mutable_fields, desc: "deprecated mutable fields in structures", default: deny - }), + }); /* FIXME(#3266)--make liveness warnings lintable (@~"unused_variable", @@ -277,13 +279,12 @@ pub fn get_lint_dict() -> LintDict { default: warn }), */ - ]; - oldmap::hash_from_vec(v) + map } // This is a highly not-optimal set of data structure decisions. type LintModes = @mut SmallIntMap; -type LintModeMap = HashMap; +type LintModeMap = @mut LinearMap; // settings_map maps node ids of items with non-default lint settings // to their settings; default_settings contains the settings for everything @@ -296,7 +297,7 @@ pub struct LintSettings { pub fn mk_lint_settings() -> LintSettings { LintSettings { default_settings: @mut SmallIntMap::new(), - settings_map: HashMap() + settings_map: @mut LinearMap::new() } } @@ -313,7 +314,7 @@ pub fn get_lint_settings_level(settings: LintSettings, item_id: ast::node_id) -> level { match settings.settings_map.find(&item_id) { - Some(modes) => get_lint_level(modes, lint_mode), + Some(&modes) => get_lint_level(modes, lint_mode), None => get_lint_level(settings.default_settings, lint_mode) } } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 95f28578fec66..302744c88520f 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1580,7 +1580,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) { match self.ir.variable_moves_map.find(&expr.id) { None => {} - Some(entire_expr) => { + Some(&entire_expr) => { debug!("(checking expr) is a move: `%s`", expr_to_str(expr, self.tcx.sess.intr())); self.check_move_from_var(ln, *var, entire_expr); diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index c360b3a23e735..3333473bea3af 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -216,6 +216,7 @@ use middle::typeck::check::{DerefArgs, DoDerefArgs, DontDerefArgs}; use util::ppaux; use util::common::indenter; +use core::hashmap::linear::LinearMap; use core::vec; use std::oldmap::HashMap; use syntax::ast::*; @@ -242,14 +243,14 @@ pub struct CaptureVar { mode: CaptureMode // How variable is being accessed } -pub type CaptureMap = HashMap; +pub type CaptureMap = @mut LinearMap; -pub type MovesMap = HashMap; +pub type MovesMap = @mut LinearMap; /** * For each variable which will be moved, links to the * expression */ -pub type VariableMovesMap = HashMap; +pub type VariableMovesMap = @mut LinearMap; /** See the section Output on the module comment for explanation. */ pub struct MoveMaps { @@ -282,9 +283,9 @@ pub fn compute_moves(tcx: ty::ctxt, tcx: tcx, method_map: method_map, move_maps: MoveMaps { - moves_map: HashMap(), - variable_moves_map: HashMap(), - capture_map: HashMap() + moves_map: @mut LinearMap::new(), + variable_moves_map: @mut LinearMap::new(), + capture_map: @mut LinearMap::new() } }; visit::visit_crate(*crate, visit_cx, visitor); diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 823af16c6054c..f0438d0e69f01 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -18,16 +18,16 @@ use syntax::ast_util::{path_to_ident, walk_pat}; use syntax::fold; use syntax::fold::*; use syntax::codemap::{span, respan}; -use std::oldmap::HashMap; +use core::hashmap::linear::LinearMap; -pub type PatIdMap = HashMap; +pub type PatIdMap = @mut LinearMap; // This is used because same-named variables in alternative patterns need to // use the node_id of their namesake in the first pattern. pub fn pat_id_map(dm: resolve::DefMap, pat: @pat) -> PatIdMap { - let map = HashMap(); + let map = @mut LinearMap::new(); do pat_bindings(dm, pat) |_bm, p_id, _s, n| { - map.insert(path_to_ident(n), p_id); + map.insert(path_to_ident(n), p_id); }; return map; } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 0d3524ed7fb2f..ed968f633ef0e 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -169,8 +169,8 @@ use util::common::indenter; use core::dvec::DVec; use core::dvec; +use core::hashmap::linear::LinearMap; use core::libc::c_ulonglong; -use std::oldmap::HashMap; use syntax::ast::def_id; use syntax::ast; use syntax::ast::ident; @@ -324,7 +324,7 @@ pub struct BindingInfo { ty: ty::t, } -pub type BindingsMap = HashMap; +pub type BindingsMap = @mut LinearMap; pub struct ArmData { bodycx: block, @@ -940,7 +940,7 @@ pub fn root_pats_as_necessary(bcx: block, let key = root_map_key {id: pat_id, derefs: 0u }; match bcx.ccx().maps.root_map.find(&key) { None => (), - Some(root_info) => { + Some(&root_info) => { // Note: the scope_id will always be the id of the match. See // the extended comment in rustc::middle::borrowck::preserve() // for details (look for the case covering cat_discr). @@ -1612,7 +1612,7 @@ pub fn trans_match_inner(scope_cx: block, // to an alloca() that will be the value for that local variable. // Note that we use the names because each binding will have many ids // from the various alternatives. - let bindings_map = HashMap(); + let bindings_map = @mut LinearMap::new(); do pat_bindings(tcx.def_map, arm.pats[0]) |bm, p_id, _s, path| { let ident = path_to_ident(path); let variable_ty = node_id_type(bcx, p_id); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 7998d4ebcacd6..19007ba60af7c 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -73,6 +73,7 @@ use util::ppaux; use core::either; use core::hash; +use core::hashmap::linear::LinearMap; use core::int; use core::io; use core::libc::{c_uint, c_ulonglong}; @@ -1034,16 +1035,14 @@ pub fn add_root_cleanup(bcx: block, let mut bcx_sid = bcx; loop { bcx_sid = match bcx_sid.node_info { - Some(NodeInfo { id, _ }) if id == scope_id => { - return bcx_sid - } - _ => { - match bcx_sid.parent { - None => bcx.tcx().sess.bug( - fmt!("no enclosing scope with id %d", scope_id)), - Some(bcx_par) => bcx_par + Some(NodeInfo { id, _ }) if id == scope_id => { + return bcx_sid + } + _ => match bcx_sid.parent { + None => bcx.tcx().sess.bug( + fmt!("no enclosing scope with id %d", scope_id)), + Some(bcx_par) => bcx_par } - } } } } @@ -1136,10 +1135,10 @@ pub fn init_local(bcx: block, local: @ast::local) -> block { } let llptr = match bcx.fcx.lllocals.find(&local.node.id) { - Some(local_mem(v)) => v, - _ => { bcx.tcx().sess.span_bug(local.span, - ~"init_local: Someone forgot to document why it's\ - safe to assume local.node.init must be local_mem!"); + Some(&local_mem(v)) => v, + _ => { bcx.tcx().sess.span_bug(local.span, + ~"init_local: Someone forgot to document why it's\ + safe to assume local.node.init must be local_mem!"); } }; @@ -1428,17 +1427,17 @@ pub fn with_scope_datumblock(bcx: block, opt_node_info: Option, pub fn block_locals(b: &ast::blk, it: fn(@ast::local)) { for vec::each(b.node.stmts) |s| { match s.node { - ast::stmt_decl(d, _) => { - match /*bad*/copy d.node { - ast::decl_local(locals) => { - for vec::each(locals) |local| { - it(*local); + ast::stmt_decl(d, _) => { + match /*bad*/copy d.node { + ast::decl_local(locals) => { + for vec::each(locals) |local| { + it(*local); + } + } + _ => {/* fall through */ } } - } - _ => {/* fall through */ } } - } - _ => {/* fall through */ } + _ => {/* fall through */ } } } } @@ -1489,7 +1488,7 @@ pub fn call_memcpy(cx: block, dst: ValueRef, src: ValueRef, | session::arch_mips => ~"llvm.memcpy.p0i8.p0i8.i32", session::arch_x86_64 => ~"llvm.memcpy.p0i8.p0i8.i64" }; - let memcpy = ccx.intrinsics.get(&key); + let memcpy = *ccx.intrinsics.get(&key); let src_ptr = PointerCast(cx, src, T_ptr(T_i8())); let dst_ptr = PointerCast(cx, dst, T_ptr(T_i8())); let size = IntCast(cx, n_bytes, ccx.int_type); @@ -1538,7 +1537,7 @@ pub fn memzero(cx: block, llptr: ValueRef, llty: TypeRef) { } } - let llintrinsicfn = ccx.intrinsics.get(&intrinsic_key); + let llintrinsicfn = *ccx.intrinsics.get(&intrinsic_key); let llptr = PointerCast(cx, llptr, T_ptr(T_i8())); let llzeroval = C_u8(0); let size = IntCast(cx, machine::llsize_of(ccx, llty), ccx.int_type); @@ -1627,9 +1626,9 @@ pub fn new_fn_ctxt_w_id(ccx: @CrateContext, llself: None, personality: None, loop_ret: None, - llargs: @HashMap(), - lllocals: @HashMap(), - llupvars: @HashMap(), + llargs: @mut LinearMap::new(), + lllocals: @mut LinearMap::new(), + llupvars: @mut LinearMap::new(), id: id, impl_id: impl_id, param_substs: param_substs, @@ -1944,7 +1943,7 @@ pub fn trans_enum_variant(ccx: @CrateContext, // this function as an opaque blob due to the way that type_of() // works. So we have to cast to the destination's view of the type. let llarg = match fcx.llargs.find(&va.id) { - Some(local_mem(x)) => x, + Some(&local_mem(x)) => x, _ => fail!(~"trans_enum_variant: how do we know this works?"), }; let arg_ty = arg_tys[i].ty; @@ -1995,7 +1994,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext, for fields.eachi |i, field| { let lldestptr = GEPi(bcx, fcx.llretptr, [0, 0, i]); let llarg = match fcx.llargs.get(&field.node.id) { - local_mem(x) => x, + &local_mem(x) => x, _ => { ccx.tcx.sess.bug(~"trans_tuple_struct: llarg wasn't \ local_mem") @@ -2374,33 +2373,33 @@ pub fn get_dtor_symbol(ccx: @CrateContext, -> ~str { let t = ty::node_id_to_type(ccx.tcx, id); match ccx.item_symbols.find(&id) { - Some(ref s) => (/*bad*/copy *s), + Some(&ref s) => /* bad */ copy *s, None if substs.is_none() => { - let s = mangle_exported_name( - ccx, - vec::append(path, ~[path_name((ccx.names)(~"dtor"))]), - t); - // XXX: Bad copy, use `@str`? - ccx.item_symbols.insert(id, copy s); - s + let s = mangle_exported_name( + ccx, + vec::append(path, ~[path_name((ccx.names)(~"dtor"))]), + t); + // XXX: Bad copy, use `@str`? + ccx.item_symbols.insert(id, copy s); + s } - None => { - // Monomorphizing, so just make a symbol, don't add - // this to item_symbols - match substs { - Some(ss) => { - let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, ss.self_ty, t); - mangle_exported_name( - ccx, - vec::append(path, - ~[path_name((ccx.names)(~"dtor"))]), - mono_ty) - } - None => { - ccx.sess.bug(fmt!("get_dtor_symbol: not monomorphizing and \ - couldn't find a symbol for dtor %?", path)); + None => { + // Monomorphizing, so just make a symbol, don't add + // this to item_symbols + match substs { + Some(ss) => { + let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, ss.self_ty, t); + mangle_exported_name( + ccx, + vec::append(path, + ~[path_name((ccx.names)(~"dtor"))]), + mono_ty) + } + None => { + ccx.sess.bug(fmt!("get_dtor_symbol: not monomorphizing and \ + couldn't find a symbol for dtor %?", path)); + } } - } } } } @@ -2644,7 +2643,8 @@ pub fn p2i(ccx: @CrateContext, v: ValueRef) -> ValueRef { } } -pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<~str, ValueRef> { +pub fn declare_intrinsics(llmod: ModuleRef) + -> @mut LinearMap<~str, ValueRef> { let T_memcpy32_args: ~[TypeRef] = ~[T_ptr(T_i8()), T_ptr(T_i8()), T_i32(), T_i32(), T_i1()]; let T_memcpy64_args: ~[TypeRef] = @@ -2777,7 +2777,7 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<~str, ValueRef> { let bswap64 = decl_cdecl_fn(llmod, ~"llvm.bswap.i64", T_fn(~[T_i64()], T_i64())); - let intrinsics = HashMap(); + let intrinsics = @mut LinearMap::new(); intrinsics.insert(~"llvm.gcroot", gcroot); intrinsics.insert(~"llvm.gcread", gcread); intrinsics.insert(~"llvm.memcpy.p0i8.p0i8.i32", memcpy32); @@ -2838,7 +2838,7 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<~str, ValueRef> { } pub fn declare_dbg_intrinsics(llmod: ModuleRef, - intrinsics: HashMap<~str, ValueRef>) { + intrinsics: @mut LinearMap<~str, ValueRef>) { let declare = decl_cdecl_fn(llmod, ~"llvm.dbg.declare", T_fn(~[T_metadata(), T_metadata()], T_void())); @@ -2853,7 +2853,7 @@ pub fn declare_dbg_intrinsics(llmod: ModuleRef, pub fn trap(bcx: block) { let v: ~[ValueRef] = ~[]; match bcx.ccx().intrinsics.find(&~"llvm.trap") { - Some(x) => { Call(bcx, x, v); }, + Some(&x) => { Call(bcx, x, v); }, _ => bcx.sess().bug(~"unbound llvm.trap in trap") } } @@ -3092,21 +3092,22 @@ pub fn trans_crate(sess: session::Session, item_vals: HashMap(), exp_map2: emap2, reachable: reachable, - item_symbols: HashMap(), + item_symbols: @mut LinearMap::new(), link_meta: link_meta, - enum_sizes: ty::new_ty_hash(), - discrims: HashMap(), - discrim_symbols: HashMap(), + enum_sizes: HashMap(), + discrims: @mut LinearMap::new(), + discrim_symbols: @mut LinearMap::new(), tydescs: ty::new_ty_hash(), finished_tydescs: @mut false, - external: HashMap(), - monomorphized: HashMap(), - monomorphizing: HashMap(), - type_use_cache: HashMap(), - vtables: oldmap::HashMap(), - const_cstr_cache: HashMap(), - const_globals: HashMap(), - const_values: HashMap(), + external: HashMap(), //changing this to LinearMap + //causes Illegal instruction (core dumped) + monomorphized: @mut LinearMap::new(), + monomorphizing: @mut LinearMap::new(), + type_use_cache: @mut LinearMap::new(), + vtables: @mut LinearMap::new(), + const_cstr_cache: @mut LinearMap::new(), + const_globals: @mut LinearMap::new(), + const_values: @mut LinearMap::new(), module_data: HashMap(), lltypes: ty::new_ty_hash(), llsizingtypes: ty::new_ty_hash(), @@ -3128,7 +3129,7 @@ pub fn trans_crate(sess: session::Session, n_inlines: 0u, n_closures: 0u, llvm_insn_ctxt: @mut ~[], - llvm_insns: HashMap(), + llvm_insns: @mut LinearMap::new(), fn_times: @mut ~[] }, upcalls: upcall::declare_upcalls(targ_cfg, llmod), @@ -3178,8 +3179,8 @@ pub fn trans_crate(sess: session::Session, } if ccx.sess.count_llvm_insns() { - for ccx.stats.llvm_insns.each |&k, &v| { - io::println(fmt!("%-7u %s", v, k)); + for ccx.stats.llvm_insns.each |&(k, v)| { + io::println(fmt!("%-7u %s", *v, *k)); } } return (llmod, link_meta); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 8db48e1de6055..3e412f90ea2c6 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -19,13 +19,13 @@ use middle::trans::machine::llsize_of_real; use core::prelude::*; use core::cast::transmute; use core::cast; +use core::hashmap::linear::LinearMap; use core::libc::{c_uint, c_int, c_ulonglong}; use core::libc; use core::option::Some; use core::ptr; use core::str; use core::vec; -use std::oldmap::HashMap; use syntax::codemap::span; use syntax::codemap; @@ -58,7 +58,7 @@ pub fn count_insn(cx: block, category: &str) { // Build version of path with cycles removed. // Pass 1: scan table mapping str -> rightmost pos. - let mm = HashMap(); + let mut mm = LinearMap::new(); let len = vec::len(*v); let mut i = 0u; while i < len { @@ -74,7 +74,7 @@ pub fn count_insn(cx: block, category: &str) { i = 0u; while i < len { let e = /*bad*/copy v[i]; - i = mm.get(&e); + i = *mm.get(&e); s += ~"/"; s += e; i += 1u; @@ -84,7 +84,7 @@ pub fn count_insn(cx: block, category: &str) { s += category; let n = match h.find(&s) { - Some(n) => n, + Some(&n) => n, _ => 0u }; h.insert(s, n+1u); diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index fd149aa71e576..a6c02670e52fe 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -28,7 +28,6 @@ use middle::ty; use util::ppaux::ty_to_str; use core::libc::c_uint; -use std::oldmap::HashMap; use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; use syntax::ast_util; @@ -416,7 +415,7 @@ pub fn trans_expr_fn(bcx: block, let Result {bcx: bcx, val: closure} = match sigil { ast::BorrowedSigil | ast::ManagedSigil | ast::OwnedSigil => { - let cap_vars = ccx.maps.capture_map.get(&user_id); + let cap_vars = *ccx.maps.capture_map.get(&user_id); let ret_handle = match is_loop_body {Some(x) => x, None => None}; let ClosureResult {llbox, cdata_ty, bcx} diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index c703632445666..fa250d2d573a8 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -47,12 +47,14 @@ use util::ppaux::{expr_repr, ty_to_str}; use core::cast; use core::cmp; use core::hash; +use core::hashmap::linear::LinearMap; use core::libc::c_uint; use core::ptr; use core::str; use core::to_bytes; use core::vec::raw::to_ptr; use core::vec; +use core::hashmap::linear::LinearMap; use std::oldmap::{HashMap, Set}; use syntax::ast::ident; use syntax::ast_map::path; @@ -137,7 +139,7 @@ pub struct Stats { n_inlines: uint, n_closures: uint, llvm_insn_ctxt: @mut ~[~str], - llvm_insns: HashMap<~str, uint>, + llvm_insns: @mut LinearMap<~str, uint>, fn_times: @mut ~[(~str, int)] // (ident, time) } @@ -168,15 +170,15 @@ pub struct CrateContext { td: TargetData, tn: @TypeNames, externs: ExternMap, - intrinsics: HashMap<~str, ValueRef>, + intrinsics: @mut LinearMap<~str, ValueRef>, item_vals: HashMap, exp_map2: resolve::ExportMap2, reachable: reachable::map, - item_symbols: HashMap, + item_symbols: @mut LinearMap, link_meta: LinkMeta, enum_sizes: HashMap, - discrims: HashMap, - discrim_symbols: HashMap, + discrims: @mut LinearMap, + discrim_symbols: @mut LinearMap, tydescs: HashMap, // Set when running emit_tydescs to enforce that no more tydescs are // created. @@ -184,14 +186,14 @@ pub struct CrateContext { // Track mapping of external ids to local items imported for inlining external: HashMap>, // Cache instances of monomorphized functions - monomorphized: HashMap, - monomorphizing: HashMap, + monomorphized: @mut LinearMap, + monomorphizing: @mut LinearMap, // Cache computed type parameter uses (see type_use.rs) - type_use_cache: HashMap, + type_use_cache: @mut LinearMap, // Cache generated vtables - vtables: HashMap, + vtables: @mut LinearMap, // Cache of constant strings, - const_cstr_cache: HashMap<@~str, ValueRef>, + const_cstr_cache: @mut LinearMap<@~str, ValueRef>, // Reverse-direction for const ptrs cast from globals. // Key is an int, cast from a ValueRef holding a *T, @@ -201,10 +203,10 @@ pub struct CrateContext { // when we ptrcast, and we have to ptrcast during translation // of a [T] const because we form a slice, a [*T,int] pair, not // a pointer to an LLVM array type. - const_globals: HashMap, + const_globals: @mut LinearMap, // Cache of emitted const values - const_values: HashMap, + const_values: @mut LinearMap, module_data: HashMap<~str, ValueRef>, lltypes: HashMap, llsizingtypes: HashMap, @@ -300,12 +302,12 @@ pub struct fn_ctxt_ { loop_ret: Option<(ValueRef, ValueRef)>, // Maps arguments to allocas created for them in llallocas. - llargs: @HashMap, + llargs: @mut LinearMap, // Maps the def_ids for local variables to the allocas created for // them in llallocas. - lllocals: @HashMap, + lllocals: @mut LinearMap, // Same as above, but for closure upvars - llupvars: @HashMap, + llupvars: @mut LinearMap, // The node_id of the function, or -1 if it doesn't correspond to // a user-defined function. @@ -1142,7 +1144,7 @@ pub fn C_u8(i: uint) -> ValueRef { pub fn C_cstr(cx: @CrateContext, s: @~str) -> ValueRef { unsafe { match cx.const_cstr_cache.find(&s) { - Some(llval) => return llval, + Some(&llval) => return llval, None => () } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 36cda3dfbe977..c7789499d60e8 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -93,7 +93,7 @@ pub fn const_vec(cx: @CrateContext, e: @ast::expr, es: &[@ast::expr]) pub fn const_deref(cx: @CrateContext, v: ValueRef) -> ValueRef { unsafe { let v = match cx.const_globals.find(&(v as int)) { - Some(v) => v, + Some(&v) => v, None => v }; assert llvm::LLVMIsGlobalConstant(v) == True; @@ -146,7 +146,7 @@ pub fn get_const_val(cx: @CrateContext, def_id: ast::def_id) -> ValueRef { _ => cx.tcx.sess.bug(~"expected a const to be an item") } } - cx.const_values.get(&def_id.node) + *cx.const_values.get(&def_id.node) } pub fn const_expr(cx: @CrateContext, e: @ast::expr) -> ValueRef { @@ -493,7 +493,7 @@ pub fn trans_const(ccx: @CrateContext, _e: @ast::expr, id: ast::node_id) { let g = base::get_item_val(ccx, id); // At this point, get_item_val has already translated the // constant's initializer to determine its LLVM type. - let v = ccx.const_values.get(&id); + let v = *ccx.const_values.get(&id); llvm::LLVMSetInitializer(g, v); llvm::LLVMSetGlobalConstant(g, True); } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 94c90aaad6d86..9516a5c9e70b8 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -649,7 +649,7 @@ pub impl Datum { let key = root_map_key { id: expr_id, derefs: derefs }; let bcx = match ccx.maps.root_map.find(&key) { None => bcx, - Some(root_info) => self.root(bcx, root_info) + Some(&root_info) => self.root(bcx, root_info) }; // Perform the write guard, if necessary. diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d6c691f666763..be74a5692b2d4 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -23,10 +23,10 @@ use middle::trans; use middle::ty; use util::ppaux::ty_to_str; +use core::hashmap::linear::LinearMap; use core::libc; use core::option; use core::sys; -use std::oldmap::HashMap; use std::oldmap; use syntax::ast::Ty; use syntax::codemap::{span, CharPos}; @@ -111,7 +111,7 @@ pub struct DebugContext { pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> DebugContext { DebugContext { - llmetadata: oldmap::HashMap(), + llmetadata: @mut LinearMap::new(), names: new_namegen(intr), crate_file: crate } @@ -119,7 +119,7 @@ pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> DebugContext { fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { let existing = if cache.contains_key(&mdtag) { - cache.get(&mdtag) + /*bad*/ copy *cache.get(&mdtag) } else { ~[] }; @@ -157,7 +157,7 @@ struct RetvalMetadata { id: ast::node_id } -type metadata_cache = HashMap; +type metadata_cache = @mut LinearMap; enum debug_metadata { file_metadata(@Metadata), @@ -322,8 +322,8 @@ fn create_block(cx: block) -> @Metadata { }; let file_node = create_file(cx.ccx(), fname); let unique_id = match cache.find(&LexicalBlockTag) { - option::Some(v) => vec::len(v) as int, - option::None => 0 + Some(v) => vec::len(*v) as int, + None => 0 }; let lldata = ~[lltag(tg), parent, @@ -755,25 +755,25 @@ pub fn create_local_var(bcx: block, local: @ast::local) update_cache(cache, AutoVariableTag, local_var_metadata(mdval)); let llptr = match bcx.fcx.lllocals.find(&local.node.id) { - option::Some(local_mem(v)) => v, - option::Some(_) => { - bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ - something weird"); - } - option::None => { - match bcx.fcx.lllocals.get(&local.node.pat.id) { - local_imm(v) => v, - _ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ - something weird") + option::Some(&local_mem(v)) => v, + option::Some(_) => { + bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ + something weird"); + } + option::None => { + match bcx.fcx.lllocals.get(&local.node.pat.id) { + &local_imm(v) => v, + _ => bcx.tcx().sess.span_bug(local.span, + ~"local is bound to something weird") + } } - } }; let declargs = ~[llmdnode(~[llptr]), mdnode]; - trans::build::Call(bcx, cx.intrinsics.get(&~"llvm.dbg.declare"), - declargs); + trans::build::Call(bcx, *cx.intrinsics.get(&~"llvm.dbg.declare"), + declargs); return mdval; } -} + } pub fn create_arg(bcx: block, arg: ast::arg, sp: span) -> Option<@Metadata> { @@ -812,11 +812,11 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: span) update_cache(cache, tg, argument_metadata(mdval)); let llptr = match fcx.llargs.get(&arg.id) { - local_mem(v) | local_imm(v) => v, + &local_mem(v) | &local_imm(v) => v, }; let declargs = ~[llmdnode(~[llptr]), mdnode]; trans::build::Call(bcx, - cx.intrinsics.get(&~"llvm.dbg.declare"), + *cx.intrinsics.get(&~"llvm.dbg.declare"), declargs); return Some(mdval); } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 74cebaee2da4f..c9900299e74f2 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -149,11 +149,11 @@ use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn, use util::common::indenter; use util::ppaux::ty_to_str; -use std::oldmap::HashMap; use syntax::print::pprust::{expr_to_str}; use syntax::ast; use syntax::codemap; use syntax::codemap::spanned; +use core::hashmap::linear::LinearMap; // Destinations @@ -826,7 +826,7 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { // at the end of the scope with id `scope_id`: let root_key = root_map_key { id: expr.id, derefs: 0u }; for bcx.ccx().maps.root_map.find(&root_key).each |&root_info| { - bcx = unrooted_datum.root(bcx, root_info); + bcx = unrooted_datum.root(bcx, *root_info); } return DatumBlock {bcx: bcx, datum: unrooted_datum}; @@ -1018,7 +1018,7 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum { // Can't move upvars, so this is never a ZeroMemLastUse. let local_ty = node_id_type(bcx, nid); match bcx.fcx.llupvars.find(&nid) { - Some(val) => { + Some(&val) => { Datum { val: val, ty: local_ty, @@ -1033,10 +1033,10 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum { } } ast::def_arg(nid, _, _) => { - take_local(bcx, *bcx.fcx.llargs, nid) + take_local(bcx, bcx.fcx.llargs, nid) } ast::def_local(nid, _) | ast::def_binding(nid, _) => { - take_local(bcx, *bcx.fcx.lllocals, nid) + take_local(bcx, bcx.fcx.lllocals, nid) } ast::def_self(nid, _) => { let self_info: ValSelfData = match bcx.fcx.llself { @@ -1068,11 +1068,11 @@ pub fn trans_local_var(bcx: block, def: ast::def) -> Datum { }; fn take_local(bcx: block, - table: HashMap, + table: @mut LinearMap, nid: ast::node_id) -> Datum { let (v, mode) = match table.find(&nid) { - Some(local_mem(v)) => (v, ByRef), - Some(local_imm(v)) => (v, ByValue), + Some(&local_mem(v)) => (v, ByRef), + Some(&local_imm(v)) => (v, ByValue), None => { bcx.sess().bug(fmt!( "trans_local_var: no llval for local/arg %? found", nid)); diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 12271f51b35d1..b72356fa9a46d 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -542,7 +542,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, abi::tydesc_field_visit_glue, None); } ~"frame_address" => { - let frameaddress = ccx.intrinsics.get(&~"llvm.frameaddress"); + let frameaddress = *ccx.intrinsics.get(&~"llvm.frameaddress"); let frameaddress_val = Call(bcx, frameaddress, ~[C_i32(0i32)]); let star_u8 = ty::mk_imm_ptr( bcx.tcx(), @@ -581,7 +581,7 @@ pub fn trans_intrinsic(ccx: @CrateContext, let size = get_param(decl, first_real_arg + 2); let align = C_i32(1); let volatile = C_i1(false); - let llfn = bcx.ccx().intrinsics.get( + let llfn = *bcx.ccx().intrinsics.get( &~"llvm.memmove.p0i8.p0i8.i32"); Call(bcx, llfn, ~[dst_ptr, src_ptr, size, align, volatile]); } @@ -591,249 +591,249 @@ pub fn trans_intrinsic(ccx: @CrateContext, let size = get_param(decl, first_real_arg + 2); let align = C_i32(1); let volatile = C_i1(false); - let llfn = bcx.ccx().intrinsics.get( + let llfn = *bcx.ccx().intrinsics.get( &~"llvm.memmove.p0i8.p0i8.i64"); Call(bcx, llfn, ~[dst_ptr, src_ptr, size, align, volatile]); } ~"sqrtf32" => { let x = get_param(decl, first_real_arg); - let sqrtf = ccx.intrinsics.get(&~"llvm.sqrt.f32"); + let sqrtf = *ccx.intrinsics.get(&~"llvm.sqrt.f32"); Store(bcx, Call(bcx, sqrtf, ~[x]), fcx.llretptr); } ~"sqrtf64" => { let x = get_param(decl, first_real_arg); - let sqrtf = ccx.intrinsics.get(&~"llvm.sqrt.f64"); + let sqrtf = *ccx.intrinsics.get(&~"llvm.sqrt.f64"); Store(bcx, Call(bcx, sqrtf, ~[x]), fcx.llretptr); } ~"powif32" => { let a = get_param(decl, first_real_arg); let x = get_param(decl, first_real_arg + 1u); - let powif = ccx.intrinsics.get(&~"llvm.powi.f32"); + let powif = *ccx.intrinsics.get(&~"llvm.powi.f32"); Store(bcx, Call(bcx, powif, ~[a, x]), fcx.llretptr); } ~"powif64" => { let a = get_param(decl, first_real_arg); let x = get_param(decl, first_real_arg + 1u); - let powif = ccx.intrinsics.get(&~"llvm.powi.f64"); + let powif = *ccx.intrinsics.get(&~"llvm.powi.f64"); Store(bcx, Call(bcx, powif, ~[a, x]), fcx.llretptr); } ~"sinf32" => { let x = get_param(decl, first_real_arg); - let sinf = ccx.intrinsics.get(&~"llvm.sin.f32"); + let sinf = *ccx.intrinsics.get(&~"llvm.sin.f32"); Store(bcx, Call(bcx, sinf, ~[x]), fcx.llretptr); } ~"sinf64" => { let x = get_param(decl, first_real_arg); - let sinf = ccx.intrinsics.get(&~"llvm.sin.f64"); + let sinf = *ccx.intrinsics.get(&~"llvm.sin.f64"); Store(bcx, Call(bcx, sinf, ~[x]), fcx.llretptr); } ~"cosf32" => { let x = get_param(decl, first_real_arg); - let cosf = ccx.intrinsics.get(&~"llvm.cos.f32"); + let cosf = *ccx.intrinsics.get(&~"llvm.cos.f32"); Store(bcx, Call(bcx, cosf, ~[x]), fcx.llretptr); } ~"cosf64" => { let x = get_param(decl, first_real_arg); - let cosf = ccx.intrinsics.get(&~"llvm.cos.f64"); + let cosf = *ccx.intrinsics.get(&~"llvm.cos.f64"); Store(bcx, Call(bcx, cosf, ~[x]), fcx.llretptr); } ~"powf32" => { let a = get_param(decl, first_real_arg); let x = get_param(decl, first_real_arg + 1u); - let powf = ccx.intrinsics.get(&~"llvm.pow.f32"); + let powf = *ccx.intrinsics.get(&~"llvm.pow.f32"); Store(bcx, Call(bcx, powf, ~[a, x]), fcx.llretptr); } ~"powf64" => { let a = get_param(decl, first_real_arg); let x = get_param(decl, first_real_arg + 1u); - let powf = ccx.intrinsics.get(&~"llvm.pow.f64"); + let powf = *ccx.intrinsics.get(&~"llvm.pow.f64"); Store(bcx, Call(bcx, powf, ~[a, x]), fcx.llretptr); } ~"expf32" => { let x = get_param(decl, first_real_arg); - let expf = ccx.intrinsics.get(&~"llvm.exp.f32"); + let expf = *ccx.intrinsics.get(&~"llvm.exp.f32"); Store(bcx, Call(bcx, expf, ~[x]), fcx.llretptr); } ~"expf64" => { let x = get_param(decl, first_real_arg); - let expf = ccx.intrinsics.get(&~"llvm.exp.f64"); + let expf = *ccx.intrinsics.get(&~"llvm.exp.f64"); Store(bcx, Call(bcx, expf, ~[x]), fcx.llretptr); } ~"exp2f32" => { let x = get_param(decl, first_real_arg); - let exp2f = ccx.intrinsics.get(&~"llvm.exp2.f32"); + let exp2f = *ccx.intrinsics.get(&~"llvm.exp2.f32"); Store(bcx, Call(bcx, exp2f, ~[x]), fcx.llretptr); } ~"exp2f64" => { let x = get_param(decl, first_real_arg); - let exp2f = ccx.intrinsics.get(&~"llvm.exp2.f64"); + let exp2f = *ccx.intrinsics.get(&~"llvm.exp2.f64"); Store(bcx, Call(bcx, exp2f, ~[x]), fcx.llretptr); } ~"logf32" => { let x = get_param(decl, first_real_arg); - let logf = ccx.intrinsics.get(&~"llvm.log.f32"); + let logf = *ccx.intrinsics.get(&~"llvm.log.f32"); Store(bcx, Call(bcx, logf, ~[x]), fcx.llretptr); } ~"logf64" => { let x = get_param(decl, first_real_arg); - let logf = ccx.intrinsics.get(&~"llvm.log.f64"); + let logf = *ccx.intrinsics.get(&~"llvm.log.f64"); Store(bcx, Call(bcx, logf, ~[x]), fcx.llretptr); } ~"log10f32" => { let x = get_param(decl, first_real_arg); - let log10f = ccx.intrinsics.get(&~"llvm.log10.f32"); + let log10f = *ccx.intrinsics.get(&~"llvm.log10.f32"); Store(bcx, Call(bcx, log10f, ~[x]), fcx.llretptr); } ~"log10f64" => { let x = get_param(decl, first_real_arg); - let log10f = ccx.intrinsics.get(&~"llvm.log10.f64"); + let log10f = *ccx.intrinsics.get(&~"llvm.log10.f64"); Store(bcx, Call(bcx, log10f, ~[x]), fcx.llretptr); } ~"log2f32" => { let x = get_param(decl, first_real_arg); - let log2f = ccx.intrinsics.get(&~"llvm.log2.f32"); + let log2f = *ccx.intrinsics.get(&~"llvm.log2.f32"); Store(bcx, Call(bcx, log2f, ~[x]), fcx.llretptr); } ~"log2f64" => { let x = get_param(decl, first_real_arg); - let log2f = ccx.intrinsics.get(&~"llvm.log2.f64"); + let log2f = *ccx.intrinsics.get(&~"llvm.log2.f64"); Store(bcx, Call(bcx, log2f, ~[x]), fcx.llretptr); } ~"fmaf32" => { let a = get_param(decl, first_real_arg); let b = get_param(decl, first_real_arg + 1u); let c = get_param(decl, first_real_arg + 2u); - let fmaf = ccx.intrinsics.get(&~"llvm.fma.f32"); + let fmaf = *ccx.intrinsics.get(&~"llvm.fma.f32"); Store(bcx, Call(bcx, fmaf, ~[a, b, c]), fcx.llretptr); } ~"fmaf64" => { let a = get_param(decl, first_real_arg); let b = get_param(decl, first_real_arg + 1u); let c = get_param(decl, first_real_arg + 2u); - let fmaf = ccx.intrinsics.get(&~"llvm.fma.f64"); + let fmaf = *ccx.intrinsics.get(&~"llvm.fma.f64"); Store(bcx, Call(bcx, fmaf, ~[a, b, c]), fcx.llretptr); } ~"fabsf32" => { let x = get_param(decl, first_real_arg); - let fabsf = ccx.intrinsics.get(&~"llvm.fabs.f32"); + let fabsf = *ccx.intrinsics.get(&~"llvm.fabs.f32"); Store(bcx, Call(bcx, fabsf, ~[x]), fcx.llretptr); } ~"fabsf64" => { let x = get_param(decl, first_real_arg); - let fabsf = ccx.intrinsics.get(&~"llvm.fabs.f64"); + let fabsf = *ccx.intrinsics.get(&~"llvm.fabs.f64"); Store(bcx, Call(bcx, fabsf, ~[x]), fcx.llretptr); } ~"floorf32" => { let x = get_param(decl, first_real_arg); - let floorf = ccx.intrinsics.get(&~"llvm.floor.f32"); + let floorf = *ccx.intrinsics.get(&~"llvm.floor.f32"); Store(bcx, Call(bcx, floorf, ~[x]), fcx.llretptr); } ~"floorf64" => { let x = get_param(decl, first_real_arg); - let floorf = ccx.intrinsics.get(&~"llvm.floor.f64"); + let floorf = *ccx.intrinsics.get(&~"llvm.floor.f64"); Store(bcx, Call(bcx, floorf, ~[x]), fcx.llretptr); } ~"ceilf32" => { let x = get_param(decl, first_real_arg); - let ceilf = ccx.intrinsics.get(&~"llvm.ceil.f32"); + let ceilf = *ccx.intrinsics.get(&~"llvm.ceil.f32"); Store(bcx, Call(bcx, ceilf, ~[x]), fcx.llretptr); } ~"ceilf64" => { let x = get_param(decl, first_real_arg); - let ceilf = ccx.intrinsics.get(&~"llvm.ceil.f64"); + let ceilf = *ccx.intrinsics.get(&~"llvm.ceil.f64"); Store(bcx, Call(bcx, ceilf, ~[x]), fcx.llretptr); } ~"truncf32" => { let x = get_param(decl, first_real_arg); - let truncf = ccx.intrinsics.get(&~"llvm.trunc.f32"); + let truncf = *ccx.intrinsics.get(&~"llvm.trunc.f32"); Store(bcx, Call(bcx, truncf, ~[x]), fcx.llretptr); } ~"truncf64" => { let x = get_param(decl, first_real_arg); - let truncf = ccx.intrinsics.get(&~"llvm.trunc.f64"); + let truncf = *ccx.intrinsics.get(&~"llvm.trunc.f64"); Store(bcx, Call(bcx, truncf, ~[x]), fcx.llretptr); } ~"ctpop8" => { let x = get_param(decl, first_real_arg); - let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i8"); + let ctpop = *ccx.intrinsics.get(&~"llvm.ctpop.i8"); Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr) } ~"ctpop16" => { let x = get_param(decl, first_real_arg); - let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i16"); + let ctpop = *ccx.intrinsics.get(&~"llvm.ctpop.i16"); Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr) } ~"ctpop32" => { let x = get_param(decl, first_real_arg); - let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i32"); + let ctpop = *ccx.intrinsics.get(&~"llvm.ctpop.i32"); Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr) } ~"ctpop64" => { let x = get_param(decl, first_real_arg); - let ctpop = ccx.intrinsics.get(&~"llvm.ctpop.i64"); + let ctpop = *ccx.intrinsics.get(&~"llvm.ctpop.i64"); Store(bcx, Call(bcx, ctpop, ~[x]), fcx.llretptr) } ~"ctlz8" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i8"); + let ctlz = *ccx.intrinsics.get(&~"llvm.ctlz.i8"); Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr) } ~"ctlz16" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i16"); + let ctlz = *ccx.intrinsics.get(&~"llvm.ctlz.i16"); Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr) } ~"ctlz32" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i32"); + let ctlz = *ccx.intrinsics.get(&~"llvm.ctlz.i32"); Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr) } ~"ctlz64" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let ctlz = ccx.intrinsics.get(&~"llvm.ctlz.i64"); + let ctlz = *ccx.intrinsics.get(&~"llvm.ctlz.i64"); Store(bcx, Call(bcx, ctlz, ~[x, y]), fcx.llretptr) } ~"cttz8" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let cttz = ccx.intrinsics.get(&~"llvm.cttz.i8"); + let cttz = *ccx.intrinsics.get(&~"llvm.cttz.i8"); Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr) } ~"cttz16" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let cttz = ccx.intrinsics.get(&~"llvm.cttz.i16"); + let cttz = *ccx.intrinsics.get(&~"llvm.cttz.i16"); Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr) } ~"cttz32" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let cttz = ccx.intrinsics.get(&~"llvm.cttz.i32"); + let cttz = *ccx.intrinsics.get(&~"llvm.cttz.i32"); Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr) } ~"cttz64" => { let x = get_param(decl, first_real_arg); let y = C_i1(false); - let cttz = ccx.intrinsics.get(&~"llvm.cttz.i64"); + let cttz = *ccx.intrinsics.get(&~"llvm.cttz.i64"); Store(bcx, Call(bcx, cttz, ~[x, y]), fcx.llretptr) } ~"bswap16" => { let x = get_param(decl, first_real_arg); - let cttz = ccx.intrinsics.get(&~"llvm.bswap.i16"); + let cttz = *ccx.intrinsics.get(&~"llvm.bswap.i16"); Store(bcx, Call(bcx, cttz, ~[x]), fcx.llretptr) } ~"bswap32" => { let x = get_param(decl, first_real_arg); - let cttz = ccx.intrinsics.get(&~"llvm.bswap.i32"); + let cttz = *ccx.intrinsics.get(&~"llvm.bswap.i32"); Store(bcx, Call(bcx, cttz, ~[x]), fcx.llretptr) } ~"bswap64" => { let x = get_param(decl, first_real_arg); - let cttz = ccx.intrinsics.get(&~"llvm.bswap.i64"); + let cttz = *ccx.intrinsics.get(&~"llvm.bswap.i64"); Store(bcx, Call(bcx, cttz, ~[x]), fcx.llretptr) } _ => { diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index d2bf034165dd9..506b1e572482c 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -35,7 +35,6 @@ use util::common::indenter; use util::ppaux::{ty_to_str, tys_to_str}; use core::libc::c_uint; -use std::oldmap::HashMap; use syntax::ast_map::{path, path_mod, path_name, node_id_to_str}; use syntax::ast_util; use syntax::print::pprust::expr_to_str; @@ -778,7 +777,7 @@ pub fn get_vtable(ccx: @CrateContext, // XXX: Bad copy. let hash_id = vtable_id(ccx, copy origin); match ccx.vtables.find(&hash_id) { - Some(val) => val, + Some(&val) => val, None => match origin { typeck::vtable_static(id, substs, sub_vtables) => { make_impl_vtable(ccx, id, substs, sub_vtables) diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index 30a42210a13b9..60ca67573b925 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -75,7 +75,7 @@ pub fn monomorphic_fn(ccx: @CrateContext, substs.map(|s| ty_to_str(ccx.tcx, *s)), hash_id); match ccx.monomorphized.find(&hash_id) { - Some(val) => { + Some(&val) => { debug!("leaving monomorphic fn %s", ty::item_path_str(ccx.tcx, fn_id)); return (val, must_cast); @@ -140,7 +140,10 @@ pub fn monomorphic_fn(ccx: @CrateContext, ccx.stats.n_monos += 1; - let depth = option::get_or_default(ccx.monomorphizing.find(&fn_id), 0u); + let depth = match ccx.monomorphizing.find(&fn_id) { + Some(&d) => d, + None => 0u, + }; // Random cut-off -- code that needs to instantiate the same function // recursively more than thirty times can probably safely be assumed to be // causing an infinite expansion. diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 17abebad600dc..6220657d8de1e 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -22,7 +22,7 @@ use middle::ty; use middle::typeck; use core::prelude::*; -use std::oldmap::HashMap; +use core::hashmap::linear::LinearMap; use syntax::ast; use syntax::ast::*; use syntax::ast_util::def_id_of_def; @@ -31,7 +31,7 @@ use syntax::codemap; use syntax::print::pprust::expr_to_str; use syntax::{visit, ast_util, ast_map}; -pub type map = HashMap; +pub type map = @mut LinearMap; struct ctx { exp_map2: resolve::ExportMap2, @@ -42,7 +42,7 @@ struct ctx { pub fn find_reachable(crate_mod: &_mod, exp_map2: resolve::ExportMap2, tcx: ty::ctxt, method_map: typeck::method_map) -> map { - let rmap = HashMap(); + let rmap = @mut LinearMap::new(); let cx = ctx { exp_map2: exp_map2, tcx: tcx, diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index dcfa897ab606a..062adc5cbac30 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -27,7 +27,6 @@ use util::ppaux::ty_to_str; use core::option::None; use core::vec; -use std::oldmap::HashMap; use syntax::ast::def_id; use syntax::ast; diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs index 72e4fa2f4ebed..22c87f09e82ed 100644 --- a/src/librustc/middle/trans/shape.rs +++ b/src/librustc/middle/trans/shape.rs @@ -27,7 +27,6 @@ use core::dvec::DVec; use core::option::is_some; use core::str; use core::vec; -use std::oldmap::HashMap; use syntax::ast; use syntax::codemap::dummy_sp; use syntax::codemap::span; diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index fdb5e94559f9c..2e04c4d5dddcf 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -21,7 +21,6 @@ use util::ppaux; use core::option::None; use core::vec; -use std::oldmap::HashMap; use syntax::ast; pub fn type_of_explicit_arg(ccx: @CrateContext, arg: ty::arg) -> TypeRef { diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index 7b7a6eee92e7c..17416b19f0e49 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -41,7 +41,6 @@ use core::uint; use core::vec; use std::list::{List, Cons, Nil}; use std::list; -use std::oldmap::HashMap; use syntax::ast; use syntax::ast::*; use syntax::ast_map; @@ -61,7 +60,7 @@ pub struct Context { pub fn type_uses_for(ccx: @CrateContext, fn_id: def_id, n_tps: uint) -> ~[type_uses] { match ccx.type_use_cache.find(&fn_id) { - Some(uses) => return uses, + Some(uses) => return copy *uses, None => () } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 0b0715dd9ca35..f874535908237 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -32,6 +32,7 @@ use core::cast; use core::cmp; use core::dvec::DVec; use core::dvec; +use core::hashmap::linear::LinearMap; use core::ops; use core::option; use core::ptr::to_unsafe_ptr; @@ -293,7 +294,7 @@ struct ctxt_ { destructors: HashMap, // Maps a trait onto a mapping from self-ty to impl - trait_impls: HashMap> + trait_impls: @mut LinearMap> } enum tbox_flag { @@ -842,7 +843,7 @@ pub fn mk_ctxt(s: session::Session, supertraits: HashMap(), destructor_for_type: HashMap(), destructors: HashMap(), - trait_impls: HashMap() + trait_impls: @mut LinearMap::new() } } @@ -4370,8 +4371,8 @@ pub fn count_traits_and_supertraits(tcx: ctxt, // Given a trait and a type, returns the impl of that type pub fn get_impl_id(tcx: ctxt, trait_id: def_id, self_ty: t) -> def_id { match tcx.trait_impls.find(&trait_id) { - Some(ty_to_impl) => match ty_to_impl.find(&self_ty) { - Some(the_impl) => the_impl.did, + Some(&ty_to_impl) => match ty_to_impl.find(&self_ty) { + Some(&the_impl) => the_impl.did, None => // try autoderef! match deref(tcx, self_ty, false) { Some(some_ty) => get_impl_id(tcx, trait_id, some_ty.ty), diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 39b2a2efdd817..c1fe621c04541 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -19,8 +19,8 @@ use middle::typeck::check::{instantiate_path, lookup_def}; use middle::typeck::check::{structure_of, valid_range_bounds}; use middle::typeck::require_same_types; +use core::hashmap::linear::LinearMap; use core::vec; -use std::oldmap::HashMap; use syntax::ast; use syntax::ast_util::walk_pat; use syntax::ast_util; @@ -204,7 +204,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, /// `class_fields` describes the type of each field of the struct. /// `class_id` is the ID of the struct. /// `substitutions` are the type substitutions applied to this struct type -/// (e.g. K,V in HashMap). +/// (e.g. K,V in LinearMap). /// `etc` is true if the pattern said '...' and false otherwise. pub fn check_struct_pat_fields(pcx: pat_ctxt, span: span, @@ -217,16 +217,16 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt, let tcx = pcx.fcx.ccx.tcx; // Index the class fields. - let field_map = HashMap(); + let field_map = @mut LinearMap::new(); for class_fields.eachi |i, class_field| { field_map.insert(class_field.ident, i); } // Typecheck each field. - let found_fields = HashMap(); + let found_fields = @mut LinearMap::new(); for fields.each |field| { match field_map.find(&field.ident) { - Some(index) => { + Some(&index) => { let class_field = class_fields[index]; let field_type = ty::lookup_field_type(tcx, class_id, @@ -396,7 +396,7 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } } - let canon_id = pcx.map.get(&ast_util::path_to_ident(name)); + let canon_id = *pcx.map.get(&ast_util::path_to_ident(name)); if canon_id != pat.id { let ct = fcx.local_ty(pat.span, canon_id); demand::eqtype(fcx, pat.span, ct, typ); diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 63d09d88f52a5..2606f1dee0173 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -98,10 +98,10 @@ use util::common::indenter; use util::ppaux::expr_repr; use core::dvec::DVec; +use core::hashmap::linear::LinearMap; use core::result; use core::uint; use core::vec; -use std::oldmap::HashMap; use syntax::ast::{def_id, sty_by_ref, sty_value, sty_region, sty_box}; use syntax::ast::{sty_uniq, sty_static, node_id, by_copy, by_ref}; use syntax::ast::{m_const, m_mutbl, m_imm}; @@ -131,7 +131,7 @@ pub fn lookup( callee_id: callee_id, m_name: m_name, supplied_tps: supplied_tps, - impl_dups: HashMap(), + impl_dups: @mut LinearMap::new(), inherent_candidates: DVec(), extension_candidates: DVec(), deref_args: deref_args, @@ -149,7 +149,7 @@ pub struct LookupContext { callee_id: node_id, m_name: ast::ident, supplied_tps: &[ty::t], - impl_dups: HashMap, + impl_dups: @mut LinearMap, inherent_candidates: DVec, extension_candidates: DVec, deref_args: check::DerefArgs, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index f724a442902f2..1b71976404f02 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -107,6 +107,7 @@ use util::ppaux::{bound_region_to_str, expr_repr, pat_repr}; use util::ppaux; use core::either; +use core::hashmap::linear::LinearMap; use core::option; use core::ptr; use core::result::{Result, Ok, Err}; @@ -511,12 +512,13 @@ pub fn check_method(ccx: @mut CrateCtxt, pub fn check_no_duplicate_fields(tcx: ty::ctxt, fields: ~[(ast::ident, span)]) { - let field_names = HashMap(); + //XXX: Local variable on the @ box + let field_names = @mut LinearMap::new(); for fields.each |p| { let (id, sp) = *p; match field_names.find(&id) { - Some(orig_sp) => { + Some(&orig_sp) => { tcx.sess.span_err(sp, fmt!("Duplicate field \ name %s in record type declaration", *tcx.sess.str_of(id))); @@ -1795,7 +1797,8 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, debug!("%? %?", ast_fields.len(), field_types.len()); - let class_field_map = HashMap(); + //XXX: Local variable on the @ box + let class_field_map = @mut LinearMap::new(); let mut fields_found = 0; for field_types.each |field| { // XXX: Check visibility here. @@ -1811,13 +1814,13 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, fmt!("structure has no field named `%s`", *tcx.sess.str_of(field.node.ident))); } - Some((_, true)) => { + Some(&(_, true)) => { tcx.sess.span_err( field.span, fmt!("field `%s` specified more than once", *tcx.sess.str_of(field.node.ident))); } - Some((field_id, false)) => { + Some(&(field_id, false)) => { let expected_field_type = ty::lookup_field_type( tcx, class_id, field_id, substitutions); @@ -1840,7 +1843,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, let mut missing_fields = ~[]; for field_types.each |class_field| { let name = class_field.ident; - let (_, seen) = class_field_map.get(&name); + let (_, seen) = *class_field_map.get(&name); if !seen { missing_fields.push( ~"`" + *tcx.sess.str_of(name) + ~"`"); diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index b2d399ac8da49..3dc8177a64dfd 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -24,11 +24,10 @@ use util::common::indenter; use util::ppaux::tys_to_str; use util::ppaux; -use core::result::{Result, Ok, Err}; -use core::result; +use core::hashmap::linear::LinearMap; use core::uint; use core::vec; -use std::oldmap::HashMap; +use core::result::{Result, Ok, Err}; use syntax::ast; use syntax::ast_util; use syntax::codemap::span; @@ -253,13 +252,13 @@ pub fn lookup_vtable(vcx: &VtableContext, _ => { let mut found = ~[]; - let mut impls_seen = HashMap(); + let impls_seen = @mut LinearMap::new(); match vcx.ccx.coherence_info.extension_methods.find(&trait_id) { None => { // Nothing found. Continue. } - Some(implementations) => { + Some(&implementations) => { // implementations is the list of all impls in scope for // trait_ty. (Usually, there's just one.) for uint::range(0, implementations.len()) |i| { diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index e5aca315dd1c9..00f757412f6af 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -28,7 +28,6 @@ use util::ppaux; use core::result::{Result, Ok, Err}; use core::vec; -use std::oldmap::HashMap; use syntax::ast; use syntax::codemap::span; use syntax::print::pprust::pat_to_str; diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index f8fcef7580b1d..e551cbe062a63 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -57,13 +57,13 @@ use syntax::visit::{visit_mod}; use util::ppaux::ty_to_str; use core::dvec::DVec; -use core::result::Ok; +use core::hashmap::linear::LinearMap; use core::hashmap::linear::LinearSet; +use core::result::Ok; use core::uint::range; use core::uint; use core::vec::{len, push}; use core::vec; -use std::oldmap::HashMap; pub struct UniversalQuantificationResult { monotype: t, @@ -156,18 +156,18 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo { pub struct CoherenceInfo { // Contains implementations of methods that are inherent to a type. // Methods in these implementations don't need to be exported. - inherent_methods: HashMap>, + inherent_methods: @mut LinearMap>, // Contains implementations of methods associated with a trait. For these, // the associated trait must be imported at the call site. - extension_methods: HashMap>, + extension_methods: @mut LinearMap>, } pub fn CoherenceInfo() -> CoherenceInfo { CoherenceInfo { - inherent_methods: HashMap(), - extension_methods: HashMap(), + inherent_methods: @mut LinearMap::new(), + extension_methods: @mut LinearMap::new(), } } @@ -176,8 +176,8 @@ pub fn CoherenceChecker(crate_context: @mut CrateCtxt) -> CoherenceChecker { crate_context: crate_context, inference_context: new_infer_ctxt(crate_context.tcx), - base_type_def_ids: HashMap(), - privileged_implementations: HashMap() + base_type_def_ids: @mut LinearMap::new(), + privileged_implementations: @mut LinearMap::new() } } @@ -188,12 +188,12 @@ pub struct CoherenceChecker { // A mapping from implementations to the corresponding base type // definition ID. - base_type_def_ids: HashMap, + base_type_def_ids: @mut LinearMap, // A set of implementations in privileged scopes; i.e. those // implementations that are defined in the same scope as their base types. - privileged_implementations: HashMap, + privileged_implementations: @mut LinearMap, } pub impl CoherenceChecker { @@ -394,7 +394,7 @@ pub impl CoherenceChecker { self.crate_context.coherence_info.inherent_methods .insert(base_def_id, implementation_list); } - Some(existing_implementation_list) => { + Some(&existing_implementation_list) => { implementation_list = existing_implementation_list; } } @@ -411,7 +411,7 @@ pub impl CoherenceChecker { self.crate_context.coherence_info.extension_methods .insert(trait_id, implementation_list); } - Some(existing_implementation_list) => { + Some(&existing_implementation_list) => { implementation_list = existing_implementation_list; } } @@ -471,11 +471,11 @@ pub impl CoherenceChecker { ty_to_str(self.crate_context.tcx, self_t)); match self.crate_context.tcx.trait_impls.find(&trait_t) { None => { - let m = HashMap(); + let m = @mut LinearMap::new(); m.insert(self_t, the_impl); self.crate_context.tcx.trait_impls.insert(trait_t, m); } - Some(m) => { + Some(&m) => { m.insert(self_t, the_impl); } } @@ -502,7 +502,7 @@ pub impl CoherenceChecker { f: &fn(x: &ty::method) -> bool) { // Make a list of all the names of the provided methods. // XXX: This is horrible. - let provided_method_idents = HashMap(); + let mut provided_method_idents = LinearMap::new(); let tcx = self.crate_context.tcx; for ty::provided_trait_methods(tcx, trait_did).each |ident| { provided_method_idents.insert(*ident, ()); @@ -640,7 +640,7 @@ pub impl CoherenceChecker { None => { // Nothing to do. } - Some(base_type_def_id) => { + Some(&base_type_def_id) => { // Check to see whether the implementation is // in the same crate as its base type. @@ -830,7 +830,7 @@ pub impl CoherenceChecker { // External crate handling - fn add_impls_for_module(&self, impls_seen: HashMap, + fn add_impls_for_module(&self, impls_seen: @mut LinearMap, crate_store: @mut CStore, module_def_id: def_id) { let implementations = get_impls_for_mod(crate_store, @@ -952,7 +952,8 @@ pub impl CoherenceChecker { // Adds implementations and traits from external crates to the coherence // info. fn add_external_crates(&self) { - let impls_seen = HashMap(); + //XXX: Local variable on the @ box + let impls_seen = @mut LinearMap::new(); let crate_store = self.crate_context.tcx.sess.cstore; do iter_crate_data(crate_store) |crate_number, _crate_metadata| { diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index aff2d599a0ef1..cae9cb192d347 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -276,7 +276,6 @@ use core::result::{Result, Ok, Err, map_vec, map_vec2, iter_vec2}; use core::result; use core::vec; use std::list::Nil; -use std::oldmap::HashMap; use std::smallintmap::SmallIntMap; use syntax::ast::{ret_style, purity}; use syntax::ast::{m_const, m_imm, m_mutbl}; diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 1ad89fe6f1e5e..36f561fe1ea22 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -552,10 +552,11 @@ use util::ppaux::note_and_explain_region; use core::cell::{Cell, empty_cell}; use core::cmp; use core::dvec::DVec; -use core::result::{Err, Ok, Result}; +use core::hashmap::linear::LinearMap; use core::to_bytes; use core::uint; use core::vec; +use core::result::{Err, Ok, Result}; use std::list::{List, Nil, Cons}; use std::oldmap::HashMap; use syntax::codemap::span; @@ -627,12 +628,12 @@ enum UndoLogEntry { AddCombination(CombineMap, TwoRegions) } -type CombineMap = HashMap; +type CombineMap = @mut LinearMap; pub struct RegionVarBindings { tcx: ty::ctxt, var_spans: DVec, - constraints: HashMap, + constraints: @mut LinearMap, lubs: CombineMap, glbs: CombineMap, skolemization_count: uint, @@ -659,22 +660,15 @@ pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings { tcx: tcx, var_spans: DVec(), values: empty_cell(), - constraints: HashMap(), - lubs: CombineMap(), - glbs: CombineMap(), + constraints: @mut LinearMap::new(), + lubs: @mut LinearMap::new(), + glbs: @mut LinearMap::new(), skolemization_count: 0, bound_count: 0, undo_log: ~[] } } -// Note: takes two regions but doesn't care which is `a` and which is -// `b`! Not obvious that this is the most efficient way to go about -// it. -fn CombineMap() -> CombineMap { - return HashMap(); -} - pub impl RegionVarBindings { fn in_snapshot(&mut self) -> bool { self.undo_log.len() > 0 @@ -920,7 +914,7 @@ pub impl RegionVarBindings { -> cres { let vars = TwoRegions { a: a, b: b }; match combines.find(&vars) { - Some(c) => Ok(re_infer(ReVar(c))), + Some(&c) => Ok(re_infer(ReVar(c))), None => { let c = self.new_region_var(span); combines.insert(vars, c); @@ -1211,10 +1205,10 @@ struct SpannedRegion { span: span, } -type TwoRegionsMap = HashMap; +type TwoRegionsMap = @mut LinearMap; fn TwoRegionsMap() -> TwoRegionsMap { - return HashMap(); + return @mut LinearMap::new(); } pub impl RegionVarBindings { @@ -1244,7 +1238,7 @@ pub impl RegionVarBindings { // It would be nice to write this using map(): let mut edges = vec::with_capacity(num_edges); - for self.constraints.each |constraint, span| { + for self.constraints.each |&(constraint, span)| { edges.push(GraphEdge { next_edge: [uint::max_value, uint::max_value], constraint: *constraint, @@ -1619,7 +1613,7 @@ pub impl RegionVarBindings { orig_node_idx: RegionVid, dir: Direction) -> ~[SpannedRegion] { - let set = HashMap(); + let set = @mut LinearMap::new(); let mut stack = ~[orig_node_idx]; set.insert(*orig_node_idx, ()); let mut result = ~[]; diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index de3df62d62caf..b2f6fa9aeff56 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -51,7 +51,6 @@ independently: use core::prelude::*; use metadata::csearch; -use middle::pat_util::{pat_id_map, PatIdMap}; use middle::resolve; use middle::ty::{arg, field, node_type_table, mk_nil, ty_param_bounds_and_ty}; use middle::ty::{ty_param_substs_and_ty, vstore_uniq}; diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 8dbc0f12a88cf..d6bc4858453c0 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -189,8 +189,8 @@ Available lint options: padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(fmt!(" %s %7.7s %s\n", padded(max_key, ~"----"), ~"-------", ~"-------")); - for lint_dict.each |&k, &v| { - let k = str::replace(*k, ~"_", ~"-"); + for lint_dict.each |&(k, v)| { + let k = str::replace(**k, ~"_", ~"-"); io::println(fmt!(" %s %7.7s %s", padded(max_key, k), match v.default { diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 8729ca5f6e170..6865aeee5063f 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -16,10 +16,10 @@ use syntax::visit; use syntax::print; use syntax; +use core::hashmap::linear::LinearMap; use core::option; use core::str; use core::vec; -use std::oldmap::HashMap; pub fn indent(op: fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` @@ -49,7 +49,7 @@ pub fn indenter() -> _indenter { _indenter(()) } -pub type flag = HashMap<~str, ()>; +pub type flag = @mut LinearMap<~str, ()>; pub fn field_expr(f: ast::field) -> @ast::expr { return f.node.expr; } @@ -110,7 +110,7 @@ pub fn pluralize(n: uint, +s: ~str) -> ~str { } // A set of node IDs (used to keep track of which node IDs are for statements) -pub type stmt_set = HashMap; +pub type stmt_set = @mut LinearMap; // // Local Variables: diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 995fdba35cbd7..cec06d15d4e52 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -37,7 +37,6 @@ use syntax::ast_map; use core::str; use core::vec; -use std::oldmap::HashMap; pub fn note_and_explain_region(cx: ctxt, prefix: ~str, diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index c25205c58d196..03ccafbf1544b 100644 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ b/src/test/compile-fail/regions-glb-free-free.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// xfail-test : Error accasionally happens on line #33 + mod argparse { extern mod std;