]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/query/mod.rs
Rollup merge of #68889 - Zoxc:hir-krate, r=eddyb
[rust.git] / src / librustc / query / mod.rs
index 228271e0c4c3ae609cda636264dc978d55d560fd..d1bccb961c48bbd3ebf6f5cf012a26829f672fd6 100644 (file)
@@ -43,6 +43,18 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
     }
 
     Other {
+        // Represents crate as a whole (as distinct from the top-level crate module).
+        // If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
+        // we will have to assume that any change means that you need to be recompiled.
+        // This is because the `hir_crate` query gives you access to all other items.
+        // To avoid this fate, do not call `tcx.hir().krate()`; instead,
+        // prefer wrappers like `tcx.visit_all_items_in_krate()`.
+        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() }