about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-11-21 19:04:47 +0100
committerSantiago Pastorino <spastorino@gmail.com>2022-01-25 15:05:19 -0300
commit80132c3ce496ba1ad6f2ec4fa1f3db34cf8b9f77 (patch)
tree3758cbea88db9eee70ccc4662d3ef3c83bfe4252 /compiler/rustc_ast_lowering/src
parent17dfae79bbc3dabe1427073086acf7f7bd45148c (diff)
downloadrust-80132c3ce496ba1ad6f2ec4fa1f3db34cf8b9f77.tar.gz
rust-80132c3ce496ba1ad6f2ec4fa1f3db34cf8b9f77.zip
Store hir_id_to_def_id in OwnerInfo.
Diffstat (limited to 'compiler/rustc_ast_lowering/src')
-rw-r--r--compiler/rustc_ast_lowering/src/lib.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 47b61067055..cc14f48b6bd 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -479,6 +479,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         let attrs = std::mem::take(&mut self.attrs);
         let mut bodies = std::mem::take(&mut self.bodies);
         let local_node_ids = std::mem::take(&mut self.local_node_ids);
+
+        let local_id_to_def_id = local_node_ids
+            .iter()
+            .filter_map(|&node_id| {
+                let def_id = self.resolver.opt_local_def_id(node_id)?;
+                let hir_id = self.node_id_to_hir_id[node_id]?;
+                Some((hir_id.local_id, def_id))
+            })
+            .collect();
+
         let trait_map = local_node_ids
             .into_iter()
             .filter_map(|node_id| {
@@ -501,7 +511,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         let (hash_including_bodies, hash_without_bodies) = self.hash_owner(node, &bodies);
         let (nodes, parenting) =
             index::index_hir(self.sess, self.resolver.definitions(), node, &bodies);
-        let nodes = hir::OwnerNodes { hash_including_bodies, hash_without_bodies, nodes, bodies };
+        let nodes = hir::OwnerNodes {
+            hash_including_bodies,
+            hash_without_bodies,
+            nodes,
+            bodies,
+            local_id_to_def_id,
+        };
         let attrs = {
             let mut hcx = self.resolver.create_stable_hashing_context();
             let mut stable_hasher = StableHasher::new();