X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fquery%2Fmod.rs;h=82ff7da13aea85fd24ad4bbeab2bf04d405ad9ca;hb=20ce2f6038913058f548f56e1ff1fad29d4df07f;hp=a20e011b91a7543697bdb006784a82e205397ace;hpb=e8819b62b4c45d380058c5f86c7e9484ae05ddb5;p=rust.git diff --git a/src/librustc/query/mod.rs b/src/librustc/query/mod.rs index a20e011b91a..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() } @@ -557,6 +569,9 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) } } + /// The `symbol_name` query provides the symbol name for calling a + /// given instance from the local crate. In particular, it will also + /// look up the correct symbol name of instances from upstream crates. query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName { no_force desc { "computing the symbol for `{}`", key } @@ -773,13 +788,47 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { } Codegen { + /// The entire set of monomorphizations the local crate can safely link + /// to because they are exported from upstream crates. Do not depend on + /// this directly, as its value changes anytime a monomorphization gets + /// added or removed in any upstream crate. Instead use the narrower + /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even + /// better, `Instance::upstream_monomorphization()`. query upstream_monomorphizations( k: CrateNum ) -> &'tcx DefIdMap, CrateNum>> { desc { "collecting available upstream monomorphizations `{:?}`", k } } + + /// Returns the set of upstream monomorphizations available for the + /// generic function identified by the given `def_id`. The query makes + /// sure to make a stable selection if the same monomorphization is + /// available in multiple upstream crates. + /// + /// You likely want to call `Instance::upstream_monomorphization()` + /// instead of invoking this query directly. query upstream_monomorphizations_for(_: DefId) -> Option<&'tcx FxHashMap, CrateNum>> {} + + /// Returns the upstream crate that exports drop-glue for the given + /// type (`substs` is expected to be a single-item list containing the + /// type one wants drop-glue for). + /// + /// This is a subset of `upstream_monomorphizations_for` in order to + /// increase dep-tracking granularity. Otherwise adding or removing any + /// type with drop-glue in any upstream crate would invalidate all + /// functions calling drop-glue of an upstream type. + /// + /// You likely want to call `Instance::upstream_monomorphization()` + /// instead of invoking this query directly. + /// + /// NOTE: This query could easily be extended to also support other + /// common functions that have are large set of monomorphizations + /// (like `Clone::clone` for example). + query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option { + desc { "available upstream drop-glue for `{:?}`", substs } + no_force + } } Other { @@ -971,6 +1020,11 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { } Linking { + /// The list of symbols exported from the given crate. + /// + /// - All names contained in `exported_symbols(cnum)` are guaranteed to + /// correspond to a publicly visible symbol in `cnum` machine code. + /// - The `exported_symbols` sets of different crates do not intersect. query exported_symbols(_: CrateNum) -> Arc, SymbolExportLevel)>> { desc { "exported_symbols" } @@ -1148,11 +1202,11 @@ fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String { desc { "normalizing `{:?}`", goal } } - query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>, traits::TraitQueryMode)) -> bool { + query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool { no_force desc { |tcx| - "testing substituted normalized predicates in mode {:?}:`{}`", - key.2, tcx.def_path_str(key.0) + "testing substituted normalized predicates:`{}`", + tcx.def_path_str(key.0) } }