use crate::dep_graph::{DepKind, DepNode, RecoverKey, SerializedDepNodeIndex};
use crate::mir;
-use crate::mir::interpret::GlobalId;
+use crate::mir::interpret::{GlobalId, LitToConstInput};
use crate::traits;
use crate::traits::query::{
CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
}
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() }
no_force
desc { "get a &core::panic::Location referring to a span" }
}
+
+ query lit_to_const(
+ key: LitToConstInput<'tcx>
+ ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
+ no_force
+ desc { "converting literal to const" }
+ }
}
TypeChecking {
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 }
}
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<FxHashMap<SubstsRef<'tcx>, 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<SubstsRef<'tcx>, 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<CrateNum> {
+ desc { "available upstream drop-glue for `{:?}`", substs }
+ no_force
+ }
}
Other {
}
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<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
desc { "exported_symbols" }