use rustc::dep_graph::DepNode;
use rustc::hir::map::DefPath;
-use rustc::hir::def_id::DefId;
-use rustc::middle::cstore::LOCAL_CRATE;
+use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::TyCtxt;
use rustc::util::nodemap::DefIdMap;
use std::fmt::{self, Debug};
use std::iter::once;
-use syntax::ast;
/// Index into the DefIdDirectory
#[derive(Copy, Clone, Debug, PartialOrd, Ord, Hash, PartialEq, Eq,
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct CrateInfo {
- krate: ast::CrateNum,
+ krate: CrateNum,
name: String,
disambiguator: String,
}
DefIdDirectory { paths: vec![], krates: krates }
}
- fn max_current_crate(&self, tcx: TyCtxt) -> ast::CrateNum {
+ fn max_current_crate(&self, tcx: TyCtxt) -> CrateNum {
tcx.sess.cstore.crates()
.into_iter()
.max()
pub fn krate_still_valid(&self,
tcx: TyCtxt,
- max_current_crate: ast::CrateNum,
- krate: ast::CrateNum) -> bool {
+ max_current_crate: CrateNum,
+ krate: CrateNum) -> bool {
// Check that the crate-number still matches. For now, if it
// doesn't, just return None. We could do better, such as
// finding the new number.
if krate > max_current_crate {
false
} else {
- let old_info = &self.krates[krate as usize];
+ let old_info = &self.krates[krate.as_usize()];
assert_eq!(old_info.krate, krate);
let old_name: &str = &old_info.name;
let old_disambiguator: &str = &old_info.disambiguator;
} else {
debug!("crate {} changed from {:?} to {:?}/{:?}",
path.krate,
- self.krates[path.krate as usize],
+ self.krates[path.krate.as_usize()],
tcx.crate_name(path.krate),
tcx.crate_disambiguator(path.krate));
None
&self.directory.paths[id.index as usize]
}
-
pub fn map(&mut self, node: &DepNode<DefId>) -> DepNode<DefPathIndex> {
node.map_def(|&def_id| Some(self.add(def_id))).unwrap()
}