]> git.lizzy.rs Git - rust.git/commitdiff
Revert a few changes
authorAlex Crichton <alex@alexcrichton.com>
Wed, 21 Jun 2017 18:34:33 +0000 (11:34 -0700)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Mon, 26 Jun 2017 02:08:12 +0000 (02:08 +0000)
src/librustc/hir/map/definitions.rs
src/librustc_metadata/creader.rs

index 5322d24e38934cddaaab784fc6915cd955f866fa..c969aef675ff9e0a162ad8410cc074d80da72625 100644 (file)
@@ -55,19 +55,12 @@ fn clone(&self) -> Self {
 }
 
 impl DefPathTable {
-    pub fn new() -> Self {
-        DefPathTable {
-            index_to_key: [vec![], vec![]],
-            key_to_index: FxHashMap(),
-            def_path_hashes: [vec![], vec![]],
-        }
-    }
 
-    pub fn allocate(&mut self,
-                    key: DefKey,
-                    def_path_hash: DefPathHash,
-                    address_space: DefIndexAddressSpace)
-                    -> DefIndex {
+    fn allocate(&mut self,
+                key: DefKey,
+                def_path_hash: DefPathHash,
+                address_space: DefIndexAddressSpace)
+                -> DefIndex {
         let index = {
             let index_to_key = &mut self.index_to_key[address_space.index()];
             let index = DefIndex::new(index_to_key.len() + address_space.start());
@@ -248,7 +241,7 @@ pub struct DefKey {
 }
 
 impl DefKey {
-    pub fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash {
+    fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash {
         let mut hasher = StableHasher::new();
 
         // We hash a 0u8 here to disambiguate between regular DefPath hashes,
@@ -291,7 +284,7 @@ pub fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash {
         DefPathHash(hasher.finish())
     }
 
-    pub fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash {
+    fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash {
         let mut hasher = StableHasher::new();
         // Disambiguate this from a regular DefPath hash,
         // see compute_stable_hash() above.
@@ -453,7 +446,11 @@ impl Definitions {
     /// Create new empty definition map.
     pub fn new() -> Definitions {
         Definitions {
-            table: DefPathTable::new(),
+            table: DefPathTable {
+                index_to_key: [vec![], vec![]],
+                key_to_index: FxHashMap(),
+                def_path_hashes: [vec![], vec![]],
+            },
             node_to_def_index: NodeMap(),
             def_index_to_node: [vec![], vec![]],
             node_to_hir_id: IndexVec::new(),
index e008a5cd9ea6179e8814a902ac465f2c1a31539d..27c2d22168c8b84aa4f3c639302c4b18ac2579fc 100644 (file)
@@ -14,7 +14,7 @@
 use locator::{self, CratePaths};
 use schema::{CrateRoot, Tracked};
 
-use rustc::hir::def_id::{CrateNum, DefIndex, CRATE_DEF_INDEX};
+use rustc::hir::def_id::{CrateNum, DefIndex};
 use rustc::hir::svh::Svh;
 use rustc::middle::cstore::DepKind;
 use rustc::session::Session;
@@ -26,8 +26,7 @@
 use rustc::util::common::record_time;
 use rustc::util::nodemap::FxHashSet;
 use rustc::middle::cstore::NativeLibrary;
-use rustc::hir::map::{Definitions, DefKey, DefPathData, DisambiguatedDefPathData, ITEM_LIKE_SPACE};
-use rustc::hir::map::definitions::DefPathTable;
+use rustc::hir::map::Definitions;
 
 use std::cell::{RefCell, Cell};
 use std::ops::Deref;
@@ -308,16 +307,9 @@ fn register_crate(&mut self,
 
         let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind);
 
-        let proc_macros = crate_root.macro_derive_registrar.map(|_| {
-            self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span)
+        let def_path_table = record_time(&self.sess.perf_stats.decode_def_path_tables_time, || {
+            crate_root.def_path_table.decode(&metadata)
         });
-        let def_path_table = if let Some(ref proc_macros) = proc_macros {
-            proc_macro_def_path_table(proc_macros)
-        } else {
-            record_time(&self.sess.perf_stats.decode_def_path_tables_time, || {
-                crate_root.def_path_table.decode(&metadata)
-            })
-        };
 
         let exported_symbols = crate_root.exported_symbols
                                          .map(|x| x.decode(&metadata).collect());
@@ -336,7 +328,9 @@ fn register_crate(&mut self,
             def_path_table: Rc::new(def_path_table),
             exported_symbols: exported_symbols,
             trait_impls: trait_impls,
-            proc_macros: proc_macros,
+            proc_macros: crate_root.macro_derive_registrar.map(|_| {
+                self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span)
+            }),
             root: crate_root,
             blob: metadata,
             cnum_map: RefCell::new(cnum_map),
@@ -1219,31 +1213,3 @@ fn process_item(&mut self, item: &ast::Item, definitions: &Definitions) {
         }
     }
 }
-
-fn proc_macro_def_path_table(proc_macros: &[(ast::Name, Rc<SyntaxExtension>)]) -> DefPathTable {
-    let mut table = DefPathTable::new();
-    let root = DefKey {
-        parent: None,
-        disambiguated_data: DisambiguatedDefPathData {
-            data: DefPathData::CrateRoot,
-            disambiguator: 0,
-        },
-    };
-
-    let initial_hash = DefKey::root_parent_stable_hash("", "");
-    let root_hash = root.compute_stable_hash(initial_hash);
-    let root_id = table.allocate(root, root_hash, ITEM_LIKE_SPACE);
-    let root_path_hash = table.def_path_hash(root_id);
-    for proc_macro in proc_macros {
-        let key = DefKey {
-            parent: Some(CRATE_DEF_INDEX),
-            disambiguated_data: DisambiguatedDefPathData {
-                data: DefPathData::MacroDef(proc_macro.0),
-                disambiguator: 0,
-            },
-        };
-        let def_path_hash = key.compute_stable_hash(root_path_hash);
-        table.allocate(key, def_path_hash, ITEM_LIKE_SPACE);
-    }
-    table
-}