about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/keys.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-10-01 19:54:55 +0000
committerbors <bors@rust-lang.org>2022-10-01 19:54:55 +0000
commit57f097ea25f2c05f424fc9b9dc50dbd6d399845c (patch)
tree54b2bb2968147e1c6c3e422a18622192334d2ba7 /compiler/rustc_query_impl/src/keys.rs
parent56a35bc906be1250a76fdb9a4b70e9261e10aec5 (diff)
parentfec53fd9db276d34d8d17701aeb3e81576d761fe (diff)
downloadrust-57f097ea25f2c05f424fc9b9dc50dbd6d399845c.tar.gz
rust-57f097ea25f2c05f424fc9b9dc50dbd6d399845c.zip
Auto merge of #102236 - cjgillot:compute_lint_levels_by_def, r=oli-obk
Compute lint levels by definition

Second attempt to https://github.com/rust-lang/rust/pull/101620.

I think that I have removed the perf regression.
Diffstat (limited to 'compiler/rustc_query_impl/src/keys.rs')
-rw-r--r--compiler/rustc_query_impl/src/keys.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/compiler/rustc_query_impl/src/keys.rs b/compiler/rustc_query_impl/src/keys.rs
index 47762440e29..cdbf734cdbe 100644
--- a/compiler/rustc_query_impl/src/keys.rs
+++ b/compiler/rustc_query_impl/src/keys.rs
@@ -1,7 +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_hir::hir_id::{HirId, OwnerId};
 use rustc_middle::infer::canonical::Canonical;
 use rustc_middle::mir;
 use rustc_middle::traits;
@@ -557,3 +557,19 @@ impl<'tcx> Key for (Ty<'tcx>, ty::ValTree<'tcx>) {
         DUMMY_SP
     }
 }
+
+impl Key for HirId {
+    #[inline(always)]
+    fn query_crate_is_local(&self) -> bool {
+        true
+    }
+
+    fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
+        tcx.hir().span(*self)
+    }
+
+    #[inline(always)]
+    fn key_as_def_id(&self) -> Option<DefId> {
+        None
+    }
+}