]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/typeck/mod.rs
use TotalEq for HashMap
[rust.git] / src / librustc / middle / typeck / mod.rs
index 66314e141545dc8c0a2c8e3734fe45f29a1ede66..67db5b7f39620f12c220e1b3478d384bb4a70cca 100644 (file)
@@ -68,7 +68,7 @@
 use util::common::time;
 use util::ppaux::Repr;
 use util::ppaux;
-use util::nodemap::{DefIdMap, FnvHashMap, NodeMap};
+use util::nodemap::{DefIdMap, FnvHashMap};
 
 use std::cell::RefCell;
 use std::rc::Rc;
@@ -148,7 +148,7 @@ pub struct MethodCallee {
     substs: ty::substs
 }
 
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash, Show)]
 pub struct MethodCall {
     expr_id: ast::NodeId,
     autoderef: u32
@@ -216,7 +216,7 @@ fn repr(&self, tcx: &ty::ctxt) -> ~str {
     }
 }
 
-pub type vtable_map = @RefCell<NodeMap<vtable_res>>;
+pub type vtable_map = @RefCell<FnvHashMap<MethodCall, vtable_res>>;
 
 
 // Information about the vtable resolutions for a trait impl.
@@ -252,8 +252,7 @@ pub struct CrateCtxt<'a> {
 pub fn write_ty_to_tcx(tcx: &ty::ctxt, node_id: ast::NodeId, ty: ty::t) {
     debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_str(tcx, ty));
     assert!(!ty::type_needs_infer(ty));
-    let mut node_types = tcx.node_types.borrow_mut();
-    node_types.get().insert(node_id as uint, ty);
+    tcx.node_types.borrow_mut().insert(node_id as uint, ty);
 }
 pub fn write_substs_to_tcx(tcx: &ty::ctxt,
                            node_id: ast::NodeId,
@@ -263,8 +262,7 @@ pub fn write_substs_to_tcx(tcx: &ty::ctxt,
                substs.map(|t| ppaux::ty_to_str(tcx, *t)));
         assert!(substs.iter().all(|t| !ty::type_needs_infer(*t)));
 
-        let mut node_type_substs = tcx.node_type_substs.borrow_mut();
-        node_type_substs.get().insert(node_id, substs);
+        tcx.node_type_substs.borrow_mut().insert(node_id, substs);
     }
 }
 pub fn write_tpt_to_tcx(tcx: &ty::ctxt,
@@ -277,8 +275,7 @@ pub fn write_tpt_to_tcx(tcx: &ty::ctxt,
 }
 
 pub fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> ast::Def {
-    let def_map = tcx.def_map.borrow();
-    match def_map.get().find(&id) {
+    match tcx.def_map.borrow().find(&id) {
         Some(&x) => x,
         _ => {
             tcx.sess.span_fatal(sp, "internal error looking up a definition")
@@ -464,7 +461,7 @@ pub fn check_crate(tcx: &ty::ctxt,
     let ccx = CrateCtxt {
         trait_map: trait_map,
         method_map: @RefCell::new(FnvHashMap::new()),
-        vtable_map: @RefCell::new(NodeMap::new()),
+        vtable_map: @RefCell::new(FnvHashMap::new()),
         tcx: tcx
     };