Skip to content

Commit 89ecf8f

Browse files
committed
wip
1 parent 8bec29f commit 89ecf8f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/librustc/hir/map/collector.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
202202
crate_disambiguator: CrateDisambiguator,
203203
cstore: &dyn CrateStore,
204204
commandline_args_hash: u64,
205-
) -> (HirEntryMap<'hir>, Svh) {
205+
) -> (
206+
HirEntryMap<'hir>,
207+
FxHashMap<DefIndex, &'hir HirOwner<'hir>>,
208+
FxHashMap<DefIndex, &'hir mut HirOwnerItems<'hir>>,
209+
Svh,
210+
) {
206211
self.hir_body_nodes.sort_unstable_by_key(|bn| bn.0);
207212

208213
let node_hashes = self.hir_body_nodes.iter().fold(
@@ -239,7 +244,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
239244
let crate_hash: Fingerprint = stable_hasher.finish();
240245

241246
let svh = Svh::new(crate_hash.to_smaller_hash());
242-
(self.map, svh)
247+
(self.map, self.owner_map, self.owner_items_map, svh)
243248
}
244249

245250
fn insert_entry(&mut self, id: HirId, entry: Entry<'hir>) {

src/librustc/hir/map/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub use self::definitions::{
55

66
use crate::arena::Arena;
77
use crate::dep_graph::{DepGraph, DepKind, DepNode, DepNodeIndex};
8+
use crate::hir::{HirOwner, HirOwnerItems};
89
use crate::middle::cstore::CrateStoreDyn;
910
use crate::ty::query::Providers;
1011
use rustc_data_structures::fx::FxHashMap;
@@ -146,6 +147,9 @@ pub struct Map<'hir> {
146147
/// The SVH of the local crate.
147148
pub crate_hash: Svh,
148149

150+
pub(super) owner_map: FxHashMap<DefIndex, &'hir HirOwner<'hir>>,
151+
pub(super) owner_items_map: FxHashMap<DefIndex, &'hir HirOwnerItems<'hir>>,
152+
149153
map: HirEntryMap<'hir>,
150154

151155
definitions: Definitions,
@@ -1222,7 +1226,7 @@ pub fn map_crate<'hir>(
12221226
.map(|(node_id, &hir_id)| (hir_id, node_id))
12231227
.collect();
12241228

1225-
let (map, crate_hash) = {
1229+
let (map, owner_map, owner_items_map, crate_hash) = {
12261230
let hcx = crate::ich::StableHashingContext::new(sess, krate, &definitions, cstore);
12271231

12281232
let mut collector =
@@ -1234,7 +1238,16 @@ pub fn map_crate<'hir>(
12341238
collector.finalize_and_compute_crate_hash(crate_disambiguator, cstore, cmdline_args)
12351239
};
12361240

1237-
let map = Map { krate, dep_graph, crate_hash, map, hir_to_node_id, definitions };
1241+
let map = Map {
1242+
krate,
1243+
dep_graph,
1244+
crate_hash,
1245+
map,
1246+
owner_map,
1247+
owner_items_map: owner_items_map.into_iter().map(|(k, v)| (k, &*v)).collect(),
1248+
hir_to_node_id,
1249+
definitions,
1250+
};
12381251

12391252
sess.time("validate_HIR_map", || {
12401253
hir_id_validator::check_crate(&map);

0 commit comments

Comments
 (0)