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};
-> 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)],
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,