1 use crate::dep_graph::{DepKind, DepNode, RecoverKey, SerializedDepNodeIndex};
3 use crate::mir::interpret::{GlobalId, LitToConstInput};
5 use crate::traits::query::{
6 CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal,
7 CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
8 CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
10 use crate::ty::query::queries;
11 use crate::ty::query::QueryDescription;
12 use crate::ty::subst::SubstsRef;
13 use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
14 use rustc_hir::def_id::{CrateNum, DefId, DefIndex};
16 use rustc_span::symbol::Symbol;
19 fn describe_as_module(def_id: DefId, tcx: TyCtxt<'_>) -> String {
20 if def_id.is_top_level_module() {
21 format!("top-level module")
23 format!("module `{}`", tcx.def_path_str(def_id))
27 // Each of these queries corresponds to a function pointer field in the
28 // `Providers` struct for requesting a value of that type, and a method
29 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
30 // which memoizes and does dep-graph tracking, wrapping around the actual
31 // `Providers` that the driver creates (using several `rustc_*` crates).
33 // The result type of each query must implement `Clone`, and additionally
34 // `ty::query::values::Value`, which produces an appropriate placeholder
35 // (error) value if the query resulted in a query cycle.
36 // Queries marked with `fatal_cycle` do not need the latter implementation,
37 // as they will raise an fatal error on query cycles instead.
40 query trigger_delay_span_bug(key: DefId) -> () {
41 desc { "trigger a delay span bug" }
46 /// Records the type of every item.
47 query type_of(key: DefId) -> Ty<'tcx> {
48 cache_on_disk_if { key.is_local() }
51 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
52 /// associated generics.
53 query generics_of(key: DefId) -> &'tcx ty::Generics {
54 cache_on_disk_if { key.is_local() }
55 load_cached(tcx, id) {
56 let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
57 .try_load_query_result(tcx, id);
58 generics.map(|x| &*tcx.arena.alloc(x))
62 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
63 /// predicates (where-clauses) that must be proven true in order
64 /// to reference it. This is almost always the "predicates query"
67 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
68 /// it is almost always the same as that query, except for the
69 /// case of traits. For traits, `predicates_of` contains
70 /// an additional `Self: Trait<...>` predicate that users don't
71 /// actually write. This reflects the fact that to invoke the
72 /// trait (e.g., via `Default::default`) you must supply types
73 /// that actually implement the trait. (However, this extra
74 /// predicate gets in the way of some checks, which are intended
75 /// to operate over only the actual where-clauses written by the
77 query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
78 cache_on_disk_if { key.is_local() }
81 query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLibrary>> {
82 desc { "looking up the native libraries of a linked crate" }
85 query lint_levels(_: CrateNum) -> &'tcx LintLevelMap {
87 desc { "computing the lint levels for items in this crate" }
92 query is_panic_runtime(_: CrateNum) -> bool {
94 desc { "checking if the crate is_panic_runtime" }
99 /// Set of all the `DefId`s in this crate that have MIR associated with
100 /// them. This includes all the body owners, but also things like struct
102 query mir_keys(_: CrateNum) -> &'tcx DefIdSet {
103 desc { "getting a list of all mir_keys" }
106 /// Maps DefId's that have an associated `mir::Body` to the result
107 /// of the MIR const-checking pass. This is the set of qualifs in
108 /// the final value of a `const`.
109 query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
110 desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
111 cache_on_disk_if { key.is_local() }
114 /// Fetch the MIR for a given `DefId` right after it's built - this includes
115 /// unreachable code.
116 query mir_built(_: DefId) -> &'tcx Steal<mir::BodyAndCache<'tcx>> {}
118 /// Fetch the MIR for a given `DefId` up till the point where it is
119 /// ready for const evaluation.
121 /// See the README for the `mir` module for details.
122 query mir_const(_: DefId) -> &'tcx Steal<mir::BodyAndCache<'tcx>> {
126 query mir_validated(_: DefId) ->
128 &'tcx Steal<mir::BodyAndCache<'tcx>>,
129 &'tcx Steal<IndexVec<mir::Promoted, mir::BodyAndCache<'tcx>>>
134 /// MIR after our optimization passes have run. This is MIR that is ready
135 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
136 query optimized_mir(key: DefId) -> &'tcx mir::BodyAndCache<'tcx> {
137 cache_on_disk_if { key.is_local() }
138 load_cached(tcx, id) {
139 let mir: Option<crate::mir::BodyAndCache<'tcx>>
140 = tcx.queries.on_disk_cache.try_load_query_result(tcx, id);
142 let cache = tcx.arena.alloc(x);
143 cache.ensure_predecessors();
149 query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::BodyAndCache<'tcx>> {
150 cache_on_disk_if { key.is_local() }
151 load_cached(tcx, id) {
152 let promoted: Option<
153 rustc_index::vec::IndexVec<
154 crate::mir::Promoted,
155 crate::mir::BodyAndCache<'tcx>
156 >> = tcx.queries.on_disk_cache.try_load_query_result(tcx, id);
158 let cache = tcx.arena.alloc(p);
159 for body in cache.iter_mut() {
160 body.ensure_predecessors();
169 // Erases regions from `ty` to yield a new type.
170 // Normally you would just use `tcx.erase_regions(&value)`,
171 // however, which uses this query as a kind of cache.
172 query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
173 // This query is not expected to have input -- as a result, it
174 // is not a good candidates for "replay" because it is essentially a
175 // pure function of its input (and hence the expectation is that
176 // no caller would be green **apart** from just these
177 // queries). Making it anonymous avoids hashing the result, which
178 // may save a bit of time.
181 desc { "erasing regions from `{:?}`", ty }
184 query program_clauses_for(_: DefId) -> Clauses<'tcx> {
185 desc { "generating chalk-style clauses" }
188 query program_clauses_for_env(_: traits::Environment<'tcx>) -> Clauses<'tcx> {
190 desc { "generating chalk-style clauses for environment" }
193 // Get the chalk-style environment of the given item.
194 query environment(_: DefId) -> traits::Environment<'tcx> {
195 desc { "return a chalk-style environment" }
200 query wasm_import_module_map(_: CrateNum) -> &'tcx FxHashMap<DefId, String> {
201 desc { "wasm import module map" }
206 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
207 /// predicates (where-clauses) directly defined on it. This is
208 /// equal to the `explicit_predicates_of` predicates plus the
209 /// `inferred_outlives_of` predicates.
210 query predicates_defined_on(_: DefId) -> ty::GenericPredicates<'tcx> {}
212 /// Returns the predicates written explicitly by the user.
213 query explicit_predicates_of(_: DefId) -> ty::GenericPredicates<'tcx> {}
215 /// Returns the inferred outlives predicates (e.g., for `struct
216 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
217 query inferred_outlives_of(_: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {}
219 /// Maps from the `DefId` of a trait to the list of
220 /// super-predicates. This is a subset of the full list of
221 /// predicates. We store these in a separate map because we must
222 /// evaluate them even during type conversion, often before the
223 /// full predicates are available (note that supertraits have
224 /// additional acyclicity requirements).
225 query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
226 desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) }
229 /// To avoid cycles within the predicates of a single item we compute
230 /// per-type-parameter predicates for resolving `T::AssocTy`.
231 query type_param_predicates(key: (DefId, DefId)) -> ty::GenericPredicates<'tcx> {
233 desc { |tcx| "computing the bounds for type parameter `{}`", {
234 let id = tcx.hir().as_local_hir_id(key.1).unwrap();
235 tcx.hir().ty_param_name(id)
239 query trait_def(_: DefId) -> &'tcx ty::TraitDef {}
240 query adt_def(_: DefId) -> &'tcx ty::AdtDef {}
241 query adt_destructor(_: DefId) -> Option<ty::Destructor> {}
243 // The cycle error here should be reported as an error by `check_representable`.
244 // We consider the type as Sized in the meanwhile to avoid
245 // further errors (done in impl Value for AdtSizedConstraint).
246 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
247 // in case we accidentally otherwise don't emit an error.
248 query adt_sized_constraint(
250 ) -> AdtSizedConstraint<'tcx> {
254 query adt_dtorck_constraint(
256 ) -> Result<DtorckConstraint<'tcx>, NoSolution> {}
258 /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
259 /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
260 /// not have the feature gate active).
262 /// **Do not call this function manually.** It is only meant to cache the base data for the
263 /// `is_const_fn` function.
264 query is_const_fn_raw(key: DefId) -> bool {
265 desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
268 query asyncness(key: DefId) -> hir::IsAsync {
269 desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
272 /// Returns `true` if calls to the function may be promoted.
274 /// This is either because the function is e.g., a tuple-struct or tuple-variant
275 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
276 /// be removed in the future in favour of some form of check which figures out whether the
277 /// function does not inspect the bits of any of its arguments (so is essentially just a
278 /// constructor function).
279 query is_promotable_const_fn(_: DefId) -> bool {}
281 query const_fn_is_allowed_fn_ptr(_: DefId) -> bool {}
283 /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
284 query is_foreign_item(_: DefId) -> bool {}
286 /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
287 query static_mutability(_: DefId) -> Option<hir::Mutability> {}
289 /// Gets a map with the variance of every item; use `item_variance` instead.
290 query crate_variances(_: CrateNum) -> &'tcx ty::CrateVariancesMap<'tcx> {
291 desc { "computing the variances for items in this crate" }
294 /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
295 query variances_of(_: DefId) -> &'tcx [ty::Variance] {}
299 /// Maps from thee `DefId` of a type to its (inferred) outlives.
300 query inferred_outlives_crate(_: CrateNum)
301 -> &'tcx ty::CratePredicatesMap<'tcx> {
302 desc { "computing the inferred outlives predicates for items in this crate" }
307 /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items.
308 query associated_item_def_ids(_: DefId) -> &'tcx [DefId] {}
310 /// Maps from a trait item to the trait item "descriptor".
311 query associated_item(_: DefId) -> ty::AssocItem {}
313 query impl_trait_ref(_: DefId) -> Option<ty::TraitRef<'tcx>> {}
314 query impl_polarity(_: DefId) -> ty::ImplPolarity {}
316 query issue33140_self_ty(_: DefId) -> Option<ty::Ty<'tcx>> {}
320 /// Maps a `DefId` of a type to a list of its inherent impls.
321 /// Contains implementations of methods that are inherent to a type.
322 /// Methods in these implementations don't need to be exported.
323 query inherent_impls(_: DefId) -> &'tcx [DefId] {
329 /// The result of unsafety-checking this `DefId`.
330 query unsafety_check_result(key: DefId) -> mir::UnsafetyCheckResult {
331 cache_on_disk_if { key.is_local() }
334 /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error
335 query unsafe_derive_on_repr_packed(_: DefId) -> () {}
337 /// The signature of functions and closures.
338 query fn_sig(_: DefId) -> ty::PolyFnSig<'tcx> {}
342 query lint_mod(key: DefId) -> () {
343 desc { |tcx| "linting {}", describe_as_module(key, tcx) }
346 /// Checks the attributes in the module.
347 query check_mod_attrs(key: DefId) -> () {
348 desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
351 query check_mod_unstable_api_usage(key: DefId) -> () {
352 desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
355 /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
356 query check_mod_const_bodies(key: DefId) -> () {
357 desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
360 /// Checks the loops in the module.
361 query check_mod_loops(key: DefId) -> () {
362 desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
365 query check_mod_item_types(key: DefId) -> () {
366 desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) }
369 query check_mod_privacy(key: DefId) -> () {
370 desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) }
373 query check_mod_intrinsics(key: DefId) -> () {
374 desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) }
377 query check_mod_liveness(key: DefId) -> () {
378 desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) }
381 query check_mod_impl_wf(key: DefId) -> () {
382 desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
385 query collect_mod_item_types(key: DefId) -> () {
386 desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
389 /// Caches `CoerceUnsized` kinds for impls on custom types.
390 query coerce_unsized_info(_: DefId)
391 -> ty::adjustment::CoerceUnsizedInfo {}
395 query typeck_item_bodies(_: CrateNum) -> () {
396 desc { "type-checking all item bodies" }
399 query typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
400 cache_on_disk_if { key.is_local() }
401 load_cached(tcx, id) {
402 let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
403 .queries.on_disk_cache
404 .try_load_query_result(tcx, id);
406 typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
409 query diagnostic_only_typeck_tables_of(key: DefId) -> &'tcx ty::TypeckTables<'tcx> {
410 cache_on_disk_if { key.is_local() }
411 load_cached(tcx, id) {
412 let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
413 .queries.on_disk_cache
414 .try_load_query_result(tcx, id);
416 typeck_tables.map(|tables| &*tcx.arena.alloc(tables))
422 query used_trait_imports(key: DefId) -> &'tcx DefIdSet {
423 cache_on_disk_if { key.is_local() }
428 query has_typeck_tables(_: DefId) -> bool {}
430 query coherent_trait(def_id: DefId) -> () {
431 desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
436 /// Borrow-checks the function body. If this is a closure, returns
437 /// additional requirements that the closure's creator must verify.
438 query mir_borrowck(key: DefId) -> mir::BorrowCheckResult<'tcx> {
439 cache_on_disk_if(tcx, _) { key.is_local() && tcx.is_closure(key) }
444 /// Gets a complete map from all types to their inherent impls.
445 /// Not meant to be used directly outside of coherence.
446 /// (Defined only for `LOCAL_CRATE`.)
447 query crate_inherent_impls(k: CrateNum)
448 -> &'tcx CrateInherentImpls {
450 desc { "all inherent impls defined in crate `{:?}`", k }
453 /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
454 /// Not meant to be used directly outside of coherence.
455 /// (Defined only for `LOCAL_CRATE`.)
456 query crate_inherent_impls_overlap_check(_: CrateNum)
459 desc { "check for overlap between inherent impls defined in this crate" }
464 /// Evaluates a constant without running sanity checks.
466 /// **Do not use this** outside const eval. Const eval uses this to break query cycles
467 /// during validation. Please add a comment to every use site explaining why using
468 /// `const_eval_validated` isn't sufficient. The returned constant also isn't in a suitable
469 /// form to be used outside of const eval.
470 query const_eval_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
471 -> ConstEvalRawResult<'tcx> {
474 "const-evaluating `{}`",
475 tcx.def_path_str(key.value.instance.def.def_id())
479 /// Results of evaluating const items or constants embedded in
480 /// other items (such as enum variant explicit discriminants).
482 /// In contrast to `const_eval_raw` this performs some validation on the constant, and
483 /// returns a proper constant that is usable by the rest of the compiler.
485 /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
486 /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_promoted`.
487 query const_eval_validated(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
488 -> ConstEvalResult<'tcx> {
491 "const-evaluating + checking `{}`",
492 tcx.def_path_str(key.value.instance.def.def_id())
494 cache_on_disk_if(_, opt_result) {
495 // Only store results without errors
496 opt_result.map_or(true, |r| r.is_ok())
500 /// Extracts a field of a (variant of a) const.
502 key: ty::ParamEnvAnd<'tcx, (&'tcx ty::Const<'tcx>, mir::Field)>
503 ) -> &'tcx ty::Const<'tcx> {
505 desc { "extract field of const" }
508 /// Destructure a constant ADT or array into its variant indent and its
510 query destructure_const(
511 key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
512 ) -> mir::DestructuredConst<'tcx> {
514 desc { "destructure constant" }
517 query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> &'tcx ty::Const<'tcx> {
519 desc { "get a &core::panic::Location referring to a span" }
523 key: LitToConstInput<'tcx>
524 ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
526 desc { "converting literal to const" }
531 query check_match(key: DefId) {
532 cache_on_disk_if { key.is_local() }
535 /// Performs part of the privacy check and computes "access levels".
536 query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels {
538 desc { "privacy access levels" }
540 query check_private_in_public(_: CrateNum) -> () {
542 desc { "checking for private elements in public interfaces" }
547 query reachable_set(_: CrateNum) -> Lrc<HirIdSet> {
548 desc { "reachability" }
551 /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
552 /// in the case of closures, this will be redirected to the enclosing function.
553 query region_scope_tree(_: DefId) -> &'tcx region::ScopeTree {}
555 query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::BodyAndCache<'tcx> {
557 desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
560 query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName {
562 desc { "computing the symbol for `{}`", key }
563 cache_on_disk_if { true }
566 query def_kind(_: DefId) -> Option<DefKind> {}
567 query def_span(_: DefId) -> Span {
568 // FIXME(mw): DefSpans are not really inputs since they are derived from
569 // HIR. But at the moment HIR hashing still contains some hacks that allow
570 // to make type debuginfo to be source location independent. Declaring
571 // DefSpan an input makes sure that changes to these are always detected
572 // regardless of HIR hashing.
575 query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
576 query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {}
577 query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
578 query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {}
582 query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {
583 cache_on_disk_if { true }
588 query fn_arg_names(_: DefId) -> Vec<ast::Name> {}
589 /// Gets the rendered value of the specified constant or associated constant.
591 query rendered_const(_: DefId) -> String {}
592 query impl_parent(_: DefId) -> Option<DefId> {}
596 query trait_of_item(_: DefId) -> Option<DefId> {}
600 query is_mir_available(key: DefId) -> bool {
601 desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
606 query vtable_methods(key: ty::PolyTraitRef<'tcx>)
607 -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] {
609 desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) }
614 query codegen_fulfill_obligation(
615 key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
616 ) -> Vtable<'tcx, ()> {
618 cache_on_disk_if { true }
620 "checking if `{}` fulfills its obligations",
621 tcx.def_path_str(key.1.def_id())
627 query trait_impls_of(key: DefId) -> &'tcx ty::trait_def::TraitImpls {
628 desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) }
630 query specialization_graph_of(_: DefId) -> &'tcx specialization_graph::Graph {
631 cache_on_disk_if { true }
633 query is_object_safe(key: DefId) -> bool {
634 desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) }
637 /// Gets the ParameterEnvironment for a given item; this environment
638 /// will be in "user-facing" mode, meaning that it is suitabe for
639 /// type-checking etc, and it does not normalize specializable
640 /// associated types. This is almost always what you want,
641 /// unless you are doing MIR optimizations, in which case you
642 /// might want to use `reveal_all()` method to change modes.
643 query param_env(_: DefId) -> ty::ParamEnv<'tcx> {}
645 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
646 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
647 query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
649 desc { "computing whether `{}` is `Copy`", env.value }
651 query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
653 desc { "computing whether `{}` is `Sized`", env.value }
655 query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
657 desc { "computing whether `{}` is freeze", env.value }
660 // The cycle error here should be reported as an error by `check_representable`.
661 // We consider the type as not needing drop in the meanwhile to avoid
662 // further errors (done in impl Value for NeedsDrop).
663 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
664 // in case we accidentally otherwise don't emit an error.
665 query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> NeedsDrop {
668 desc { "computing whether `{}` needs drop", env.value }
672 env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
673 ) -> Result<&'tcx ty::layout::LayoutDetails, ty::layout::LayoutError<'tcx>> {
675 desc { "computing layout of `{}`", env.value }
680 query dylib_dependency_formats(_: CrateNum)
681 -> &'tcx [(CrateNum, LinkagePreference)] {
682 desc { "dylib dependency formats of crate" }
685 query dependency_formats(_: CrateNum)
686 -> Lrc<crate::middle::dependency_format::Dependencies>
688 desc { "get the linkage format of all dependencies" }
693 query is_compiler_builtins(_: CrateNum) -> bool {
695 desc { "checking if the crate is_compiler_builtins" }
697 query has_global_allocator(_: CrateNum) -> bool {
699 desc { "checking if the crate has_global_allocator" }
701 query has_panic_handler(_: CrateNum) -> bool {
703 desc { "checking if the crate has_panic_handler" }
705 query is_profiler_runtime(_: CrateNum) -> bool {
707 desc { "query a crate is `#![profiler_runtime]`" }
709 query panic_strategy(_: CrateNum) -> PanicStrategy {
711 desc { "query a crate's configured panic strategy" }
713 query is_no_builtins(_: CrateNum) -> bool {
715 desc { "test whether a crate has `#![no_builtins]`" }
717 query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
719 desc { "query a crate's symbol mangling version" }
722 query extern_crate(_: DefId) -> Option<&'tcx ExternCrate> {
724 desc { "getting crate's ExternCrateData" }
729 query specializes(_: (DefId, DefId)) -> bool {
731 desc { "computing whether impls specialize one another" }
733 query in_scope_traits_map(_: DefIndex)
734 -> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> {
736 desc { "traits in scope at a block" }
741 query module_exports(_: DefId) -> Option<&'tcx [Export<hir::HirId>]> {
747 query impl_defaultness(_: DefId) -> hir::Defaultness {}
749 query check_item_well_formed(_: DefId) -> () {}
750 query check_trait_item_well_formed(_: DefId) -> () {}
751 query check_impl_item_well_formed(_: DefId) -> () {}
755 // The `DefId`s of all non-generic functions and statics in the given crate
756 // that can be reached from outside the crate.
758 // We expect this items to be available for being linked to.
760 // This query can also be called for `LOCAL_CRATE`. In this case it will
761 // compute which items will be reachable to other crates, taking into account
762 // the kind of crate that is currently compiled. Crates with only a
763 // C interface have fewer reachable things.
765 // Does not include external symbols that don't have a corresponding DefId,
766 // like the compiler-generated `main` function and so on.
767 query reachable_non_generics(_: CrateNum)
768 -> &'tcx DefIdMap<SymbolExportLevel> {
769 desc { "looking up the exported symbols of a crate" }
771 query is_reachable_non_generic(_: DefId) -> bool {}
772 query is_unreachable_local_definition(_: DefId) -> bool {}
776 query upstream_monomorphizations(
778 ) -> &'tcx DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
779 desc { "collecting available upstream monomorphizations `{:?}`", k }
781 query upstream_monomorphizations_for(_: DefId)
782 -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {}
786 query foreign_modules(_: CrateNum) -> &'tcx [ForeignModule] {
787 desc { "looking up the foreign modules of a linked crate" }
790 /// Identifies the entry-point (e.g., the `main` function) for a given
791 /// crate, returning `None` if there is no entry point (such as for library crates).
792 query entry_fn(_: CrateNum) -> Option<(DefId, EntryFnType)> {
793 desc { "looking up the entry function of a crate" }
795 query plugin_registrar_fn(_: CrateNum) -> Option<DefId> {
796 desc { "looking up the plugin registrar for a crate" }
798 query proc_macro_decls_static(_: CrateNum) -> Option<DefId> {
799 desc { "looking up the derive registrar for a crate" }
801 query crate_disambiguator(_: CrateNum) -> CrateDisambiguator {
803 desc { "looking up the disambiguator a crate" }
805 query crate_hash(_: CrateNum) -> Svh {
807 desc { "looking up the hash a crate" }
809 query crate_host_hash(_: CrateNum) -> Option<Svh> {
811 desc { "looking up the hash of a host version of a crate" }
813 query original_crate_name(_: CrateNum) -> Symbol {
815 desc { "looking up the original name a crate" }
817 query extra_filename(_: CrateNum) -> String {
819 desc { "looking up the extra filename for a crate" }
824 query implementations_of_trait(_: (CrateNum, DefId))
827 desc { "looking up implementations of a trait in a crate" }
829 query all_trait_implementations(_: CrateNum)
831 desc { "looking up all (?) trait implementations" }
836 query dllimport_foreign_items(_: CrateNum)
837 -> &'tcx FxHashSet<DefId> {
838 desc { "dllimport_foreign_items" }
840 query is_dllimport_foreign_item(_: DefId) -> bool {}
841 query is_statically_included_foreign_item(_: DefId) -> bool {}
842 query native_library_kind(_: DefId)
843 -> Option<NativeLibraryKind> {}
847 query link_args(_: CrateNum) -> Lrc<Vec<String>> {
849 desc { "looking up link arguments for a crate" }
854 /// Lifetime resolution. See `middle::resolve_lifetimes`.
855 query resolve_lifetimes(_: CrateNum) -> &'tcx ResolveLifetimes {
856 desc { "resolving lifetimes" }
858 query named_region_map(_: DefIndex) ->
859 Option<&'tcx FxHashMap<ItemLocalId, Region>> {
860 desc { "looking up a named region" }
862 query is_late_bound_map(_: DefIndex) ->
863 Option<&'tcx FxHashSet<ItemLocalId>> {
864 desc { "testing if a region is late bound" }
866 query object_lifetime_defaults_map(_: DefIndex)
867 -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>> {
868 desc { "looking up lifetime defaults for a region" }
873 query visibility(_: DefId) -> ty::Visibility {}
877 query dep_kind(_: CrateNum) -> DepKind {
879 desc { "fetching what a dependency looks like" }
881 query crate_name(_: CrateNum) -> Symbol {
883 desc { "fetching what a crate is named" }
885 query item_children(_: DefId) -> &'tcx [Export<hir::HirId>] {}
886 query extern_mod_stmt_cnum(_: DefId) -> Option<CrateNum> {}
888 query get_lib_features(_: CrateNum) -> &'tcx LibFeatures {
890 desc { "calculating the lib features map" }
892 query defined_lib_features(_: CrateNum)
893 -> &'tcx [(Symbol, Option<Symbol>)] {
894 desc { "calculating the lib features defined in a crate" }
896 /// Returns the lang items defined in another crate by loading it from metadata.
897 // FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid
899 query get_lang_items(_: CrateNum) -> &'tcx LanguageItems {
901 desc { "calculating the lang items map" }
904 /// Returns all diagnostic items defined in all crates.
905 query all_diagnostic_items(_: CrateNum) -> &'tcx FxHashMap<Symbol, DefId> {
907 desc { "calculating the diagnostic items map" }
910 /// Returns the lang items defined in another crate by loading it from metadata.
911 query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
912 desc { "calculating the lang items defined in a crate" }
915 /// Returns the diagnostic items defined in a crate.
916 query diagnostic_items(_: CrateNum) -> &'tcx FxHashMap<Symbol, DefId> {
917 desc { "calculating the diagnostic items map in a crate" }
920 query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
921 desc { "calculating the missing lang items in a crate" }
923 query visible_parent_map(_: CrateNum)
924 -> &'tcx DefIdMap<DefId> {
925 desc { "calculating the visible parent map" }
927 query missing_extern_crate_item(_: CrateNum) -> bool {
929 desc { "seeing if we're missing an `extern crate` item for this crate" }
931 query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
933 desc { "looking at the source for a crate" }
935 query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] {
937 desc { "generating a postorder list of CrateNums" }
940 query upvars(_: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
943 query maybe_unused_trait_import(_: DefId) -> bool {
946 query maybe_unused_extern_crates(_: CrateNum)
947 -> &'tcx [(DefId, Span)] {
949 desc { "looking up all possibly unused extern crates" }
951 query names_imported_by_glob_use(_: DefId)
952 -> Lrc<FxHashSet<ast::Name>> {
956 query stability_index(_: CrateNum) -> &'tcx stability::Index<'tcx> {
958 desc { "calculating the stability index for the local crate" }
960 query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] {
962 desc { "fetching all foreign CrateNum instances" }
965 /// A vector of every trait accessible in the whole crate
966 /// (i.e., including those from subcrates). This is used only for
968 query all_traits(_: CrateNum) -> &'tcx [DefId] {
969 desc { "fetching all foreign and local traits" }
974 query exported_symbols(_: CrateNum)
975 -> Arc<Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)>> {
976 desc { "exported_symbols" }
981 query collect_and_partition_mono_items(_: CrateNum)
982 -> (Arc<DefIdSet>, Arc<Vec<Arc<CodegenUnit<'tcx>>>>) {
984 desc { "collect_and_partition_mono_items" }
986 query is_codegened_item(_: DefId) -> bool {}
987 query codegen_unit(_: Symbol) -> Arc<CodegenUnit<'tcx>> {
989 desc { "codegen_unit" }
991 query backend_optimization_level(_: CrateNum) -> OptLevel {
992 desc { "optimization level used by backend" }
997 query output_filenames(_: CrateNum) -> Arc<OutputFilenames> {
999 desc { "output_filenames" }
1004 /// Do not call this query directly: invoke `normalize` instead.
1005 query normalize_projection_ty(
1006 goal: CanonicalProjectionGoal<'tcx>
1008 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1012 desc { "normalizing `{:?}`", goal }
1015 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1016 query normalize_ty_after_erasing_regions(
1017 goal: ParamEnvAnd<'tcx, Ty<'tcx>>
1020 desc { "normalizing `{:?}`", goal }
1023 query implied_outlives_bounds(
1024 goal: CanonicalTyGoal<'tcx>
1026 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1030 desc { "computing implied outlives bounds for `{:?}`", goal }
1033 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1034 query dropck_outlives(
1035 goal: CanonicalTyGoal<'tcx>
1037 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1041 desc { "computing dropck types for `{:?}`", goal }
1044 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1045 /// `infcx.predicate_must_hold()` instead.
1046 query evaluate_obligation(
1047 goal: CanonicalPredicateGoal<'tcx>
1048 ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1050 desc { "evaluating trait selection obligation `{}`", goal.value.value }
1053 query evaluate_goal(
1054 goal: traits::ChalkCanonicalGoal<'tcx>
1056 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1060 desc { "evaluating trait selection obligation `{}`", goal.value.goal }
1063 /// Do not call this query directly: part of the `Eq` type-op
1064 query type_op_ascribe_user_type(
1065 goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1067 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1071 desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1074 /// Do not call this query directly: part of the `Eq` type-op
1076 goal: CanonicalTypeOpEqGoal<'tcx>
1078 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1082 desc { "evaluating `type_op_eq` `{:?}`", goal }
1085 /// Do not call this query directly: part of the `Subtype` type-op
1086 query type_op_subtype(
1087 goal: CanonicalTypeOpSubtypeGoal<'tcx>
1089 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1093 desc { "evaluating `type_op_subtype` `{:?}`", goal }
1096 /// Do not call this query directly: part of the `ProvePredicate` type-op
1097 query type_op_prove_predicate(
1098 goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1100 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1104 desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1107 /// Do not call this query directly: part of the `Normalize` type-op
1108 query type_op_normalize_ty(
1109 goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1111 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1115 desc { "normalizing `{:?}`", goal }
1118 /// Do not call this query directly: part of the `Normalize` type-op
1119 query type_op_normalize_predicate(
1120 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1122 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1126 desc { "normalizing `{:?}`", goal }
1129 /// Do not call this query directly: part of the `Normalize` type-op
1130 query type_op_normalize_poly_fn_sig(
1131 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1133 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1137 desc { "normalizing `{:?}`", goal }
1140 /// Do not call this query directly: part of the `Normalize` type-op
1141 query type_op_normalize_fn_sig(
1142 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1144 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1148 desc { "normalizing `{:?}`", goal }
1151 query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>, traits::TraitQueryMode)) -> bool {
1154 "testing substituted normalized predicates in mode {:?}:`{}`",
1155 key.2, tcx.def_path_str(key.0)
1159 query method_autoderef_steps(
1160 goal: CanonicalTyGoal<'tcx>
1161 ) -> MethodAutoderefStepsResult<'tcx> {
1163 desc { "computing autoderef types for `{:?}`", goal }
1168 query target_features_whitelist(_: CrateNum) -> &'tcx FxHashMap<String, Option<Symbol>> {
1170 desc { "looking up the whitelist of target features" }
1173 // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1174 query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1177 desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1180 query features_query(_: CrateNum) -> &'tcx rustc_feature::Features {
1182 desc { "looking up enabled feature gates" }