]> git.lizzy.rs Git - rust.git/commitdiff
Add a `hir_krate` query
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Thu, 6 Feb 2020 11:16:51 +0000 (12:16 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Thu, 6 Feb 2020 11:16:51 +0000 (12:16 +0100)
src/librustc/hir/mod.rs
src/librustc/query/mod.rs
src/librustc/ty/query/mod.rs

index 4a4d9cb81456d266de2d1235ffbb85b51c30545c..3a53c0cb28274b85921b079bd23010df0a0fe977 100644 (file)
@@ -41,5 +41,6 @@ pub fn hir(self) -> Hir<'tcx> {
 }
 
 pub fn provide(providers: &mut Providers<'_>) {
+    providers.hir_crate = |tcx, _| tcx.hir_map.forest.untracked_krate();
     map::provide(providers);
 }
index 37d5e23535b817be97008ca94011f886958a8149..f0ea9ee7b196aaba900d5c1790b4f8b389ae813d 100644 (file)
@@ -43,6 +43,12 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
     }
 
     Other {
+        query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> {
+            eval_always
+            no_hash
+            desc { "get the crate HIR" }
+        }
+
         /// Records the type of every item.
         query type_of(key: DefId) -> Ty<'tcx> {
             cache_on_disk_if { key.is_local() }
index 973cd81014616ffd112f9c9f3e48a766597aca59..e7b95af103cc939e2b45c51adabb547835ce99c4 100644 (file)
@@ -45,7 +45,7 @@
 use rustc_hir as hir;
 use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet, DefIndex};
-use rustc_hir::{HirIdSet, ItemLocalId, TraitCandidate};
+use rustc_hir::{Crate, HirIdSet, ItemLocalId, TraitCandidate};
 use rustc_index::vec::IndexVec;
 use rustc_target::spec::PanicStrategy;