]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_query_impl/src/keys.rs
Rollup merge of #102178 - RalfJung:bootstrap-backtrace, r=Mark-Simulacrum
[rust.git] / compiler / rustc_query_impl / src / keys.rs
index 2bb7a240faa60b88d101e3b9da6f4bc5ec46dfa1..47762440e290b659a82b0dff776628fac1971e44 100644 (file)
@@ -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 @@ fn default_span(&self, _: TyCtxt<'_>) -> Span {
     }
 }
 
+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 {