1 // Each of these queries corresponds to a function pointer field in the
2 // `Providers` struct for requesting a value of that type, and a method
3 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
4 // which memoizes and does dep-graph tracking, wrapping around the actual
5 // `Providers` that the driver creates (using several `rustc_*` crates).
7 // The result type of each query must implement `Clone`, and additionally
8 // `ty::query::values::Value`, which produces an appropriate placeholder
9 // (error) value if the query resulted in a query cycle.
10 // Queries marked with `fatal_cycle` do not need the latter implementation,
11 // as they will raise an fatal error on query cycles instead.
13 query trigger_delay_span_bug(key: DefId) -> () {
14 desc { "trigger a delay span bug" }
17 query resolutions(_: ()) -> &'tcx ty::ResolverOutputs {
20 desc { "get the resolver outputs" }
23 /// Return the span for a definition.
24 /// Contrary to `def_span` below, this query returns the full absolute span of the definition.
25 /// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
26 /// of rustc_middle::hir::source_map.
27 query source_span(key: LocalDefId) -> Span {
28 desc { "get the source span" }
31 /// Represents crate as a whole (as distinct from the top-level crate module).
32 /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
33 /// we will have to assume that any change means that you need to be recompiled.
34 /// This is because the `hir_crate` query gives you access to all other items.
35 /// To avoid this fate, do not call `tcx.hir().krate()`; instead,
36 /// prefer wrappers like `tcx.visit_all_items_in_krate()`.
37 query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
39 desc { "get the crate HIR" }
42 /// The items in a module.
44 /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
45 /// Avoid calling this query directly.
46 query hir_module_items(key: LocalDefId) -> rustc_middle::hir::ModuleItems {
47 storage(ArenaCacheSelector<'tcx>)
48 desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
51 /// Gives access to the HIR node for the HIR owner `key`.
53 /// This can be conveniently accessed by methods on `tcx.hir()`.
54 /// Avoid calling this query directly.
55 query hir_owner(key: LocalDefId) -> Option<crate::hir::Owner<'tcx>> {
56 desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
59 /// Gives access to the HIR node's parent for the HIR owner `key`.
61 /// This can be conveniently accessed by methods on `tcx.hir()`.
62 /// Avoid calling this query directly.
63 query hir_owner_parent(key: LocalDefId) -> hir::HirId {
64 desc { |tcx| "HIR parent of `{}`", tcx.def_path_str(key.to_def_id()) }
67 /// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
69 /// This can be conveniently accessed by methods on `tcx.hir()`.
70 /// Avoid calling this query directly.
71 query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx hir::OwnerNodes<'tcx>> {
72 desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
75 /// Gives access to the HIR attributes inside the HIR owner `key`.
77 /// This can be conveniently accessed by methods on `tcx.hir()`.
78 /// Avoid calling this query directly.
79 query hir_attrs(key: LocalDefId) -> &'tcx hir::AttributeMap<'tcx> {
80 desc { |tcx| "HIR owner attributes in `{}`", tcx.def_path_str(key.to_def_id()) }
83 /// Computes the `DefId` of the corresponding const parameter in case the `key` is a
84 /// const argument and returns `None` otherwise.
86 /// ```ignore (incomplete)
87 /// let a = foo::<7>();
88 /// // ^ Calling `opt_const_param_of` for this argument,
90 /// fn foo<const N: usize>()
91 /// // ^ returns this `DefId`.
94 /// // ^ While calling `opt_const_param_of` for other bodies returns `None`.
97 // It looks like caching this query on disk actually slightly
98 // worsened performance in #74376.
100 // Once const generics are more prevalently used, we might want to
101 // consider only caching calls returning `Some`.
102 query opt_const_param_of(key: LocalDefId) -> Option<DefId> {
103 desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) }
106 /// Given the def_id of a const-generic parameter, computes the associated default const
107 /// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
108 query const_param_default(param: DefId) -> &'tcx ty::Const<'tcx> {
109 desc { |tcx| "compute const default for a given parameter `{}`", tcx.def_path_str(param) }
110 separate_provide_extern
113 /// Records the type of every item.
114 query type_of(key: DefId) -> Ty<'tcx> {
118 use rustc_hir::def::DefKind;
119 match tcx.def_kind(key) {
120 DefKind::TyAlias => "expanding type alias",
121 DefKind::TraitAlias => "expanding trait alias",
122 _ => "computing type of",
125 path = tcx.def_path_str(key),
127 cache_on_disk_if { key.is_local() }
128 separate_provide_extern
131 query analysis(key: ()) -> Result<(), ErrorReported> {
133 desc { "running analysis passes on this crate" }
136 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
137 /// associated generics.
138 query generics_of(key: DefId) -> ty::Generics {
139 desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
140 storage(ArenaCacheSelector<'tcx>)
141 cache_on_disk_if { key.is_local() }
142 separate_provide_extern
145 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
146 /// predicates (where-clauses) that must be proven true in order
147 /// to reference it. This is almost always the "predicates query"
150 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
151 /// it is almost always the same as that query, except for the
152 /// case of traits. For traits, `predicates_of` contains
153 /// an additional `Self: Trait<...>` predicate that users don't
154 /// actually write. This reflects the fact that to invoke the
155 /// trait (e.g., via `Default::default`) you must supply types
156 /// that actually implement the trait. (However, this extra
157 /// predicate gets in the way of some checks, which are intended
158 /// to operate over only the actual where-clauses written by the
160 query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
161 desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
162 cache_on_disk_if { key.is_local() }
165 /// Returns the list of bounds that can be used for
166 /// `SelectionCandidate::ProjectionCandidate(_)` and
167 /// `ProjectionTyCandidate::TraitDef`.
168 /// Specifically this is the bounds written on the trait's type
169 /// definition, or those after the `impl` keyword
171 /// ```ignore (incomplete)
172 /// type X: Bound + 'lt
174 /// impl Debug + Display
175 /// // ^^^^^^^^^^^^^^^
178 /// `key` is the `DefId` of the associated type or opaque type.
180 /// Bounds from the parent (e.g. with nested impl trait) are not included.
181 query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
182 desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
183 separate_provide_extern
186 /// Elaborated version of the predicates from `explicit_item_bounds`.
192 /// type MyAType: Eq + ?Sized;
196 /// `explicit_item_bounds` returns `[<Self as MyTrait>::MyAType: Eq]`,
197 /// and `item_bounds` returns
200 /// <Self as Trait>::MyAType: Eq,
201 /// <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
205 /// Bounds from the parent (e.g. with nested impl trait) are not included.
206 query item_bounds(key: DefId) -> &'tcx ty::List<ty::Predicate<'tcx>> {
207 desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
210 query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLib>> {
211 desc { "looking up the native libraries of a linked crate" }
212 separate_provide_extern
215 query lint_levels(_: ()) -> LintLevelMap {
216 storage(ArenaCacheSelector<'tcx>)
218 desc { "computing the lint levels for items in this crate" }
221 query parent_module_from_def_id(key: LocalDefId) -> LocalDefId {
223 desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) }
226 query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
227 // This query reads from untracked data in definitions.
229 desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) }
230 separate_provide_extern
233 query is_panic_runtime(_: CrateNum) -> bool {
235 desc { "checking if the crate is_panic_runtime" }
236 separate_provide_extern
239 /// Fetch the THIR for a given body. If typeck for that body failed, returns an empty `Thir`.
240 query thir_body(key: ty::WithOptConstParam<LocalDefId>) -> (&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId) {
241 // Perf tests revealed that hashing THIR is inefficient (see #85729).
243 desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
246 /// Create a THIR tree for debugging.
247 query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String {
249 desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) }
252 /// Set of all the `DefId`s in this crate that have MIR associated with
253 /// them. This includes all the body owners, but also things like struct
255 query mir_keys(_: ()) -> rustc_data_structures::fx::FxIndexSet<LocalDefId> {
256 storage(ArenaCacheSelector<'tcx>)
257 desc { "getting a list of all mir_keys" }
260 /// Maps DefId's that have an associated `mir::Body` to the result
261 /// of the MIR const-checking pass. This is the set of qualifs in
262 /// the final value of a `const`.
263 query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
264 desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
265 cache_on_disk_if { key.is_local() }
266 separate_provide_extern
268 query mir_const_qualif_const_arg(
269 key: (LocalDefId, DefId)
270 ) -> mir::ConstQualifs {
272 |tcx| "const checking the const argument `{}`",
273 tcx.def_path_str(key.0.to_def_id())
277 /// Fetch the MIR for a given `DefId` right after it's built - this includes
278 /// unreachable code.
279 query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
280 desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
283 /// Fetch the MIR for a given `DefId` up till the point where it is
284 /// ready for const qualification.
286 /// See the README for the `mir` module for details.
287 query mir_const(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
289 |tcx| "processing MIR for {}`{}`",
290 if key.const_param_did.is_some() { "the const argument " } else { "" },
291 tcx.def_path_str(key.did.to_def_id()),
296 /// Try to build an abstract representation of the given constant.
297 query thir_abstract_const(
299 ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
301 |tcx| "building an abstract representation for {}", tcx.def_path_str(key),
303 separate_provide_extern
305 /// Try to build an abstract representation of the given constant.
306 query thir_abstract_const_of_const_arg(
307 key: (LocalDefId, DefId)
308 ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
311 "building an abstract representation for the const argument {}",
312 tcx.def_path_str(key.0.to_def_id()),
316 query try_unify_abstract_consts(key: (
317 ty::Unevaluated<'tcx, ()>, ty::Unevaluated<'tcx, ()>
320 |tcx| "trying to unify the generic constants {} and {}",
321 tcx.def_path_str(key.0.def.did), tcx.def_path_str(key.1.def.did)
325 query mir_drops_elaborated_and_const_checked(
326 key: ty::WithOptConstParam<LocalDefId>
327 ) -> &'tcx Steal<mir::Body<'tcx>> {
329 desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) }
334 ) -> &'tcx mir::Body<'tcx> {
335 desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) }
336 cache_on_disk_if { key.is_local() }
337 separate_provide_extern
340 query mir_for_ctfe_of_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::Body<'tcx> {
342 |tcx| "MIR for CTFE of the const argument `{}`",
343 tcx.def_path_str(key.0.to_def_id())
347 query mir_promoted(key: ty::WithOptConstParam<LocalDefId>) ->
349 &'tcx Steal<mir::Body<'tcx>>,
350 &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
354 |tcx| "processing {}`{}`",
355 if key.const_param_did.is_some() { "the const argument " } else { "" },
356 tcx.def_path_str(key.did.to_def_id()),
360 query symbols_for_closure_captures(
361 key: (LocalDefId, DefId)
362 ) -> Vec<rustc_span::Symbol> {
364 |tcx| "symbols for captures of closure `{}` in `{}`",
365 tcx.def_path_str(key.1),
366 tcx.def_path_str(key.0.to_def_id())
370 /// MIR after our optimization passes have run. This is MIR that is ready
371 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
372 query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
373 desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) }
374 cache_on_disk_if { key.is_local() }
375 separate_provide_extern
378 /// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
379 /// MIR pass (assuming the -Zinstrument-coverage option is enabled).
380 query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
381 desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
382 storage(ArenaCacheSelector<'tcx>)
385 /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
386 /// function was optimized out before codegen, and before being added to the Coverage Map.
387 query covered_code_regions(key: DefId) -> Vec<&'tcx mir::coverage::CodeRegion> {
389 |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
390 tcx.def_path_str(key)
392 storage(ArenaCacheSelector<'tcx>)
393 cache_on_disk_if { key.is_local() }
396 /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
397 /// `DefId`. This function returns all promoteds in the specified body. The body references
398 /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
399 /// after inlining a body may refer to promoteds from other bodies. In that case you still
400 /// need to use the `DefId` of the original body.
401 query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
402 desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) }
403 cache_on_disk_if { key.is_local() }
404 separate_provide_extern
406 query promoted_mir_of_const_arg(
407 key: (LocalDefId, DefId)
408 ) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
410 |tcx| "optimizing promoted MIR for the const argument `{}`",
411 tcx.def_path_str(key.0.to_def_id()),
415 /// Erases regions from `ty` to yield a new type.
416 /// Normally you would just use `tcx.erase_regions(value)`,
417 /// however, which uses this query as a kind of cache.
418 query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
419 // This query is not expected to have input -- as a result, it
420 // is not a good candidates for "replay" because it is essentially a
421 // pure function of its input (and hence the expectation is that
422 // no caller would be green **apart** from just these
423 // queries). Making it anonymous avoids hashing the result, which
424 // may save a bit of time.
426 desc { "erasing regions from `{:?}`", ty }
429 query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
430 storage(ArenaCacheSelector<'tcx>)
431 desc { "wasm import module map" }
434 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
435 /// predicates (where-clauses) directly defined on it. This is
436 /// equal to the `explicit_predicates_of` predicates plus the
437 /// `inferred_outlives_of` predicates.
438 query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> {
439 desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
442 /// Returns everything that looks like a predicate written explicitly
443 /// by the user on a trait item.
445 /// Traits are unusual, because predicates on associated types are
446 /// converted into bounds on that type for backwards compatibility:
448 /// trait X where Self::U: Copy { type U; }
452 /// trait X { type U: Copy; }
454 /// `explicit_predicates_of` and `explicit_item_bounds` will then take
455 /// the appropriate subsets of the predicates here.
456 query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
457 desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key.to_def_id()) }
460 /// Returns the predicates written explicitly by the user.
461 query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
462 desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) }
463 separate_provide_extern
466 /// Returns the inferred outlives predicates (e.g., for `struct
467 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
468 query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
469 desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) }
470 separate_provide_extern
473 /// Maps from the `DefId` of a trait to the list of
474 /// super-predicates. This is a subset of the full list of
475 /// predicates. We store these in a separate map because we must
476 /// evaluate them even during type conversion, often before the
477 /// full predicates are available (note that supertraits have
478 /// additional acyclicity requirements).
479 query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
480 desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
481 separate_provide_extern
484 /// The `Option<Ident>` is the name of an associated type. If it is `None`, then this query
485 /// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
486 /// subset of super-predicates that reference traits that define the given associated type.
487 /// This is used to avoid cycles in resolving types like `T::Item`.
488 query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
489 desc { |tcx| "computing the super traits of `{}`{}",
490 tcx.def_path_str(key.0),
491 if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
495 /// To avoid cycles within the predicates of a single item we compute
496 /// per-type-parameter predicates for resolving `T::AssocTy`.
497 query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
498 desc { |tcx| "computing the bounds for type parameter `{}`", {
499 let id = tcx.hir().local_def_id_to_hir_id(key.1);
500 tcx.hir().ty_param_name(id)
504 query trait_def(key: DefId) -> ty::TraitDef {
505 desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
506 storage(ArenaCacheSelector<'tcx>)
507 separate_provide_extern
509 query adt_def(key: DefId) -> &'tcx ty::AdtDef {
510 desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) }
511 cache_on_disk_if { key.is_local() }
512 separate_provide_extern
514 query adt_destructor(key: DefId) -> Option<ty::Destructor> {
515 desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) }
516 separate_provide_extern
519 // The cycle error here should be reported as an error by `check_representable`.
520 // We consider the type as Sized in the meanwhile to avoid
521 // further errors (done in impl Value for AdtSizedConstraint).
522 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
523 // in case we accidentally otherwise don't emit an error.
524 query adt_sized_constraint(
526 ) -> AdtSizedConstraint<'tcx> {
527 desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
531 query adt_dtorck_constraint(
533 ) -> Result<DtorckConstraint<'tcx>, NoSolution> {
534 desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
537 /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
538 /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
539 /// not have the feature gate active).
541 /// **Do not call this function manually.** It is only meant to cache the base data for the
542 /// `is_const_fn` function.
543 query is_const_fn_raw(key: DefId) -> bool {
544 desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
545 separate_provide_extern
548 query asyncness(key: DefId) -> hir::IsAsync {
549 desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
550 separate_provide_extern
553 /// Returns `true` if calls to the function may be promoted.
555 /// This is either because the function is e.g., a tuple-struct or tuple-variant
556 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
557 /// be removed in the future in favour of some form of check which figures out whether the
558 /// function does not inspect the bits of any of its arguments (so is essentially just a
559 /// constructor function).
560 query is_promotable_const_fn(key: DefId) -> bool {
561 desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
564 /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
565 query is_foreign_item(key: DefId) -> bool {
566 desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) }
567 separate_provide_extern
570 /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
571 query static_mutability(def_id: DefId) -> Option<hir::Mutability> {
572 desc { |tcx| "looking up static mutability of `{}`", tcx.def_path_str(def_id) }
573 separate_provide_extern
576 /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
577 query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
578 desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) }
579 separate_provide_extern
582 /// Gets a map with the variance of every item; use `item_variance` instead.
583 query crate_variances(_: ()) -> ty::CrateVariancesMap<'tcx> {
584 storage(ArenaCacheSelector<'tcx>)
585 desc { "computing the variances for items in this crate" }
588 /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
589 query variances_of(def_id: DefId) -> &'tcx [ty::Variance] {
590 desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) }
591 separate_provide_extern
594 /// Maps from thee `DefId` of a type to its (inferred) outlives.
595 query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> {
596 storage(ArenaCacheSelector<'tcx>)
597 desc { "computing the inferred outlives predicates for items in this crate" }
600 /// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
601 query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
602 desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
603 separate_provide_extern
606 /// Maps from a trait item to the trait item "descriptor".
607 query associated_item(key: DefId) -> ty::AssocItem {
608 desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
609 storage(ArenaCacheSelector<'tcx>)
610 separate_provide_extern
613 /// Collects the associated items defined on a trait or impl.
614 query associated_items(key: DefId) -> ty::AssocItems<'tcx> {
615 storage(ArenaCacheSelector<'tcx>)
616 desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
619 /// Maps from associated items on a trait to the corresponding associated
620 /// item on the impl specified by `impl_id`.
622 /// For example, with the following code
627 /// trait Trait { // trait_id
628 /// fn f(); // trait_f
629 /// fn g() {} // trait_g
632 /// impl Trait for Type { // impl_id
633 /// fn f() {} // impl_f
634 /// fn g() {} // impl_g
638 /// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
639 ///`{ trait_f: impl_f, trait_g: impl_g }`
640 query impl_item_implementor_ids(impl_id: DefId) -> FxHashMap<DefId, DefId> {
641 desc { |tcx| "comparing impl items against trait for {}", tcx.def_path_str(impl_id) }
642 storage(ArenaCacheSelector<'tcx>)
645 /// Given an `impl_id`, return the trait it implements.
646 /// Return `None` if this is an inherent impl.
647 query impl_trait_ref(impl_id: DefId) -> Option<ty::TraitRef<'tcx>> {
648 desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
649 separate_provide_extern
651 query impl_polarity(impl_id: DefId) -> ty::ImplPolarity {
652 desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) }
653 separate_provide_extern
656 query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> {
657 desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
660 /// Maps a `DefId` of a type to a list of its inherent impls.
661 /// Contains implementations of methods that are inherent to a type.
662 /// Methods in these implementations don't need to be exported.
663 query inherent_impls(key: DefId) -> &'tcx [DefId] {
664 desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) }
665 separate_provide_extern
668 /// The result of unsafety-checking this `LocalDefId`.
669 query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
670 desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
671 cache_on_disk_if { true }
673 query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult {
675 |tcx| "unsafety-checking the const argument `{}`",
676 tcx.def_path_str(key.0.to_def_id())
680 /// Unsafety-check this `LocalDefId` with THIR unsafeck. This should be
681 /// used with `-Zthir-unsafeck`.
682 query thir_check_unsafety(key: LocalDefId) {
683 desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
684 cache_on_disk_if { true }
686 query thir_check_unsafety_for_const_arg(key: (LocalDefId, DefId)) {
688 |tcx| "unsafety-checking the const argument `{}`",
689 tcx.def_path_str(key.0.to_def_id())
693 /// HACK: when evaluated, this reports an "unsafe derive on repr(packed)" error.
695 /// Unsafety checking is executed for each method separately, but we only want
696 /// to emit this error once per derive. As there are some impls with multiple
697 /// methods, we use a query for deduplication.
698 query unsafe_derive_on_repr_packed(key: LocalDefId) -> () {
699 desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
702 /// Computes the signature of the function.
703 query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> {
704 desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
705 separate_provide_extern
708 /// Performs lint checking for the module.
709 query lint_mod(key: LocalDefId) -> () {
710 desc { |tcx| "linting {}", describe_as_module(key, tcx) }
713 /// Checks the attributes in the module.
714 query check_mod_attrs(key: LocalDefId) -> () {
715 desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
718 /// Checks for uses of unstable APIs in the module.
719 query check_mod_unstable_api_usage(key: LocalDefId) -> () {
720 desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
723 /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
724 query check_mod_const_bodies(key: LocalDefId) -> () {
725 desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
728 /// Checks the loops in the module.
729 query check_mod_loops(key: LocalDefId) -> () {
730 desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
733 query check_mod_naked_functions(key: LocalDefId) -> () {
734 desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
737 query check_mod_item_types(key: LocalDefId) -> () {
738 desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) }
741 query check_mod_privacy(key: LocalDefId) -> () {
742 desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) }
745 query check_mod_intrinsics(key: LocalDefId) -> () {
746 desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) }
749 query check_mod_liveness(key: LocalDefId) -> () {
750 desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) }
753 query check_mod_impl_wf(key: LocalDefId) -> () {
754 desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
757 query collect_mod_item_types(key: LocalDefId) -> () {
758 desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
761 /// Caches `CoerceUnsized` kinds for impls on custom types.
762 query coerce_unsized_info(key: DefId) -> ty::adjustment::CoerceUnsizedInfo {
763 desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
764 separate_provide_extern
767 query typeck_item_bodies(_: ()) -> () {
768 desc { "type-checking all item bodies" }
771 query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
772 desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
773 cache_on_disk_if { true }
775 query typeck_const_arg(
776 key: (LocalDefId, DefId)
777 ) -> &'tcx ty::TypeckResults<'tcx> {
779 |tcx| "type-checking the const argument `{}`",
780 tcx.def_path_str(key.0.to_def_id()),
783 query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
784 desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
785 cache_on_disk_if { true }
786 load_cached(tcx, id) {
789 match match tcx.on_disk_cache().as_ref() {
790 Some(c) => c.try_load_query_result(*tcx, id),
793 Some(x) => Some(&*tcx.arena.alloc(x)),
797 #[cfg(not(bootstrap))]
799 let typeck_results: Option<ty::TypeckResults<'tcx>> = tcx
800 .on_disk_cache().as_ref()
801 .and_then(|c| c.try_load_query_result(*tcx, id));
803 typeck_results.map(|x| &*tcx.arena.alloc(x))
808 query used_trait_imports(key: LocalDefId) -> &'tcx FxHashSet<LocalDefId> {
809 desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) }
810 cache_on_disk_if { true }
813 query has_typeck_results(def_id: DefId) -> bool {
814 desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) }
817 query coherent_trait(def_id: DefId) -> () {
818 desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
821 /// Borrow-checks the function body. If this is a closure, returns
822 /// additional requirements that the closure's creator must verify.
823 query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
824 desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
825 cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }
827 query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> {
829 |tcx| "borrow-checking the const argument`{}`",
830 tcx.def_path_str(key.0.to_def_id())
834 /// Gets a complete map from all types to their inherent impls.
835 /// Not meant to be used directly outside of coherence.
836 query crate_inherent_impls(k: ()) -> CrateInherentImpls {
837 storage(ArenaCacheSelector<'tcx>)
838 desc { "all inherent impls defined in crate" }
841 /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
842 /// Not meant to be used directly outside of coherence.
843 query crate_inherent_impls_overlap_check(_: ()) -> () {
844 desc { "check for overlap between inherent impls defined in this crate" }
847 /// Checks whether all impls in the crate pass the overlap check, returning
848 /// which impls fail it. If all impls are correct, the returned slice is empty.
849 query orphan_check_crate(_: ()) -> &'tcx [LocalDefId] {
851 "checking whether the immpl in the this crate follow the orphan rules",
855 /// Check whether the function has any recursion that could cause the inliner to trigger
856 /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
857 /// current function, just all intermediate functions.
858 query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool {
861 "computing if `{}` (transitively) calls `{}`",
863 tcx.def_path_str(key.1.to_def_id()),
867 /// Obtain all the calls into other local functions
868 query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] {
871 "computing all local function calls in `{}`",
872 tcx.def_path_str(key.def_id()),
876 /// Evaluates a constant and returns the computed allocation.
878 /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper.
879 query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
880 -> EvalToAllocationRawResult<'tcx> {
882 "const-evaluating + checking `{}`",
883 key.value.display(tcx)
885 cache_on_disk_if { true }
888 /// Evaluates const items or anonymous constants
889 /// (such as enum variant explicit discriminants or array lengths)
890 /// into a representation suitable for the type system and const generics.
892 /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
893 /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
894 query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
895 -> EvalToConstValueResult<'tcx> {
897 "simplifying constant for the type system `{}`",
898 key.value.display(tcx)
900 cache_on_disk_if { true }
903 /// Convert an evaluated constant to a type level constant or
904 /// return `None` if that is not possible.
905 query const_to_valtree(
906 key: ty::ParamEnvAnd<'tcx, ConstAlloc<'tcx>>
907 ) -> Option<ty::ValTree<'tcx>> {
908 desc { "destructure constant" }
912 /// Destructure a constant ADT or array into its variant index and its
914 query destructure_const(
915 key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
916 ) -> mir::DestructuredConst<'tcx> {
917 desc { "destructure constant" }
921 /// Dereference a constant reference or raw pointer and turn the result into a constant
924 key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
925 ) -> &'tcx ty::Const<'tcx> {
926 desc { "deref constant" }
930 query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
931 desc { "get a &core::panic::Location referring to a span" }
935 key: LitToConstInput<'tcx>
936 ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
937 desc { "converting literal to const" }
940 query check_match(key: DefId) {
941 desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
942 cache_on_disk_if { key.is_local() }
945 /// Performs part of the privacy check and computes "access levels".
946 query privacy_access_levels(_: ()) -> &'tcx AccessLevels {
948 desc { "privacy access levels" }
950 query check_private_in_public(_: ()) -> () {
952 desc { "checking for private elements in public interfaces" }
955 query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
956 storage(ArenaCacheSelector<'tcx>)
957 desc { "reachability" }
960 /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
961 /// in the case of closures, this will be redirected to the enclosing function.
962 query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree {
963 desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
966 /// Generates a MIR body for the shim.
967 query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
968 storage(ArenaCacheSelector<'tcx>)
969 desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
972 /// The `symbol_name` query provides the symbol name for calling a
973 /// given instance from the local crate. In particular, it will also
974 /// look up the correct symbol name of instances from upstream crates.
975 query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
976 desc { "computing the symbol for `{}`", key }
977 cache_on_disk_if { true }
980 query opt_def_kind(def_id: DefId) -> Option<DefKind> {
981 desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
982 separate_provide_extern
985 /// Gets the span for the definition.
986 query def_span(def_id: DefId) -> Span {
987 desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
988 separate_provide_extern
991 /// Gets the span for the identifier of the definition.
992 query def_ident_span(def_id: DefId) -> Option<Span> {
993 desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
994 separate_provide_extern
997 query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> {
998 desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
999 separate_provide_extern
1002 query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> {
1003 desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
1004 separate_provide_extern
1007 query should_inherit_track_caller(def_id: DefId) -> bool {
1008 desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) }
1011 query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
1012 desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
1013 separate_provide_extern
1016 query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] {
1017 desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
1018 separate_provide_extern
1021 query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
1022 desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
1023 storage(ArenaCacheSelector<'tcx>)
1024 cache_on_disk_if { true }
1027 query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
1028 desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
1029 separate_provide_extern
1031 /// Gets the rendered value of the specified constant or associated constant.
1032 /// Used by rustdoc.
1033 query rendered_const(def_id: DefId) -> String {
1034 desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) }
1035 separate_provide_extern
1037 query impl_parent(def_id: DefId) -> Option<DefId> {
1038 desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
1039 separate_provide_extern
1042 /// Given an `associated_item`, find the trait it belongs to.
1043 /// Return `None` if the `DefId` is not an associated item.
1044 query trait_of_item(associated_item: DefId) -> Option<DefId> {
1045 desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(associated_item) }
1046 separate_provide_extern
1049 query is_ctfe_mir_available(key: DefId) -> bool {
1050 desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx.def_path_str(key) }
1051 separate_provide_extern
1053 query is_mir_available(key: DefId) -> bool {
1054 desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
1055 separate_provide_extern
1058 query own_existential_vtable_entries(
1059 key: ty::PolyExistentialTraitRef<'tcx>
1060 ) -> &'tcx [DefId] {
1061 desc { |tcx| "finding all existential vtable entries for trait {}", tcx.def_path_str(key.def_id()) }
1064 query vtable_entries(key: ty::PolyTraitRef<'tcx>)
1065 -> &'tcx [ty::VtblEntry<'tcx>] {
1066 desc { |tcx| "finding all vtable entries for trait {}", tcx.def_path_str(key.def_id()) }
1069 query vtable_trait_upcasting_coercion_new_vptr_slot(key: (ty::Ty<'tcx>, ty::Ty<'tcx>)) -> Option<usize> {
1070 desc { |tcx| "finding the slot within vtable for trait object {} vtable ptr during trait upcasting coercion from {} vtable",
1074 query vtable_allocation(key: (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>)) -> mir::interpret::AllocId {
1075 desc { |tcx| "vtable const allocation for <{} as {}>",
1077 key.1.map(|trait_ref| format!("{}", trait_ref)).unwrap_or("_".to_owned())
1081 query codegen_fulfill_obligation(
1082 key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
1083 ) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
1084 cache_on_disk_if { true }
1086 "checking if `{}` fulfills its obligations",
1087 tcx.def_path_str(key.1.def_id())
1091 /// Return all `impl` blocks in the current crate.
1092 query all_local_trait_impls(_: ()) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
1093 desc { "local trait impls" }
1096 /// Given a trait `trait_id`, return all known `impl` blocks.
1097 query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls {
1098 storage(ArenaCacheSelector<'tcx>)
1099 desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) }
1102 query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph {
1103 storage(ArenaCacheSelector<'tcx>)
1104 desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
1105 cache_on_disk_if { true }
1107 query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
1108 desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(trait_id) }
1111 /// Gets the ParameterEnvironment for a given item; this environment
1112 /// will be in "user-facing" mode, meaning that it is suitable for
1113 /// type-checking etc, and it does not normalize specializable
1114 /// associated types. This is almost always what you want,
1115 /// unless you are doing MIR optimizations, in which case you
1116 /// might want to use `reveal_all()` method to change modes.
1117 query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
1118 desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
1121 /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
1122 /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
1123 /// as this method is more efficient.
1124 query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
1125 desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
1128 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
1129 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
1130 query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1131 desc { "computing whether `{}` is `Copy`", env.value }
1134 /// Query backing `TyS::is_sized`.
1135 query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1136 desc { "computing whether `{}` is `Sized`", env.value }
1139 /// Query backing `TyS::is_freeze`.
1140 query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1141 desc { "computing whether `{}` is freeze", env.value }
1144 /// Query backing `TyS::is_unpin`.
1145 query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1146 desc { "computing whether `{}` is `Unpin`", env.value }
1149 /// Query backing `TyS::needs_drop`.
1150 query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1151 desc { "computing whether `{}` needs drop", env.value }
1154 /// Query backing `TyS::has_significant_drop_raw`.
1155 query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1156 desc { "computing whether `{}` has a significant drop", env.value }
1160 /// Query backing `TyS::is_structural_eq_shallow`.
1162 /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1164 query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1166 "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`",
1171 /// A list of types where the ADT requires drop if and only if any of
1172 /// those types require drop. If the ADT is known to always need drop
1173 /// then `Err(AlwaysRequiresDrop)` is returned.
1174 query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1175 desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
1176 cache_on_disk_if { true }
1179 /// A list of types where the ADT requires drop if and only if any of those types
1180 /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
1181 /// is considered to not be significant. A drop is significant if it is implemented
1182 /// by the user or does anything that will have any observable behavior (other than
1183 /// freeing up memory). If the ADT is known to have a significant destructor then
1184 /// `Err(AlwaysRequiresDrop)` is returned.
1185 query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1186 desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
1187 cache_on_disk_if { false }
1190 /// Computes the layout of a type. Note that this implicitly
1191 /// executes in "reveal all" mode, and will normalize the input type.
1193 key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1194 ) -> Result<ty::layout::TyAndLayout<'tcx>, ty::layout::LayoutError<'tcx>> {
1195 desc { "computing layout of `{}`", key.value }
1199 /// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
1201 /// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
1202 /// instead, where the instance is an `InstanceDef::Virtual`.
1203 query fn_abi_of_fn_ptr(
1204 key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1205 ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1206 desc { "computing call ABI of `{}` function pointers", key.value.0 }
1210 /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
1211 /// direct calls to an `fn`.
1213 /// NB: that includes virtual calls, which are represented by "direct calls"
1214 /// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
1215 query fn_abi_of_instance(
1216 key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1217 ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1218 desc { "computing call ABI of `{}`", key.value.0 }
1222 query dylib_dependency_formats(_: CrateNum)
1223 -> &'tcx [(CrateNum, LinkagePreference)] {
1224 desc { "dylib dependency formats of crate" }
1225 separate_provide_extern
1228 query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
1229 desc { "get the linkage format of all dependencies" }
1232 query is_compiler_builtins(_: CrateNum) -> bool {
1234 desc { "checking if the crate is_compiler_builtins" }
1235 separate_provide_extern
1237 query has_global_allocator(_: CrateNum) -> bool {
1238 // This query depends on untracked global state in CStore
1241 desc { "checking if the crate has_global_allocator" }
1242 separate_provide_extern
1244 query has_panic_handler(_: CrateNum) -> bool {
1246 desc { "checking if the crate has_panic_handler" }
1247 separate_provide_extern
1249 query is_profiler_runtime(_: CrateNum) -> bool {
1251 desc { "query a crate is `#![profiler_runtime]`" }
1252 separate_provide_extern
1254 query panic_strategy(_: CrateNum) -> PanicStrategy {
1256 desc { "query a crate's configured panic strategy" }
1257 separate_provide_extern
1259 query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
1261 desc { "query a crate's configured panic-in-drop strategy" }
1262 separate_provide_extern
1264 query is_no_builtins(_: CrateNum) -> bool {
1266 desc { "test whether a crate has `#![no_builtins]`" }
1267 separate_provide_extern
1269 query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1271 desc { "query a crate's symbol mangling version" }
1272 separate_provide_extern
1275 query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
1277 desc { "getting crate's ExternCrateData" }
1278 separate_provide_extern
1281 query specializes(_: (DefId, DefId)) -> bool {
1282 desc { "computing whether impls specialize one another" }
1284 query in_scope_traits_map(_: LocalDefId)
1285 -> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> {
1286 desc { "traits in scope at a block" }
1289 query module_reexports(def_id: LocalDefId) -> Option<&'tcx [ModChild]> {
1290 desc { |tcx| "looking up reexports of module `{}`", tcx.def_path_str(def_id.to_def_id()) }
1293 query impl_defaultness(def_id: DefId) -> hir::Defaultness {
1294 desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
1295 separate_provide_extern
1298 query impl_constness(def_id: DefId) -> hir::Constness {
1299 desc { |tcx| "looking up whether `{}` is a const impl", tcx.def_path_str(def_id) }
1300 separate_provide_extern
1303 query check_item_well_formed(key: LocalDefId) -> () {
1304 desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1306 query check_trait_item_well_formed(key: LocalDefId) -> () {
1307 desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1309 query check_impl_item_well_formed(key: LocalDefId) -> () {
1310 desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1313 // The `DefId`s of all non-generic functions and statics in the given crate
1314 // that can be reached from outside the crate.
1316 // We expect this items to be available for being linked to.
1318 // This query can also be called for `LOCAL_CRATE`. In this case it will
1319 // compute which items will be reachable to other crates, taking into account
1320 // the kind of crate that is currently compiled. Crates with only a
1321 // C interface have fewer reachable things.
1323 // Does not include external symbols that don't have a corresponding DefId,
1324 // like the compiler-generated `main` function and so on.
1325 query reachable_non_generics(_: CrateNum)
1326 -> DefIdMap<SymbolExportLevel> {
1327 storage(ArenaCacheSelector<'tcx>)
1328 desc { "looking up the exported symbols of a crate" }
1329 separate_provide_extern
1331 query is_reachable_non_generic(def_id: DefId) -> bool {
1332 desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
1333 separate_provide_extern
1335 query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
1337 "checking whether `{}` is reachable from outside the crate",
1338 tcx.def_path_str(def_id.to_def_id()),
1342 /// The entire set of monomorphizations the local crate can safely link
1343 /// to because they are exported from upstream crates. Do not depend on
1344 /// this directly, as its value changes anytime a monomorphization gets
1345 /// added or removed in any upstream crate. Instead use the narrower
1346 /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
1347 /// better, `Instance::upstream_monomorphization()`.
1348 query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1349 storage(ArenaCacheSelector<'tcx>)
1350 desc { "collecting available upstream monomorphizations" }
1353 /// Returns the set of upstream monomorphizations available for the
1354 /// generic function identified by the given `def_id`. The query makes
1355 /// sure to make a stable selection if the same monomorphization is
1356 /// available in multiple upstream crates.
1358 /// You likely want to call `Instance::upstream_monomorphization()`
1359 /// instead of invoking this query directly.
1360 query upstream_monomorphizations_for(def_id: DefId)
1361 -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1363 "collecting available upstream monomorphizations for `{}`",
1364 tcx.def_path_str(def_id),
1366 separate_provide_extern
1369 /// Returns the upstream crate that exports drop-glue for the given
1370 /// type (`substs` is expected to be a single-item list containing the
1371 /// type one wants drop-glue for).
1373 /// This is a subset of `upstream_monomorphizations_for` in order to
1374 /// increase dep-tracking granularity. Otherwise adding or removing any
1375 /// type with drop-glue in any upstream crate would invalidate all
1376 /// functions calling drop-glue of an upstream type.
1378 /// You likely want to call `Instance::upstream_monomorphization()`
1379 /// instead of invoking this query directly.
1381 /// NOTE: This query could easily be extended to also support other
1382 /// common functions that have are large set of monomorphizations
1383 /// (like `Clone::clone` for example).
1384 query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
1385 desc { "available upstream drop-glue for `{:?}`", substs }
1388 query foreign_modules(_: CrateNum) -> Lrc<FxHashMap<DefId, ForeignModule>> {
1389 desc { "looking up the foreign modules of a linked crate" }
1390 separate_provide_extern
1393 /// Identifies the entry-point (e.g., the `main` function) for a given
1394 /// crate, returning `None` if there is no entry point (such as for library crates).
1395 query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
1396 desc { "looking up the entry function of a crate" }
1398 query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1399 desc { "looking up the derive registrar for a crate" }
1401 // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1402 // Changing the name should cause a compiler error, but in case that changes, be aware.
1403 query crate_hash(_: CrateNum) -> Svh {
1405 desc { "looking up the hash a crate" }
1406 separate_provide_extern
1408 query crate_host_hash(_: CrateNum) -> Option<Svh> {
1410 desc { "looking up the hash of a host version of a crate" }
1411 separate_provide_extern
1413 query extra_filename(_: CrateNum) -> String {
1415 desc { "looking up the extra filename for a crate" }
1416 separate_provide_extern
1418 query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
1420 desc { "looking up the paths for extern crates" }
1421 separate_provide_extern
1424 /// Given a crate and a trait, look up all impls of that trait in the crate.
1425 /// Return `(impl_id, self_ty)`.
1426 query implementations_of_trait(_: (CrateNum, DefId)) -> &'tcx [(DefId, Option<SimplifiedType>)] {
1427 desc { "looking up implementations of a trait in a crate" }
1428 separate_provide_extern
1431 query is_dllimport_foreign_item(def_id: DefId) -> bool {
1432 desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) }
1434 query is_statically_included_foreign_item(def_id: DefId) -> bool {
1435 desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) }
1437 query native_library_kind(def_id: DefId)
1438 -> Option<NativeLibKind> {
1439 desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) }
1442 /// Does lifetime resolution, but does not descend into trait items. This
1443 /// should only be used for resolving lifetimes of on trait definitions,
1444 /// and is used to avoid cycles. Importantly, `resolve_lifetimes` still visits
1445 /// the same lifetimes and is responsible for diagnostics.
1446 /// See `rustc_resolve::late::lifetimes for details.
1447 query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes {
1448 storage(ArenaCacheSelector<'tcx>)
1449 desc { "resolving lifetimes for a trait definition" }
1451 /// Does lifetime resolution on items. Importantly, we can't resolve
1452 /// lifetimes directly on things like trait methods, because of trait params.
1453 /// See `rustc_resolve::late::lifetimes for details.
1454 query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
1455 storage(ArenaCacheSelector<'tcx>)
1456 desc { "resolving lifetimes" }
1458 query named_region_map(_: LocalDefId) ->
1459 Option<&'tcx FxHashMap<ItemLocalId, Region>> {
1460 desc { "looking up a named region" }
1462 query is_late_bound_map(_: LocalDefId) ->
1463 Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
1464 desc { "testing if a region is late bound" }
1466 /// For a given item (like a struct), gets the default lifetimes to be used
1467 /// for each parameter if a trait object were to be passed for that parameter.
1468 /// For example, for `struct Foo<'a, T, U>`, this would be `['static, 'static]`.
1469 /// For `struct Foo<'a, T: 'a, U>`, this would instead be `['a, 'static]`.
1470 query object_lifetime_defaults_map(_: LocalDefId)
1471 -> Option<Vec<ObjectLifetimeDefault>> {
1472 desc { "looking up lifetime defaults for a region on an item" }
1474 query late_bound_vars_map(_: LocalDefId)
1475 -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
1476 desc { "looking up late bound vars" }
1479 query lifetime_scope_map(_: LocalDefId) -> Option<FxHashMap<ItemLocalId, LifetimeScopeForPath>> {
1480 desc { "finds the lifetime scope for an HirId of a PathSegment" }
1483 query visibility(def_id: DefId) -> ty::Visibility {
1484 desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
1485 separate_provide_extern
1488 /// Computes the set of modules from which this type is visibly uninhabited.
1489 /// To check whether a type is uninhabited at all (not just from a given module), you could
1490 /// check whether the forest is empty.
1491 query type_uninhabited_from(
1492 key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1493 ) -> ty::inhabitedness::DefIdForest {
1494 desc { "computing the inhabitedness of `{:?}`", key }
1498 query dep_kind(_: CrateNum) -> CrateDepKind {
1500 desc { "fetching what a dependency looks like" }
1501 separate_provide_extern
1504 /// Gets the name of the crate.
1505 query crate_name(_: CrateNum) -> Symbol {
1507 desc { "fetching what a crate is named" }
1508 separate_provide_extern
1510 query module_children(def_id: DefId) -> &'tcx [ModChild] {
1511 desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) }
1512 separate_provide_extern
1514 query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
1515 desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1518 query lib_features(_: ()) -> LibFeatures {
1519 storage(ArenaCacheSelector<'tcx>)
1520 desc { "calculating the lib features map" }
1522 query defined_lib_features(_: CrateNum)
1523 -> &'tcx [(Symbol, Option<Symbol>)] {
1524 desc { "calculating the lib features defined in a crate" }
1525 separate_provide_extern
1527 /// Returns the lang items defined in another crate by loading it from metadata.
1528 query get_lang_items(_: ()) -> LanguageItems {
1529 storage(ArenaCacheSelector<'tcx>)
1531 desc { "calculating the lang items map" }
1534 /// Returns all diagnostic items defined in all crates.
1535 query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems {
1536 storage(ArenaCacheSelector<'tcx>)
1538 desc { "calculating the diagnostic items map" }
1541 /// Returns the lang items defined in another crate by loading it from metadata.
1542 query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
1543 desc { "calculating the lang items defined in a crate" }
1544 separate_provide_extern
1547 /// Returns the diagnostic items defined in a crate.
1548 query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems {
1549 storage(ArenaCacheSelector<'tcx>)
1550 desc { "calculating the diagnostic items map in a crate" }
1551 separate_provide_extern
1554 query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1555 desc { "calculating the missing lang items in a crate" }
1556 separate_provide_extern
1558 query visible_parent_map(_: ()) -> Lrc<DefIdMap<DefId>> {
1559 desc { "calculating the visible parent map" }
1561 query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
1562 storage(ArenaCacheSelector<'tcx>)
1563 desc { "calculating trimmed def paths" }
1565 query missing_extern_crate_item(_: CrateNum) -> bool {
1567 desc { "seeing if we're missing an `extern crate` item for this crate" }
1568 separate_provide_extern
1570 query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
1572 desc { "looking at the source for a crate" }
1573 separate_provide_extern
1575 query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
1577 desc { "generating a postorder list of CrateNums" }
1579 /// Returns whether or not the crate with CrateNum 'cnum'
1580 /// is marked as a private dependency
1581 query is_private_dep(c: CrateNum) -> bool {
1583 desc { "check whether crate {} is a private dependency", c }
1584 separate_provide_extern
1586 query allocator_kind(_: ()) -> Option<AllocatorKind> {
1588 desc { "allocator kind for the current crate" }
1591 query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
1592 desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
1594 query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
1595 desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1597 query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] {
1598 desc { "looking up all possibly unused extern crates" }
1600 query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxHashSet<Symbol> {
1601 desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1604 query stability_index(_: ()) -> stability::Index<'tcx> {
1605 storage(ArenaCacheSelector<'tcx>)
1607 desc { "calculating the stability index for the local crate" }
1609 query crates(_: ()) -> &'tcx [CrateNum] {
1611 desc { "fetching all foreign CrateNum instances" }
1614 /// A list of all traits in a crate, used by rustdoc and error reporting.
1615 /// NOTE: Not named just `traits` due to a naming conflict.
1616 query traits_in_crate(_: CrateNum) -> &'tcx [DefId] {
1617 desc { "fetching all traits in a crate" }
1618 separate_provide_extern
1621 /// The list of symbols exported from the given crate.
1623 /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1624 /// correspond to a publicly visible symbol in `cnum` machine code.
1625 /// - The `exported_symbols` sets of different crates do not intersect.
1626 query exported_symbols(_: CrateNum)
1627 -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
1628 desc { "exported_symbols" }
1629 separate_provide_extern
1632 query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1634 desc { "collect_and_partition_mono_items" }
1636 query is_codegened_item(def_id: DefId) -> bool {
1637 desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
1640 /// All items participating in code generation together with items inlined into them.
1641 query codegened_and_inlined_items(_: ()) -> &'tcx DefIdSet {
1643 desc { "codegened_and_inlined_items" }
1646 query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> {
1647 desc { "codegen_unit" }
1649 query unused_generic_params(key: ty::InstanceDef<'tcx>) -> FiniteBitSet<u32> {
1650 cache_on_disk_if { key.def_id().is_local() }
1652 |tcx| "determining which generic parameters are unused by `{}`",
1653 tcx.def_path_str(key.def_id())
1655 separate_provide_extern
1657 query backend_optimization_level(_: ()) -> OptLevel {
1658 desc { "optimization level used by backend" }
1661 query output_filenames(_: ()) -> Arc<OutputFilenames> {
1663 desc { "output_filenames" }
1666 /// Do not call this query directly: invoke `normalize` instead.
1667 query normalize_projection_ty(
1668 goal: CanonicalProjectionGoal<'tcx>
1670 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1673 desc { "normalizing `{:?}`", goal }
1677 /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
1678 query try_normalize_generic_arg_after_erasing_regions(
1679 goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1680 ) -> Result<GenericArg<'tcx>, NoSolution> {
1681 desc { "normalizing `{}`", goal.value }
1685 /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
1686 query try_normalize_mir_const_after_erasing_regions(
1687 goal: ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1688 ) -> Result<mir::ConstantKind<'tcx>, NoSolution> {
1689 desc { "normalizing `{}`", goal.value }
1693 query implied_outlives_bounds(
1694 goal: CanonicalTyGoal<'tcx>
1696 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1699 desc { "computing implied outlives bounds for `{:?}`", goal }
1703 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1704 query dropck_outlives(
1705 goal: CanonicalTyGoal<'tcx>
1707 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1710 desc { "computing dropck types for `{:?}`", goal }
1714 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1715 /// `infcx.predicate_must_hold()` instead.
1716 query evaluate_obligation(
1717 goal: CanonicalPredicateGoal<'tcx>
1718 ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1719 desc { "evaluating trait selection obligation `{}`", goal.value.value }
1722 query evaluate_goal(
1723 goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx>
1725 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1728 desc { "evaluating trait selection obligation `{}`", goal.value }
1731 /// Do not call this query directly: part of the `Eq` type-op
1732 query type_op_ascribe_user_type(
1733 goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1735 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1738 desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1742 /// Do not call this query directly: part of the `Eq` type-op
1744 goal: CanonicalTypeOpEqGoal<'tcx>
1746 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1749 desc { "evaluating `type_op_eq` `{:?}`", goal }
1753 /// Do not call this query directly: part of the `Subtype` type-op
1754 query type_op_subtype(
1755 goal: CanonicalTypeOpSubtypeGoal<'tcx>
1757 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1760 desc { "evaluating `type_op_subtype` `{:?}`", goal }
1764 /// Do not call this query directly: part of the `ProvePredicate` type-op
1765 query type_op_prove_predicate(
1766 goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1768 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1771 desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1774 /// Do not call this query directly: part of the `Normalize` type-op
1775 query type_op_normalize_ty(
1776 goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1778 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1781 desc { "normalizing `{:?}`", goal }
1785 /// Do not call this query directly: part of the `Normalize` type-op
1786 query type_op_normalize_predicate(
1787 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1789 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1792 desc { "normalizing `{:?}`", goal }
1796 /// Do not call this query directly: part of the `Normalize` type-op
1797 query type_op_normalize_poly_fn_sig(
1798 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1800 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1803 desc { "normalizing `{:?}`", goal }
1807 /// Do not call this query directly: part of the `Normalize` type-op
1808 query type_op_normalize_fn_sig(
1809 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1811 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1814 desc { "normalizing `{:?}`", goal }
1818 query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1820 "impossible substituted predicates:`{}`",
1821 tcx.def_path_str(key.0)
1825 query method_autoderef_steps(
1826 goal: CanonicalTyGoal<'tcx>
1827 ) -> MethodAutoderefStepsResult<'tcx> {
1828 desc { "computing autoderef types for `{:?}`", goal }
1832 query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
1833 storage(ArenaCacheSelector<'tcx>)
1835 desc { "looking up supported target features" }
1838 /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1839 query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1841 desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1844 query features_query(_: ()) -> &'tcx rustc_feature::Features {
1846 desc { "looking up enabled feature gates" }
1849 /// Attempt to resolve the given `DefId` to an `Instance`, for the
1850 /// given generics args (`SubstsRef`), returning one of:
1851 /// * `Ok(Some(instance))` on success
1852 /// * `Ok(None)` when the `SubstsRef` are still too generic,
1853 /// and therefore don't allow finding the final `Instance`
1854 /// * `Err(ErrorReported)` when the `Instance` resolution process
1855 /// couldn't complete due to errors elsewhere - this is distinct
1856 /// from `Ok(None)` to avoid misleading diagnostics when an error
1857 /// has already been/will be emitted, for the original cause
1858 query resolve_instance(
1859 key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
1860 ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1861 desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
1865 query resolve_instance_of_const_arg(
1866 key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
1867 ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1869 "resolving instance of the const argument `{}`",
1870 ty::Instance::new(key.value.0.to_def_id(), key.value.2),
1875 query normalize_opaque_types(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
1876 desc { "normalizing opaque types in {:?}", key }
1879 /// Checks whether a type is definitely uninhabited. This is
1880 /// conservative: for some types that are uninhabited we return `false`,
1881 /// but we only return `true` for types that are definitely uninhabited.
1882 /// `ty.conservative_is_privately_uninhabited` implies that any value of type `ty`
1883 /// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero
1884 /// size, to account for partial initialisation. See #49298 for details.)
1885 query conservative_is_privately_uninhabited(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1886 desc { "conservatively checking if {:?} is privately uninhabited", key }
1890 query limits(key: ()) -> Limits {
1891 desc { "looking up limits" }
1894 /// Performs an HIR-based well-formed check on the item with the given `HirId`. If
1895 /// we get an `Unimplemented` error that matches the provided `Predicate`, return
1896 /// the cause of the newly created obligation.
1898 /// This is only used by error-reporting code to get a better cause (in particular, a better
1899 /// span) for an *existing* error. Therefore, it is best-effort, and may never handle
1900 /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
1901 /// because the `ty::Ty`-based wfcheck is always run.
1902 query diagnostic_hir_wf_check(key: (ty::Predicate<'tcx>, traits::WellFormedLoc)) -> Option<traits::ObligationCause<'tcx>> {
1905 desc { "performing HIR wf-checking for predicate {:?} at item {:?}", key.0, key.1 }