about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/keys.rs
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-09-20 14:11:23 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-09-24 23:21:19 +0900
commit8fe936099a3a2ea236d40212a340fc4a326eb506 (patch)
tree26b0d90d8a211b35dd4a48d312e018d4fe6de4fa /compiler/rustc_query_impl/src/keys.rs
parentbb5a01617589b5e3ece5a36435fc285bfd13c9a4 (diff)
downloadrust-8fe936099a3a2ea236d40212a340fc4a326eb506.tar.gz
rust-8fe936099a3a2ea236d40212a340fc4a326eb506.zip
separate definitions and `HIR` owners
fix a ui test

use `into`

fix clippy ui test

fix a run-make-fulldeps test

implement `IntoQueryParam<DefId>` for `OwnerId`

use `OwnerId` for more queries

change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
Diffstat (limited to 'compiler/rustc_query_impl/src/keys.rs')
-rw-r--r--compiler/rustc_query_impl/src/keys.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_query_impl/src/keys.rs b/compiler/rustc_query_impl/src/keys.rs
index 2bb7a240faa..47762440e29 100644
--- a/compiler/rustc_query_impl/src/keys.rs
+++ b/compiler/rustc_query_impl/src/keys.rs
@@ -1,6 +1,7 @@
 //! Defines the set of legal keys that can be used in queries.
 
 use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
+use rustc_hir::hir_id::OwnerId;
 use rustc_middle::infer::canonical::Canonical;
 use rustc_middle::mir;
 use rustc_middle::traits;
@@ -104,6 +105,19 @@ impl Key for CrateNum {
     }
 }
 
+impl Key for OwnerId {
+    #[inline(always)]
+    fn query_crate_is_local(&self) -> bool {
+        true
+    }
+    fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
+        self.to_def_id().default_span(tcx)
+    }
+    fn key_as_def_id(&self) -> Option<DefId> {
+        Some(self.to_def_id())
+    }
+}
+
 impl Key for LocalDefId {
     #[inline(always)]
     fn query_crate_is_local(&self) -> bool {