]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_incremental/persist/directory.rs
New upstream version 1.13.0+dfsg1
[rustc.git] / src / librustc_incremental / persist / directory.rs
index 89a79d1a487e0f8106d99270c5bec649f9bc6c61..619e237ee34a3fc6f49d30503e5c3f127fb78c3c 100644 (file)
 
 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,
@@ -43,7 +41,7 @@ pub struct DefIdDirectory {
 
 #[derive(Debug, RustcEncodable, RustcDecodable)]
 pub struct CrateInfo {
-    krate: ast::CrateNum,
+    krate: CrateNum,
     name: String,
     disambiguator: String,
 }
@@ -53,7 +51,7 @@ impl DefIdDirectory {
         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()
@@ -72,8 +70,8 @@ impl DefIdDirectory {
 
     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.
@@ -81,7 +79,7 @@ impl DefIdDirectory {
         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;
@@ -101,7 +99,7 @@ impl DefIdDirectory {
                                 } 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
@@ -180,7 +178,6 @@ impl<'a,'tcx> DefIdDirectoryBuilder<'a,'tcx> {
         &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()
     }