about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2022-01-29 08:40:23 -0300
committerSantiago Pastorino <spastorino@gmail.com>2022-01-29 08:40:23 -0300
commitbf1ca2e4b01b9930d29064b1d170a9ead0415fa2 (patch)
tree0f6a65406d314c8a2e9a2a83e5f0538630a7965c
parent5a299a9903abd6bd5161d610855b0c123ed58dfb (diff)
downloadrust-bf1ca2e4b01b9930d29064b1d170a9ead0415fa2.tar.gz
rust-bf1ca2e4b01b9930d29064b1d170a9ead0415fa2.zip
Make local_def_id_to_hir_id query directly returh HirId
-rw-r--r--compiler/rustc_middle/src/hir/map/mod.rs7
-rw-r--r--compiler/rustc_middle/src/hir/mod.rs9
-rw-r--r--compiler/rustc_middle/src/query/mod.rs2
3 files changed, 10 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index a83f027595d..649cb34bd5f 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -215,12 +215,7 @@ impl<'hir> Map<'hir> {
 
     #[inline]
     pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId {
-        let owner = self.tcx.local_def_id_to_hir_id(def_id);
-        match owner {
-            MaybeOwner::Owner(_) => HirId::make_owner(def_id),
-            MaybeOwner::Phantom => bug!("No HirId for {:?}", def_id),
-            MaybeOwner::NonOwner(hir_id) => hir_id,
-        }
+        self.tcx.local_def_id_to_hir_id(def_id)
     }
 
     pub fn iter_local_def_id(&self) -> impl Iterator<Item = LocalDefId> + '_ {
diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs
index 12379eed80e..1053f0cefbe 100644
--- a/compiler/rustc_middle/src/hir/mod.rs
+++ b/compiler/rustc_middle/src/hir/mod.rs
@@ -69,7 +69,14 @@ pub fn provide(providers: &mut Providers) {
         let node = owner.node();
         Some(Owner { node, hash_without_bodies: owner.nodes.hash_without_bodies })
     };
-    providers.local_def_id_to_hir_id = |tcx, id| tcx.hir_crate(()).owners[id].map(|_| ());
+    providers.local_def_id_to_hir_id = |tcx, id| {
+        let owner = tcx.hir_crate(()).owners[id].map(|_| ());
+        match owner {
+            MaybeOwner::Owner(_) => HirId::make_owner(id),
+            MaybeOwner::Phantom => bug!("No HirId for {:?}", id),
+            MaybeOwner::NonOwner(hir_id) => hir_id,
+        }
+    };
     providers.hir_owner_nodes = |tcx, id| tcx.hir_crate(()).owners[id].map(|i| &i.nodes);
     providers.hir_owner_parent = |tcx, id| {
         // Accessing the def_key is ok since its value is hashed as part of `id`'s DefPathHash.
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 334e06aa685..c01e7177760 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -60,7 +60,7 @@ rustc_queries! {
     ///
     /// This can be conveniently accessed by methods on `tcx.hir()`.
     /// Avoid calling this query directly.
-    query local_def_id_to_hir_id(key: LocalDefId) -> hir::MaybeOwner<()> {
+    query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId {
         desc { |tcx| "HIR ID of `{}`", tcx.def_path_str(key.to_def_id()) }
     }