Skip to content

Commit 302935f

Browse files
alexcrichtonjseyfried
authored andcommitted
Revert a few changes
1 parent 4012b8d commit 302935f

File tree

2 files changed

+19
-56
lines changed

2 files changed

+19
-56
lines changed

src/librustc/hir/map/definitions.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,12 @@ impl Clone for DefPathTable {
5555
}
5656

5757
impl DefPathTable {
58-
pub fn new() -> Self {
59-
DefPathTable {
60-
index_to_key: [vec![], vec![]],
61-
key_to_index: FxHashMap(),
62-
def_path_hashes: [vec![], vec![]],
63-
}
64-
}
6558

66-
pub fn allocate(&mut self,
67-
key: DefKey,
68-
def_path_hash: DefPathHash,
69-
address_space: DefIndexAddressSpace)
70-
-> DefIndex {
59+
fn allocate(&mut self,
60+
key: DefKey,
61+
def_path_hash: DefPathHash,
62+
address_space: DefIndexAddressSpace)
63+
-> DefIndex {
7164
let index = {
7265
let index_to_key = &mut self.index_to_key[address_space.index()];
7366
let index = DefIndex::new(index_to_key.len() + address_space.start());
@@ -248,7 +241,7 @@ pub struct DefKey {
248241
}
249242

250243
impl DefKey {
251-
pub fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash {
244+
fn compute_stable_hash(&self, parent_hash: DefPathHash) -> DefPathHash {
252245
let mut hasher = StableHasher::new();
253246

254247
// We hash a 0u8 here to disambiguate between regular DefPath hashes,
@@ -291,7 +284,7 @@ impl DefKey {
291284
DefPathHash(hasher.finish())
292285
}
293286

294-
pub fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash {
287+
fn root_parent_stable_hash(crate_name: &str, crate_disambiguator: &str) -> DefPathHash {
295288
let mut hasher = StableHasher::new();
296289
// Disambiguate this from a regular DefPath hash,
297290
// see compute_stable_hash() above.
@@ -453,7 +446,11 @@ impl Definitions {
453446
/// Create new empty definition map.
454447
pub fn new() -> Definitions {
455448
Definitions {
456-
table: DefPathTable::new(),
449+
table: DefPathTable {
450+
index_to_key: [vec![], vec![]],
451+
key_to_index: FxHashMap(),
452+
def_path_hashes: [vec![], vec![]],
453+
},
457454
node_to_def_index: NodeMap(),
458455
def_index_to_node: [vec![], vec![]],
459456
node_to_hir_id: IndexVec::new(),

src/librustc_metadata/creader.rs

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use cstore::{self, CStore, CrateSource, MetadataBlob};
1414
use locator::{self, CratePaths};
1515
use schema::{CrateRoot, Tracked};
1616

17-
use rustc::hir::def_id::{CrateNum, DefIndex, CRATE_DEF_INDEX};
17+
use rustc::hir::def_id::{CrateNum, DefIndex};
1818
use rustc::hir::svh::Svh;
1919
use rustc::middle::cstore::DepKind;
2020
use rustc::session::Session;
@@ -26,8 +26,7 @@ use rustc::middle::cstore::{CrateStore, validate_crate_name, ExternCrate};
2626
use rustc::util::common::record_time;
2727
use rustc::util::nodemap::FxHashSet;
2828
use rustc::middle::cstore::NativeLibrary;
29-
use rustc::hir::map::{Definitions, DefKey, DefPathData, DisambiguatedDefPathData, ITEM_LIKE_SPACE};
30-
use rustc::hir::map::definitions::DefPathTable;
29+
use rustc::hir::map::Definitions;
3130

3231
use std::cell::{RefCell, Cell};
3332
use std::ops::Deref;
@@ -308,16 +307,9 @@ impl<'a> CrateLoader<'a> {
308307

309308
let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind);
310309

311-
let proc_macros = crate_root.macro_derive_registrar.map(|_| {
312-
self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span)
310+
let def_path_table = record_time(&self.sess.perf_stats.decode_def_path_tables_time, || {
311+
crate_root.def_path_table.decode(&metadata)
313312
});
314-
let def_path_table = if let Some(ref proc_macros) = proc_macros {
315-
proc_macro_def_path_table(proc_macros)
316-
} else {
317-
record_time(&self.sess.perf_stats.decode_def_path_tables_time, || {
318-
crate_root.def_path_table.decode(&metadata)
319-
})
320-
};
321313

322314
let exported_symbols = crate_root.exported_symbols
323315
.map(|x| x.decode(&metadata).collect());
@@ -336,7 +328,9 @@ impl<'a> CrateLoader<'a> {
336328
def_path_table: Rc::new(def_path_table),
337329
exported_symbols: exported_symbols,
338330
trait_impls: trait_impls,
339-
proc_macros: proc_macros,
331+
proc_macros: crate_root.macro_derive_registrar.map(|_| {
332+
self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span)
333+
}),
340334
root: crate_root,
341335
blob: metadata,
342336
cnum_map: RefCell::new(cnum_map),
@@ -1219,31 +1213,3 @@ impl<'a> middle::cstore::CrateLoader for CrateLoader<'a> {
12191213
}
12201214
}
12211215
}
1222-
1223-
fn proc_macro_def_path_table(proc_macros: &[(ast::Name, Rc<SyntaxExtension>)]) -> DefPathTable {
1224-
let mut table = DefPathTable::new();
1225-
let root = DefKey {
1226-
parent: None,
1227-
disambiguated_data: DisambiguatedDefPathData {
1228-
data: DefPathData::CrateRoot,
1229-
disambiguator: 0,
1230-
},
1231-
};
1232-
1233-
let initial_hash = DefKey::root_parent_stable_hash("", "");
1234-
let root_hash = root.compute_stable_hash(initial_hash);
1235-
let root_id = table.allocate(root, root_hash, ITEM_LIKE_SPACE);
1236-
let root_path_hash = table.def_path_hash(root_id);
1237-
for proc_macro in proc_macros {
1238-
let key = DefKey {
1239-
parent: Some(CRATE_DEF_INDEX),
1240-
disambiguated_data: DisambiguatedDefPathData {
1241-
data: DefPathData::MacroDef(proc_macro.0),
1242-
disambiguator: 0,
1243-
},
1244-
};
1245-
let def_path_hash = key.compute_stable_hash(root_path_hash);
1246-
table.allocate(key, def_path_hash, ITEM_LIKE_SPACE);
1247-
}
1248-
table
1249-
}

0 commit comments

Comments
 (0)