X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fquery%2Fmod.rs;h=82ff7da13aea85fd24ad4bbeab2bf04d405ad9ca;hb=20ce2f6038913058f548f56e1ff1fad29d4df07f;hp=37d5e23535b817be97008ca94011f886958a8149;hpb=c4071d09197e22d2fab8334aa8d30659961bb977;p=rust.git diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index 37d5e23535b..82ff7da13ae 100644 --- a/src/librustc/query/mod.rs +++ b/src/librustc/query/mod.rs @@ -43,6 +43,18 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { } Other { + // Represents crate as a whole (as distinct from the to-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() }