]> git.lizzy.rs Git - rust.git/commitdiff
hash def-path's better
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 28 Jul 2016 19:39:02 +0000 (15:39 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 28 Jul 2016 19:39:02 +0000 (15:39 -0400)
actually we shouldn't even hash nested items at all, but that is
addressed in a followup PR

src/librustc_incremental/calculate_svh.rs

index 70704f5dec0d29d80a213288e1ef7cfddd68ed0c..d433bdea6ecaa8f94184e1545615f79dc780143d 100644 (file)
@@ -119,6 +119,7 @@ mod svh_visitor {
     use rustc::ty::TyCtxt;
     use rustc::hir;
     use rustc::hir::*;
+    use rustc::hir::map::DefPath;
     use rustc::hir::intravisit as visit;
     use rustc::hir::intravisit::{Visitor, FnKind};
 
@@ -135,6 +136,15 @@ pub fn new(st: &'a mut SipHasher,
                    -> Self {
             StrictVersionHashVisitor { st: st, tcx: tcx }
         }
+
+        fn hash_def_path(&mut self, path: &DefPath) {
+            self.tcx.crate_name(path.krate).hash(self.st);
+            self.tcx.crate_disambiguator(path.krate).hash(self.st);
+            for data in &path.data {
+                data.data.as_interned_str().hash(self.st);
+                data.disambiguator.hash(self.st);
+            }
+        }
     }
 
     // To off-load the bulk of the hash-computation on #[derive(Hash)],
@@ -289,9 +299,9 @@ fn saw_stmt(node: &Stmt_) -> SawStmtComponent {
 
     impl<'a, 'tcx> Visitor<'a> for StrictVersionHashVisitor<'a, 'tcx> {
         fn visit_nested_item(&mut self, item: ItemId) {
-            debug!("visit_nested_item: {:?} st={:?}", item, self.st);
-            let def_path = self.tcx.map.def_path_from_id(item.id);
-            def_path.hash(self.st);
+            let def_path = self.tcx.map.def_path_from_id(item.id).unwrap();
+            debug!("visit_nested_item: def_path={:?} st={:?}", def_path, self.st);
+            self.hash_def_path(&def_path);
         }
 
         fn visit_variant_data(&mut self, s: &'a VariantData, name: Name,