From eb19a8a6208d992d6d4e661be8fa80c1eeab01f6 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Fri, 22 Jul 2022 16:48:36 +0000 Subject: Compute `lint_levels` by definition --- compiler/rustc_query_impl/src/keys.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'compiler/rustc_query_impl/src') diff --git a/compiler/rustc_query_impl/src/keys.rs b/compiler/rustc_query_impl/src/keys.rs index 49175e97f41..ea2d10cd14b 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::HirId; use rustc_middle::infer::canonical::Canonical; use rustc_middle::mir; use rustc_middle::traits; @@ -543,3 +544,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 { + self.owner.default_span(tcx) + } + + #[inline(always)] + fn key_as_def_id(&self) -> Option { + Some(self.owner.to_def_id()) + } +} -- cgit 1.4.1-3-g733a5