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 query default_anon_const_substs(key: DefId) -> SubstsRef<'tcx> {
114 desc { |tcx| "computing the default generic arguments for `{}`", tcx.def_path_str(key) }
117 /// Records the type of every item.
118 query type_of(key: DefId) -> Ty<'tcx> {
122 use rustc_hir::def::DefKind;
123 match tcx.def_kind(key) {
124 DefKind::TyAlias => "expanding type alias",
125 DefKind::TraitAlias => "expanding trait alias",
126 _ => "computing type of",
129 path = tcx.def_path_str(key),
131 cache_on_disk_if { key.is_local() }
132 separate_provide_extern
135 query analysis(key: ()) -> Result<(), ErrorReported> {
137 desc { "running analysis passes on this crate" }
140 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
141 /// associated generics.
142 query generics_of(key: DefId) -> ty::Generics {
143 desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
144 storage(ArenaCacheSelector<'tcx>)
145 cache_on_disk_if { key.is_local() }
146 separate_provide_extern
149 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
150 /// predicates (where-clauses) that must be proven true in order
151 /// to reference it. This is almost always the "predicates query"
154 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
155 /// it is almost always the same as that query, except for the
156 /// case of traits. For traits, `predicates_of` contains
157 /// an additional `Self: Trait<...>` predicate that users don't
158 /// actually write. This reflects the fact that to invoke the
159 /// trait (e.g., via `Default::default`) you must supply types
160 /// that actually implement the trait. (However, this extra
161 /// predicate gets in the way of some checks, which are intended
162 /// to operate over only the actual where-clauses written by the
164 query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
165 desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
166 cache_on_disk_if { key.is_local() }
169 /// Returns the list of bounds that can be used for
170 /// `SelectionCandidate::ProjectionCandidate(_)` and
171 /// `ProjectionTyCandidate::TraitDef`.
172 /// Specifically this is the bounds written on the trait's type
173 /// definition, or those after the `impl` keyword
175 /// ```ignore (incomplete)
176 /// type X: Bound + 'lt
178 /// impl Debug + Display
179 /// // ^^^^^^^^^^^^^^^
182 /// `key` is the `DefId` of the associated type or opaque type.
184 /// Bounds from the parent (e.g. with nested impl trait) are not included.
185 query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
186 desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
187 separate_provide_extern
190 /// Elaborated version of the predicates from `explicit_item_bounds`.
196 /// type MyAType: Eq + ?Sized;
200 /// `explicit_item_bounds` returns `[<Self as MyTrait>::MyAType: Eq]`,
201 /// and `item_bounds` returns
204 /// <Self as Trait>::MyAType: Eq,
205 /// <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
209 /// Bounds from the parent (e.g. with nested impl trait) are not included.
210 query item_bounds(key: DefId) -> &'tcx ty::List<ty::Predicate<'tcx>> {
211 desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
214 query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLib>> {
215 desc { "looking up the native libraries of a linked crate" }
216 separate_provide_extern
219 query lint_levels(_: ()) -> LintLevelMap {
220 storage(ArenaCacheSelector<'tcx>)
222 desc { "computing the lint levels for items in this crate" }
225 query parent_module_from_def_id(key: LocalDefId) -> LocalDefId {
227 desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) }
230 query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
231 // This query reads from untracked data in definitions.
233 desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) }
234 separate_provide_extern
237 query is_panic_runtime(_: CrateNum) -> bool {
239 desc { "checking if the crate is_panic_runtime" }
240 separate_provide_extern
243 /// Fetch the THIR for a given body. If typeck for that body failed, returns an empty `Thir`.
244 query thir_body(key: ty::WithOptConstParam<LocalDefId>) -> (&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId) {
245 // Perf tests revealed that hashing THIR is inefficient (see #85729).
247 desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
250 /// Create a THIR tree for debugging.
251 query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String {
253 desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) }
256 /// Set of all the `DefId`s in this crate that have MIR associated with
257 /// them. This includes all the body owners, but also things like struct
259 query mir_keys(_: ()) -> FxHashSet<LocalDefId> {
260 storage(ArenaCacheSelector<'tcx>)
261 desc { "getting a list of all mir_keys" }
264 /// Maps DefId's that have an associated `mir::Body` to the result
265 /// of the MIR const-checking pass. This is the set of qualifs in
266 /// the final value of a `const`.
267 query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
268 desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
269 cache_on_disk_if { key.is_local() }
270 separate_provide_extern
272 query mir_const_qualif_const_arg(
273 key: (LocalDefId, DefId)
274 ) -> mir::ConstQualifs {
276 |tcx| "const checking the const argument `{}`",
277 tcx.def_path_str(key.0.to_def_id())
281 /// Fetch the MIR for a given `DefId` right after it's built - this includes
282 /// unreachable code.
283 query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
284 desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) }
287 /// Fetch the MIR for a given `DefId` up till the point where it is
288 /// ready for const qualification.
290 /// See the README for the `mir` module for details.
291 query mir_const(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
293 |tcx| "processing MIR for {}`{}`",
294 if key.const_param_did.is_some() { "the const argument " } else { "" },
295 tcx.def_path_str(key.did.to_def_id()),
300 /// Try to build an abstract representation of the given constant.
301 query thir_abstract_const(
303 ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
305 |tcx| "building an abstract representation for {}", tcx.def_path_str(key),
307 separate_provide_extern
309 /// Try to build an abstract representation of the given constant.
310 query thir_abstract_const_of_const_arg(
311 key: (LocalDefId, DefId)
312 ) -> Result<Option<&'tcx [thir::abstract_const::Node<'tcx>]>, ErrorReported> {
315 "building an abstract representation for the const argument {}",
316 tcx.def_path_str(key.0.to_def_id()),
320 query try_unify_abstract_consts(key: (
321 ty::Unevaluated<'tcx, ()>, ty::Unevaluated<'tcx, ()>
324 |tcx| "trying to unify the generic constants {} and {}",
325 tcx.def_path_str(key.0.def.did), tcx.def_path_str(key.1.def.did)
329 query mir_drops_elaborated_and_const_checked(
330 key: ty::WithOptConstParam<LocalDefId>
331 ) -> &'tcx Steal<mir::Body<'tcx>> {
333 desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) }
338 ) -> &'tcx mir::Body<'tcx> {
339 desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) }
340 cache_on_disk_if { key.is_local() }
341 separate_provide_extern
344 query mir_for_ctfe_of_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::Body<'tcx> {
346 |tcx| "MIR for CTFE of the const argument `{}`",
347 tcx.def_path_str(key.0.to_def_id())
351 query mir_promoted(key: ty::WithOptConstParam<LocalDefId>) ->
353 &'tcx Steal<mir::Body<'tcx>>,
354 &'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
358 |tcx| "processing {}`{}`",
359 if key.const_param_did.is_some() { "the const argument " } else { "" },
360 tcx.def_path_str(key.did.to_def_id()),
364 query symbols_for_closure_captures(
365 key: (LocalDefId, DefId)
366 ) -> Vec<rustc_span::Symbol> {
368 |tcx| "symbols for captures of closure `{}` in `{}`",
369 tcx.def_path_str(key.1),
370 tcx.def_path_str(key.0.to_def_id())
374 /// MIR after our optimization passes have run. This is MIR that is ready
375 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
376 query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
377 desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) }
378 cache_on_disk_if { key.is_local() }
379 separate_provide_extern
382 /// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
383 /// MIR pass (assuming the -Zinstrument-coverage option is enabled).
384 query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
385 desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
386 storage(ArenaCacheSelector<'tcx>)
389 /// Returns the name of the file that contains the function body, if instrumented for coverage.
390 query covered_file_name(key: DefId) -> Option<Symbol> {
392 |tcx| "retrieving the covered file name, if instrumented, for `{}`",
393 tcx.def_path_str(key)
395 storage(ArenaCacheSelector<'tcx>)
396 cache_on_disk_if { key.is_local() }
399 /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
400 /// function was optimized out before codegen, and before being added to the Coverage Map.
401 query covered_code_regions(key: DefId) -> Vec<&'tcx mir::coverage::CodeRegion> {
403 |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
404 tcx.def_path_str(key)
406 storage(ArenaCacheSelector<'tcx>)
407 cache_on_disk_if { key.is_local() }
410 /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
411 /// `DefId`. This function returns all promoteds in the specified body. The body references
412 /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
413 /// after inlining a body may refer to promoteds from other bodies. In that case you still
414 /// need to use the `DefId` of the original body.
415 query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
416 desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) }
417 cache_on_disk_if { key.is_local() }
418 separate_provide_extern
420 query promoted_mir_of_const_arg(
421 key: (LocalDefId, DefId)
422 ) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
424 |tcx| "optimizing promoted MIR for the const argument `{}`",
425 tcx.def_path_str(key.0.to_def_id()),
429 /// Erases regions from `ty` to yield a new type.
430 /// Normally you would just use `tcx.erase_regions(value)`,
431 /// however, which uses this query as a kind of cache.
432 query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
433 // This query is not expected to have input -- as a result, it
434 // is not a good candidates for "replay" because it is essentially a
435 // pure function of its input (and hence the expectation is that
436 // no caller would be green **apart** from just these
437 // queries). Making it anonymous avoids hashing the result, which
438 // may save a bit of time.
440 desc { "erasing regions from `{:?}`", ty }
443 query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> {
444 storage(ArenaCacheSelector<'tcx>)
445 desc { "wasm import module map" }
448 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
449 /// predicates (where-clauses) directly defined on it. This is
450 /// equal to the `explicit_predicates_of` predicates plus the
451 /// `inferred_outlives_of` predicates.
452 query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> {
453 desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
456 /// Returns everything that looks like a predicate written explicitly
457 /// by the user on a trait item.
459 /// Traits are unusual, because predicates on associated types are
460 /// converted into bounds on that type for backwards compatibility:
462 /// trait X where Self::U: Copy { type U; }
466 /// trait X { type U: Copy; }
468 /// `explicit_predicates_of` and `explicit_item_bounds` will then take
469 /// the appropriate subsets of the predicates here.
470 query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
471 desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key.to_def_id()) }
474 /// Returns the predicates written explicitly by the user.
475 query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
476 desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) }
477 separate_provide_extern
480 /// Returns the inferred outlives predicates (e.g., for `struct
481 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
482 query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
483 desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) }
484 separate_provide_extern
487 /// Maps from the `DefId` of a trait to the list of
488 /// super-predicates. This is a subset of the full list of
489 /// predicates. We store these in a separate map because we must
490 /// evaluate them even during type conversion, often before the
491 /// full predicates are available (note that supertraits have
492 /// additional acyclicity requirements).
493 query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
494 desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
495 separate_provide_extern
498 /// The `Option<Ident>` is the name of an associated type. If it is `None`, then this query
499 /// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
500 /// subset of super-predicates that reference traits that define the given associated type.
501 /// This is used to avoid cycles in resolving types like `T::Item`.
502 query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
503 desc { |tcx| "computing the super traits of `{}`{}",
504 tcx.def_path_str(key.0),
505 if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
509 /// To avoid cycles within the predicates of a single item we compute
510 /// per-type-parameter predicates for resolving `T::AssocTy`.
511 query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
512 desc { |tcx| "computing the bounds for type parameter `{}`", {
513 let id = tcx.hir().local_def_id_to_hir_id(key.1);
514 tcx.hir().ty_param_name(id)
518 query trait_def(key: DefId) -> ty::TraitDef {
519 desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
520 storage(ArenaCacheSelector<'tcx>)
521 separate_provide_extern
523 query adt_def(key: DefId) -> &'tcx ty::AdtDef {
524 desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) }
525 separate_provide_extern
527 query adt_destructor(key: DefId) -> Option<ty::Destructor> {
528 desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) }
529 separate_provide_extern
532 // The cycle error here should be reported as an error by `check_representable`.
533 // We consider the type as Sized in the meanwhile to avoid
534 // further errors (done in impl Value for AdtSizedConstraint).
535 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
536 // in case we accidentally otherwise don't emit an error.
537 query adt_sized_constraint(
539 ) -> AdtSizedConstraint<'tcx> {
540 desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
544 query adt_dtorck_constraint(
546 ) -> Result<DtorckConstraint<'tcx>, NoSolution> {
547 desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
550 /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
551 /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
552 /// not have the feature gate active).
554 /// **Do not call this function manually.** It is only meant to cache the base data for the
555 /// `is_const_fn` function.
556 query is_const_fn_raw(key: DefId) -> bool {
557 desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
558 separate_provide_extern
561 query asyncness(key: DefId) -> hir::IsAsync {
562 desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
563 separate_provide_extern
566 /// Returns `true` if calls to the function may be promoted.
568 /// This is either because the function is e.g., a tuple-struct or tuple-variant
569 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
570 /// be removed in the future in favour of some form of check which figures out whether the
571 /// function does not inspect the bits of any of its arguments (so is essentially just a
572 /// constructor function).
573 query is_promotable_const_fn(key: DefId) -> bool {
574 desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
577 /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
578 query is_foreign_item(key: DefId) -> bool {
579 desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) }
580 separate_provide_extern
583 /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item.
584 query static_mutability(def_id: DefId) -> Option<hir::Mutability> {
585 desc { |tcx| "looking up static mutability of `{}`", tcx.def_path_str(def_id) }
586 separate_provide_extern
589 /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
590 query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
591 desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) }
592 separate_provide_extern
595 /// Gets a map with the variance of every item; use `item_variance` instead.
596 query crate_variances(_: ()) -> ty::CrateVariancesMap<'tcx> {
597 storage(ArenaCacheSelector<'tcx>)
598 desc { "computing the variances for items in this crate" }
601 /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
602 query variances_of(def_id: DefId) -> &'tcx [ty::Variance] {
603 desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) }
604 separate_provide_extern
607 /// Maps from thee `DefId` of a type to its (inferred) outlives.
608 query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> {
609 storage(ArenaCacheSelector<'tcx>)
610 desc { "computing the inferred outlives predicates for items in this crate" }
613 /// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
614 query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
615 desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
616 separate_provide_extern
619 /// Maps from a trait item to the trait item "descriptor".
620 query associated_item(key: DefId) -> ty::AssocItem {
621 desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
622 storage(ArenaCacheSelector<'tcx>)
623 separate_provide_extern
626 /// Collects the associated items defined on a trait or impl.
627 query associated_items(key: DefId) -> ty::AssocItems<'tcx> {
628 storage(ArenaCacheSelector<'tcx>)
629 desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) }
632 /// Given an `impl_id`, return the trait it implements.
633 /// Return `None` if this is an inherent impl.
634 query impl_trait_ref(impl_id: DefId) -> Option<ty::TraitRef<'tcx>> {
635 desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
636 separate_provide_extern
638 query impl_polarity(impl_id: DefId) -> ty::ImplPolarity {
639 desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) }
640 separate_provide_extern
643 query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> {
644 desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
647 /// Maps a `DefId` of a type to a list of its inherent impls.
648 /// Contains implementations of methods that are inherent to a type.
649 /// Methods in these implementations don't need to be exported.
650 query inherent_impls(key: DefId) -> &'tcx [DefId] {
651 desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) }
653 separate_provide_extern
656 /// The result of unsafety-checking this `LocalDefId`.
657 query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
658 desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
659 cache_on_disk_if { true }
661 query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult {
663 |tcx| "unsafety-checking the const argument `{}`",
664 tcx.def_path_str(key.0.to_def_id())
668 /// Unsafety-check this `LocalDefId` with THIR unsafeck. This should be
669 /// used with `-Zthir-unsafeck`.
670 query thir_check_unsafety(key: LocalDefId) {
671 desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
672 cache_on_disk_if { true }
674 query thir_check_unsafety_for_const_arg(key: (LocalDefId, DefId)) {
676 |tcx| "unsafety-checking the const argument `{}`",
677 tcx.def_path_str(key.0.to_def_id())
681 /// HACK: when evaluated, this reports an "unsafe derive on repr(packed)" error.
683 /// Unsafety checking is executed for each method separately, but we only want
684 /// to emit this error once per derive. As there are some impls with multiple
685 /// methods, we use a query for deduplication.
686 query unsafe_derive_on_repr_packed(key: LocalDefId) -> () {
687 desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
690 /// Computes the signature of the function.
691 query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> {
692 desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
693 separate_provide_extern
696 /// Performs lint checking for the module.
697 query lint_mod(key: LocalDefId) -> () {
698 desc { |tcx| "linting {}", describe_as_module(key, tcx) }
701 /// Checks the attributes in the module.
702 query check_mod_attrs(key: LocalDefId) -> () {
703 desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
706 /// Checks for uses of unstable APIs in the module.
707 query check_mod_unstable_api_usage(key: LocalDefId) -> () {
708 desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
711 /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
712 query check_mod_const_bodies(key: LocalDefId) -> () {
713 desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
716 /// Checks the loops in the module.
717 query check_mod_loops(key: LocalDefId) -> () {
718 desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
721 query check_mod_naked_functions(key: LocalDefId) -> () {
722 desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
725 query check_mod_item_types(key: LocalDefId) -> () {
726 desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) }
729 query check_mod_privacy(key: LocalDefId) -> () {
730 desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) }
733 query check_mod_intrinsics(key: LocalDefId) -> () {
734 desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) }
737 query check_mod_liveness(key: LocalDefId) -> () {
738 desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) }
741 query check_mod_impl_wf(key: LocalDefId) -> () {
742 desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
745 query collect_mod_item_types(key: LocalDefId) -> () {
746 desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
749 /// Caches `CoerceUnsized` kinds for impls on custom types.
750 query coerce_unsized_info(key: DefId) -> ty::adjustment::CoerceUnsizedInfo {
751 desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
752 separate_provide_extern
755 query typeck_item_bodies(_: ()) -> () {
756 desc { "type-checking all item bodies" }
759 query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
760 desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
761 cache_on_disk_if { true }
763 query typeck_const_arg(
764 key: (LocalDefId, DefId)
765 ) -> &'tcx ty::TypeckResults<'tcx> {
767 |tcx| "type-checking the const argument `{}`",
768 tcx.def_path_str(key.0.to_def_id()),
771 query diagnostic_only_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 }
774 load_cached(tcx, id) {
775 let typeck_results: Option<ty::TypeckResults<'tcx>> = tcx
776 .on_disk_cache().as_ref()
777 .and_then(|c| c.try_load_query_result(*tcx, id));
779 typeck_results.map(|x| &*tcx.arena.alloc(x))
783 query used_trait_imports(key: LocalDefId) -> &'tcx FxHashSet<LocalDefId> {
784 desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) }
785 cache_on_disk_if { true }
788 query has_typeck_results(def_id: DefId) -> bool {
789 desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) }
792 query coherent_trait(def_id: DefId) -> () {
793 desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
796 /// Borrow-checks the function body. If this is a closure, returns
797 /// additional requirements that the closure's creator must verify.
798 query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
799 desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) }
800 cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }
802 query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> {
804 |tcx| "borrow-checking the const argument`{}`",
805 tcx.def_path_str(key.0.to_def_id())
809 /// Gets a complete map from all types to their inherent impls.
810 /// Not meant to be used directly outside of coherence.
811 query crate_inherent_impls(k: ()) -> CrateInherentImpls {
812 storage(ArenaCacheSelector<'tcx>)
814 desc { "all inherent impls defined in crate" }
817 /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
818 /// Not meant to be used directly outside of coherence.
819 query crate_inherent_impls_overlap_check(_: ())
822 desc { "check for overlap between inherent impls defined in this crate" }
825 /// Checks whether all impls in the crate pass the overlap check, returning
826 /// which impls fail it. If all impls are correct, the returned slice is empty.
827 query orphan_check_crate(_: ()) -> &'tcx [LocalDefId] {
829 "checking whether the immpl in the this crate follow the orphan rules",
833 /// Check whether the function has any recursion that could cause the inliner to trigger
834 /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
835 /// current function, just all intermediate functions.
836 query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool {
839 "computing if `{}` (transitively) calls `{}`",
841 tcx.def_path_str(key.1.to_def_id()),
845 /// Obtain all the calls into other local functions
846 query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] {
849 "computing all local function calls in `{}`",
850 tcx.def_path_str(key.def_id()),
854 /// Evaluates a constant and returns the computed allocation.
856 /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper.
857 query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
858 -> EvalToAllocationRawResult<'tcx> {
860 "const-evaluating + checking `{}`",
861 key.value.display(tcx)
863 cache_on_disk_if { true }
866 /// Evaluates const items or anonymous constants
867 /// (such as enum variant explicit discriminants or array lengths)
868 /// into a representation suitable for the type system and const generics.
870 /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
871 /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
872 query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
873 -> EvalToConstValueResult<'tcx> {
875 "simplifying constant for the type system `{}`",
876 key.value.display(tcx)
878 cache_on_disk_if { true }
881 /// Convert an evaluated constant to a type level constant or
882 /// return `None` if that is not possible.
883 query const_to_valtree(
884 key: ty::ParamEnvAnd<'tcx, ConstAlloc<'tcx>>
885 ) -> Option<ty::ValTree<'tcx>> {
886 desc { "destructure constant" }
889 /// Destructure a constant ADT or array into its variant index and its
891 query destructure_const(
892 key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
893 ) -> mir::DestructuredConst<'tcx> {
894 desc { "destructure constant" }
897 /// Dereference a constant reference or raw pointer and turn the result into a constant
900 key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>>
901 ) -> &'tcx ty::Const<'tcx> {
902 desc { "deref constant" }
905 query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
906 desc { "get a &core::panic::Location referring to a span" }
910 key: LitToConstInput<'tcx>
911 ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> {
912 desc { "converting literal to const" }
915 query check_match(key: DefId) {
916 desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
917 cache_on_disk_if { key.is_local() }
920 /// Performs part of the privacy check and computes "access levels".
921 query privacy_access_levels(_: ()) -> &'tcx AccessLevels {
923 desc { "privacy access levels" }
925 query check_private_in_public(_: ()) -> () {
927 desc { "checking for private elements in public interfaces" }
930 query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
931 storage(ArenaCacheSelector<'tcx>)
932 desc { "reachability" }
935 /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
936 /// in the case of closures, this will be redirected to the enclosing function.
937 query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree {
938 desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
941 /// Generates a MIR body for the shim.
942 query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> {
943 storage(ArenaCacheSelector<'tcx>)
944 desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
947 /// The `symbol_name` query provides the symbol name for calling a
948 /// given instance from the local crate. In particular, it will also
949 /// look up the correct symbol name of instances from upstream crates.
950 query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
951 desc { "computing the symbol for `{}`", key }
952 cache_on_disk_if { true }
955 query opt_def_kind(def_id: DefId) -> Option<DefKind> {
956 desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
957 separate_provide_extern
960 /// Gets the span for the definition.
961 query def_span(def_id: DefId) -> Span {
962 desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
963 separate_provide_extern
966 /// Gets the span for the identifier of the definition.
967 query def_ident_span(def_id: DefId) -> Option<Span> {
968 desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
969 separate_provide_extern
972 query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> {
973 desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
974 separate_provide_extern
977 query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> {
978 desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
979 separate_provide_extern
982 query should_inherit_track_caller(def_id: DefId) -> bool {
983 desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) }
986 query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
987 desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
988 separate_provide_extern
991 query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] {
992 desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
993 separate_provide_extern
996 query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
997 desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
998 storage(ArenaCacheSelector<'tcx>)
999 cache_on_disk_if { true }
1002 query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
1003 desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
1004 separate_provide_extern
1006 /// Gets the rendered value of the specified constant or associated constant.
1007 /// Used by rustdoc.
1008 query rendered_const(def_id: DefId) -> String {
1009 desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) }
1010 separate_provide_extern
1012 query impl_parent(def_id: DefId) -> Option<DefId> {
1013 desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
1014 separate_provide_extern
1017 /// Given an `associated_item`, find the trait it belongs to.
1018 /// Return `None` if the `DefId` is not an associated item.
1019 query trait_of_item(associated_item: DefId) -> Option<DefId> {
1020 desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(associated_item) }
1021 separate_provide_extern
1024 query is_ctfe_mir_available(key: DefId) -> bool {
1025 desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx.def_path_str(key) }
1026 separate_provide_extern
1028 query is_mir_available(key: DefId) -> bool {
1029 desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) }
1030 separate_provide_extern
1033 query own_existential_vtable_entries(
1034 key: ty::PolyExistentialTraitRef<'tcx>
1035 ) -> &'tcx [DefId] {
1036 desc { |tcx| "finding all existential vtable entries for trait {}", tcx.def_path_str(key.def_id()) }
1039 query vtable_entries(key: ty::PolyTraitRef<'tcx>)
1040 -> &'tcx [ty::VtblEntry<'tcx>] {
1041 desc { |tcx| "finding all vtable entries for trait {}", tcx.def_path_str(key.def_id()) }
1044 query vtable_trait_upcasting_coercion_new_vptr_slot(key: (ty::Ty<'tcx>, ty::Ty<'tcx>)) -> Option<usize> {
1045 desc { |tcx| "finding the slot within vtable for trait object {} vtable ptr during trait upcasting coercion from {} vtable",
1049 query vtable_allocation(key: (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>)) -> mir::interpret::AllocId {
1050 desc { |tcx| "vtable const allocation for <{} as {}>",
1052 key.1.map(|trait_ref| format!("{}", trait_ref)).unwrap_or("_".to_owned())
1056 query codegen_fulfill_obligation(
1057 key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
1058 ) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
1059 cache_on_disk_if { true }
1061 "checking if `{}` fulfills its obligations",
1062 tcx.def_path_str(key.1.def_id())
1066 /// Return all `impl` blocks in the current crate.
1067 query all_local_trait_impls(_: ()) -> &'tcx BTreeMap<DefId, Vec<LocalDefId>> {
1068 desc { "local trait impls" }
1071 /// Given a trait `trait_id`, return all known `impl` blocks.
1072 query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls {
1073 storage(ArenaCacheSelector<'tcx>)
1074 desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) }
1077 query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph {
1078 storage(ArenaCacheSelector<'tcx>)
1079 desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
1080 cache_on_disk_if { true }
1082 query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
1083 desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(trait_id) }
1086 /// Gets the ParameterEnvironment for a given item; this environment
1087 /// will be in "user-facing" mode, meaning that it is suitable for
1088 /// type-checking etc, and it does not normalize specializable
1089 /// associated types. This is almost always what you want,
1090 /// unless you are doing MIR optimizations, in which case you
1091 /// might want to use `reveal_all()` method to change modes.
1092 query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
1093 desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
1096 /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
1097 /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
1098 /// as this method is more efficient.
1099 query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
1100 desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
1103 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
1104 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
1105 query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1106 desc { "computing whether `{}` is `Copy`", env.value }
1108 /// Query backing `TyS::is_sized`.
1109 query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1110 desc { "computing whether `{}` is `Sized`", env.value }
1112 /// Query backing `TyS::is_freeze`.
1113 query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1114 desc { "computing whether `{}` is freeze", env.value }
1116 /// Query backing `TyS::is_unpin`.
1117 query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1118 desc { "computing whether `{}` is `Unpin`", env.value }
1120 /// Query backing `TyS::needs_drop`.
1121 query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1122 desc { "computing whether `{}` needs drop", env.value }
1124 /// Query backing `TyS::has_significant_drop_raw`.
1125 query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1126 desc { "computing whether `{}` has a significant drop", env.value }
1129 /// Query backing `TyS::is_structural_eq_shallow`.
1131 /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1133 query has_structural_eq_impls(ty: Ty<'tcx>) -> bool {
1135 "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`",
1140 /// A list of types where the ADT requires drop if and only if any of
1141 /// those types require drop. If the ADT is known to always need drop
1142 /// then `Err(AlwaysRequiresDrop)` is returned.
1143 query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1144 desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
1145 cache_on_disk_if { true }
1148 /// A list of types where the ADT requires drop if and only if any of those types
1149 /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
1150 /// is considered to not be significant. A drop is significant if it is implemented
1151 /// by the user or does anything that will have any observable behavior (other than
1152 /// freeing up memory). If the ADT is known to have a significant destructor then
1153 /// `Err(AlwaysRequiresDrop)` is returned.
1154 query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1155 desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
1156 cache_on_disk_if { false }
1159 /// Computes the layout of a type. Note that this implicitly
1160 /// executes in "reveal all" mode, and will normalize the input type.
1162 key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1163 ) -> Result<ty::layout::TyAndLayout<'tcx>, ty::layout::LayoutError<'tcx>> {
1164 desc { "computing layout of `{}`", key.value }
1167 /// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
1169 /// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
1170 /// instead, where the instance is an `InstanceDef::Virtual`.
1171 query fn_abi_of_fn_ptr(
1172 key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1173 ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1174 desc { "computing call ABI of `{}` function pointers", key.value.0 }
1177 /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
1178 /// direct calls to an `fn`.
1180 /// NB: that includes virtual calls, which are represented by "direct calls"
1181 /// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
1182 query fn_abi_of_instance(
1183 key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1184 ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1185 desc { "computing call ABI of `{}`", key.value.0 }
1188 query dylib_dependency_formats(_: CrateNum)
1189 -> &'tcx [(CrateNum, LinkagePreference)] {
1190 desc { "dylib dependency formats of crate" }
1191 separate_provide_extern
1194 query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
1195 desc { "get the linkage format of all dependencies" }
1198 query is_compiler_builtins(_: CrateNum) -> bool {
1200 desc { "checking if the crate is_compiler_builtins" }
1201 separate_provide_extern
1203 query has_global_allocator(_: CrateNum) -> bool {
1204 // This query depends on untracked global state in CStore
1207 desc { "checking if the crate has_global_allocator" }
1208 separate_provide_extern
1210 query has_panic_handler(_: CrateNum) -> bool {
1212 desc { "checking if the crate has_panic_handler" }
1213 separate_provide_extern
1215 query is_profiler_runtime(_: CrateNum) -> bool {
1217 desc { "query a crate is `#![profiler_runtime]`" }
1218 separate_provide_extern
1220 query panic_strategy(_: CrateNum) -> PanicStrategy {
1222 desc { "query a crate's configured panic strategy" }
1223 separate_provide_extern
1225 query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
1227 desc { "query a crate's configured panic-in-drop strategy" }
1228 separate_provide_extern
1230 query is_no_builtins(_: CrateNum) -> bool {
1232 desc { "test whether a crate has `#![no_builtins]`" }
1233 separate_provide_extern
1235 query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1237 desc { "query a crate's symbol mangling version" }
1238 separate_provide_extern
1241 query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
1243 desc { "getting crate's ExternCrateData" }
1244 separate_provide_extern
1247 query specializes(_: (DefId, DefId)) -> bool {
1248 desc { "computing whether impls specialize one another" }
1250 query in_scope_traits_map(_: LocalDefId)
1251 -> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> {
1252 desc { "traits in scope at a block" }
1255 query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export]> {
1256 desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1259 query impl_defaultness(def_id: DefId) -> hir::Defaultness {
1260 desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) }
1261 separate_provide_extern
1264 query impl_constness(def_id: DefId) -> hir::Constness {
1265 desc { |tcx| "looking up whether `{}` is a const impl", tcx.def_path_str(def_id) }
1266 separate_provide_extern
1269 query check_item_well_formed(key: LocalDefId) -> () {
1270 desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1272 query check_trait_item_well_formed(key: LocalDefId) -> () {
1273 desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1275 query check_impl_item_well_formed(key: LocalDefId) -> () {
1276 desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) }
1279 // The `DefId`s of all non-generic functions and statics in the given crate
1280 // that can be reached from outside the crate.
1282 // We expect this items to be available for being linked to.
1284 // This query can also be called for `LOCAL_CRATE`. In this case it will
1285 // compute which items will be reachable to other crates, taking into account
1286 // the kind of crate that is currently compiled. Crates with only a
1287 // C interface have fewer reachable things.
1289 // Does not include external symbols that don't have a corresponding DefId,
1290 // like the compiler-generated `main` function and so on.
1291 query reachable_non_generics(_: CrateNum)
1292 -> DefIdMap<SymbolExportLevel> {
1293 storage(ArenaCacheSelector<'tcx>)
1294 desc { "looking up the exported symbols of a crate" }
1295 separate_provide_extern
1297 query is_reachable_non_generic(def_id: DefId) -> bool {
1298 desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
1299 separate_provide_extern
1301 query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
1303 "checking whether `{}` is reachable from outside the crate",
1304 tcx.def_path_str(def_id.to_def_id()),
1308 /// The entire set of monomorphizations the local crate can safely link
1309 /// to because they are exported from upstream crates. Do not depend on
1310 /// this directly, as its value changes anytime a monomorphization gets
1311 /// added or removed in any upstream crate. Instead use the narrower
1312 /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
1313 /// better, `Instance::upstream_monomorphization()`.
1314 query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1315 storage(ArenaCacheSelector<'tcx>)
1316 desc { "collecting available upstream monomorphizations" }
1319 /// Returns the set of upstream monomorphizations available for the
1320 /// generic function identified by the given `def_id`. The query makes
1321 /// sure to make a stable selection if the same monomorphization is
1322 /// available in multiple upstream crates.
1324 /// You likely want to call `Instance::upstream_monomorphization()`
1325 /// instead of invoking this query directly.
1326 query upstream_monomorphizations_for(def_id: DefId)
1327 -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1329 "collecting available upstream monomorphizations for `{}`",
1330 tcx.def_path_str(def_id),
1332 separate_provide_extern
1335 /// Returns the upstream crate that exports drop-glue for the given
1336 /// type (`substs` is expected to be a single-item list containing the
1337 /// type one wants drop-glue for).
1339 /// This is a subset of `upstream_monomorphizations_for` in order to
1340 /// increase dep-tracking granularity. Otherwise adding or removing any
1341 /// type with drop-glue in any upstream crate would invalidate all
1342 /// functions calling drop-glue of an upstream type.
1344 /// You likely want to call `Instance::upstream_monomorphization()`
1345 /// instead of invoking this query directly.
1347 /// NOTE: This query could easily be extended to also support other
1348 /// common functions that have are large set of monomorphizations
1349 /// (like `Clone::clone` for example).
1350 query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
1351 desc { "available upstream drop-glue for `{:?}`", substs }
1354 query foreign_modules(_: CrateNum) -> Lrc<FxHashMap<DefId, ForeignModule>> {
1355 desc { "looking up the foreign modules of a linked crate" }
1356 separate_provide_extern
1359 /// Identifies the entry-point (e.g., the `main` function) for a given
1360 /// crate, returning `None` if there is no entry point (such as for library crates).
1361 query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
1362 desc { "looking up the entry function of a crate" }
1364 query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
1365 desc { "looking up the derive registrar for a crate" }
1367 // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1368 // Changing the name should cause a compiler error, but in case that changes, be aware.
1369 query crate_hash(_: CrateNum) -> Svh {
1371 desc { "looking up the hash a crate" }
1372 separate_provide_extern
1374 query crate_host_hash(_: CrateNum) -> Option<Svh> {
1376 desc { "looking up the hash of a host version of a crate" }
1377 separate_provide_extern
1379 query extra_filename(_: CrateNum) -> String {
1381 desc { "looking up the extra filename for a crate" }
1382 separate_provide_extern
1384 query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
1386 desc { "looking up the paths for extern crates" }
1387 separate_provide_extern
1390 /// Given a crate and a trait, look up all impls of that trait in the crate.
1391 /// Return `(impl_id, self_ty)`.
1392 query implementations_of_trait(_: (CrateNum, DefId))
1393 -> &'tcx [(DefId, Option<ty::fast_reject::SimplifiedType>)] {
1394 desc { "looking up implementations of a trait in a crate" }
1395 separate_provide_extern
1398 /// Given a crate, look up all trait impls in that crate.
1399 /// Return `(impl_id, self_ty)`.
1400 query all_trait_implementations(_: CrateNum)
1401 -> &'tcx [(DefId, Option<ty::fast_reject::SimplifiedType>)] {
1402 desc { "looking up all (?) trait implementations" }
1403 separate_provide_extern
1406 query is_dllimport_foreign_item(def_id: DefId) -> bool {
1407 desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) }
1409 query is_statically_included_foreign_item(def_id: DefId) -> bool {
1410 desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) }
1412 query native_library_kind(def_id: DefId)
1413 -> Option<NativeLibKind> {
1414 desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) }
1417 /// Does lifetime resolution, but does not descend into trait items. This
1418 /// should only be used for resolving lifetimes of on trait definitions,
1419 /// and is used to avoid cycles. Importantly, `resolve_lifetimes` still visits
1420 /// the same lifetimes and is responsible for diagnostics.
1421 /// See `rustc_resolve::late::lifetimes for details.
1422 query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes {
1423 storage(ArenaCacheSelector<'tcx>)
1424 desc { "resolving lifetimes for a trait definition" }
1426 /// Does lifetime resolution on items. Importantly, we can't resolve
1427 /// lifetimes directly on things like trait methods, because of trait params.
1428 /// See `rustc_resolve::late::lifetimes for details.
1429 query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
1430 storage(ArenaCacheSelector<'tcx>)
1431 desc { "resolving lifetimes" }
1433 query named_region_map(_: LocalDefId) ->
1434 Option<&'tcx FxHashMap<ItemLocalId, Region>> {
1435 desc { "looking up a named region" }
1437 query is_late_bound_map(_: LocalDefId) ->
1438 Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
1439 desc { "testing if a region is late bound" }
1441 /// For a given item (like a struct), gets the default lifetimes to be used
1442 /// for each parameter if a trait object were to be passed for that parameter.
1443 /// For example, for `struct Foo<'a, T, U>`, this would be `['static, 'static]`.
1444 /// For `struct Foo<'a, T: 'a, U>`, this would instead be `['a, 'static]`.
1445 query object_lifetime_defaults_map(_: LocalDefId)
1446 -> Option<Vec<ObjectLifetimeDefault>> {
1447 desc { "looking up lifetime defaults for a region on an item" }
1449 query late_bound_vars_map(_: LocalDefId)
1450 -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
1451 desc { "looking up late bound vars" }
1454 query lifetime_scope_map(_: LocalDefId) -> Option<FxHashMap<ItemLocalId, LifetimeScopeForPath>> {
1455 desc { "finds the lifetime scope for an HirId of a PathSegment" }
1458 query visibility(def_id: DefId) -> ty::Visibility {
1459 desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
1460 separate_provide_extern
1463 /// Computes the set of modules from which this type is visibly uninhabited.
1464 /// To check whether a type is uninhabited at all (not just from a given module), you could
1465 /// check whether the forest is empty.
1466 query type_uninhabited_from(
1467 key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
1468 ) -> ty::inhabitedness::DefIdForest {
1469 desc { "computing the inhabitedness of `{:?}`", key }
1472 query dep_kind(_: CrateNum) -> CrateDepKind {
1474 desc { "fetching what a dependency looks like" }
1475 separate_provide_extern
1478 /// Gets the name of the crate.
1479 query crate_name(_: CrateNum) -> Symbol {
1481 desc { "fetching what a crate is named" }
1482 separate_provide_extern
1484 query item_children(def_id: DefId) -> &'tcx [Export] {
1485 desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) }
1486 separate_provide_extern
1488 query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
1489 desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
1492 query get_lib_features(_: ()) -> LibFeatures {
1493 storage(ArenaCacheSelector<'tcx>)
1495 desc { "calculating the lib features map" }
1497 query defined_lib_features(_: CrateNum)
1498 -> &'tcx [(Symbol, Option<Symbol>)] {
1499 desc { "calculating the lib features defined in a crate" }
1500 separate_provide_extern
1502 /// Returns the lang items defined in another crate by loading it from metadata.
1503 query get_lang_items(_: ()) -> LanguageItems {
1504 storage(ArenaCacheSelector<'tcx>)
1506 desc { "calculating the lang items map" }
1509 /// Returns all diagnostic items defined in all crates.
1510 query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems {
1511 storage(ArenaCacheSelector<'tcx>)
1513 desc { "calculating the diagnostic items map" }
1516 /// Returns the lang items defined in another crate by loading it from metadata.
1517 query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
1518 desc { "calculating the lang items defined in a crate" }
1519 separate_provide_extern
1522 /// Returns the diagnostic items defined in a crate.
1523 query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems {
1524 storage(ArenaCacheSelector<'tcx>)
1525 desc { "calculating the diagnostic items map in a crate" }
1526 separate_provide_extern
1529 query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1530 desc { "calculating the missing lang items in a crate" }
1531 separate_provide_extern
1533 query visible_parent_map(_: ()) -> DefIdMap<DefId> {
1534 storage(ArenaCacheSelector<'tcx>)
1535 desc { "calculating the visible parent map" }
1537 query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
1538 storage(ArenaCacheSelector<'tcx>)
1539 desc { "calculating trimmed def paths" }
1541 query missing_extern_crate_item(_: CrateNum) -> bool {
1543 desc { "seeing if we're missing an `extern crate` item for this crate" }
1544 separate_provide_extern
1546 query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
1548 desc { "looking at the source for a crate" }
1549 separate_provide_extern
1551 query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
1553 desc { "generating a postorder list of CrateNums" }
1555 /// Returns whether or not the crate with CrateNum 'cnum'
1556 /// is marked as a private dependency
1557 query is_private_dep(c: CrateNum) -> bool {
1559 desc { "check whether crate {} is a private dependency", c }
1560 separate_provide_extern
1562 query allocator_kind(_: ()) -> Option<AllocatorKind> {
1564 desc { "allocator kind for the current crate" }
1567 query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
1568 desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
1571 query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
1572 desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1574 query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] {
1575 desc { "looking up all possibly unused extern crates" }
1577 query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxHashSet<Symbol> {
1578 desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) }
1581 query stability_index(_: ()) -> stability::Index<'tcx> {
1582 storage(ArenaCacheSelector<'tcx>)
1584 desc { "calculating the stability index for the local crate" }
1586 query crates(_: ()) -> &'tcx [CrateNum] {
1588 desc { "fetching all foreign CrateNum instances" }
1591 /// A vector of every trait accessible in the whole crate
1592 /// (i.e., including those from subcrates). This is used only for
1593 /// error reporting.
1594 query all_traits(_: ()) -> &'tcx [DefId] {
1595 desc { "fetching all foreign and local traits" }
1598 /// The list of symbols exported from the given crate.
1600 /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1601 /// correspond to a publicly visible symbol in `cnum` machine code.
1602 /// - The `exported_symbols` sets of different crates do not intersect.
1603 query exported_symbols(_: CrateNum)
1604 -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
1605 desc { "exported_symbols" }
1606 separate_provide_extern
1609 query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1611 desc { "collect_and_partition_mono_items" }
1613 query is_codegened_item(def_id: DefId) -> bool {
1614 desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
1617 /// All items participating in code generation together with items inlined into them.
1618 query codegened_and_inlined_items(_: ()) -> &'tcx DefIdSet {
1620 desc { "codegened_and_inlined_items" }
1623 query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> {
1624 desc { "codegen_unit" }
1626 query unused_generic_params(key: ty::InstanceDef<'tcx>) -> FiniteBitSet<u32> {
1627 cache_on_disk_if { key.def_id().is_local() }
1629 |tcx| "determining which generic parameters are unused by `{}`",
1630 tcx.def_path_str(key.def_id())
1632 separate_provide_extern
1634 query backend_optimization_level(_: ()) -> OptLevel {
1635 desc { "optimization level used by backend" }
1638 query output_filenames(_: ()) -> Arc<OutputFilenames> {
1640 desc { "output_filenames" }
1643 /// Do not call this query directly: invoke `normalize` instead.
1644 query normalize_projection_ty(
1645 goal: CanonicalProjectionGoal<'tcx>
1647 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
1650 desc { "normalizing `{:?}`", goal }
1653 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1654 query normalize_generic_arg_after_erasing_regions(
1655 goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1656 ) -> GenericArg<'tcx> {
1657 desc { "normalizing `{}`", goal.value }
1660 /// Do not call this query directly: invoke `normalize_erasing_regions` instead.
1661 query normalize_mir_const_after_erasing_regions(
1662 goal: ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
1663 ) -> mir::ConstantKind<'tcx> {
1664 desc { "normalizing `{}`", goal.value }
1667 query implied_outlives_bounds(
1668 goal: CanonicalTyGoal<'tcx>
1670 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1673 desc { "computing implied outlives bounds for `{:?}`", goal }
1676 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1677 query dropck_outlives(
1678 goal: CanonicalTyGoal<'tcx>
1680 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
1683 desc { "computing dropck types for `{:?}`", goal }
1686 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1687 /// `infcx.predicate_must_hold()` instead.
1688 query evaluate_obligation(
1689 goal: CanonicalPredicateGoal<'tcx>
1690 ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1691 desc { "evaluating trait selection obligation `{}`", goal.value.value }
1694 query evaluate_goal(
1695 goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx>
1697 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1700 desc { "evaluating trait selection obligation `{}`", goal.value }
1703 /// Do not call this query directly: part of the `Eq` type-op
1704 query type_op_ascribe_user_type(
1705 goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1707 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1710 desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
1713 /// Do not call this query directly: part of the `Eq` type-op
1715 goal: CanonicalTypeOpEqGoal<'tcx>
1717 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1720 desc { "evaluating `type_op_eq` `{:?}`", goal }
1723 /// Do not call this query directly: part of the `Subtype` type-op
1724 query type_op_subtype(
1725 goal: CanonicalTypeOpSubtypeGoal<'tcx>
1727 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1730 desc { "evaluating `type_op_subtype` `{:?}`", goal }
1733 /// Do not call this query directly: part of the `ProvePredicate` type-op
1734 query type_op_prove_predicate(
1735 goal: CanonicalTypeOpProvePredicateGoal<'tcx>
1737 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1740 desc { "evaluating `type_op_prove_predicate` `{:?}`", goal }
1743 /// Do not call this query directly: part of the `Normalize` type-op
1744 query type_op_normalize_ty(
1745 goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1747 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1750 desc { "normalizing `{:?}`", goal }
1753 /// Do not call this query directly: part of the `Normalize` type-op
1754 query type_op_normalize_predicate(
1755 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>
1757 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>,
1760 desc { "normalizing `{:?}`", goal }
1763 /// Do not call this query directly: part of the `Normalize` type-op
1764 query type_op_normalize_poly_fn_sig(
1765 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1767 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1770 desc { "normalizing `{:?}`", goal }
1773 /// Do not call this query directly: part of the `Normalize` type-op
1774 query type_op_normalize_fn_sig(
1775 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
1777 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
1780 desc { "normalizing `{:?}`", goal }
1783 query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1785 "impossible substituted predicates:`{}`",
1786 tcx.def_path_str(key.0)
1790 query method_autoderef_steps(
1791 goal: CanonicalTyGoal<'tcx>
1792 ) -> MethodAutoderefStepsResult<'tcx> {
1793 desc { "computing autoderef types for `{:?}`", goal }
1796 query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
1797 storage(ArenaCacheSelector<'tcx>)
1799 desc { "looking up supported target features" }
1802 /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1803 query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
1805 desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
1808 query features_query(_: ()) -> &'tcx rustc_feature::Features {
1810 desc { "looking up enabled feature gates" }
1813 /// Attempt to resolve the given `DefId` to an `Instance`, for the
1814 /// given generics args (`SubstsRef`), returning one of:
1815 /// * `Ok(Some(instance))` on success
1816 /// * `Ok(None)` when the `SubstsRef` are still too generic,
1817 /// and therefore don't allow finding the final `Instance`
1818 /// * `Err(ErrorReported)` when the `Instance` resolution process
1819 /// couldn't complete due to errors elsewhere - this is distinct
1820 /// from `Ok(None)` to avoid misleading diagnostics when an error
1821 /// has already been/will be emitted, for the original cause
1822 query resolve_instance(
1823 key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
1824 ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1825 desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
1828 query resolve_instance_of_const_arg(
1829 key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)>
1830 ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> {
1832 "resolving instance of the const argument `{}`",
1833 ty::Instance::new(key.value.0.to_def_id(), key.value.2),
1837 query normalize_opaque_types(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {
1838 desc { "normalizing opaque types in {:?}", key }
1841 /// Checks whether a type is definitely uninhabited. This is
1842 /// conservative: for some types that are uninhabited we return `false`,
1843 /// but we only return `true` for types that are definitely uninhabited.
1844 /// `ty.conservative_is_privately_uninhabited` implies that any value of type `ty`
1845 /// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero
1846 /// size, to account for partial initialisation. See #49298 for details.)
1847 query conservative_is_privately_uninhabited(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1848 desc { "conservatively checking if {:?} is privately uninhabited", key }
1851 query limits(key: ()) -> Limits {
1852 desc { "looking up limits" }
1855 /// Performs an HIR-based well-formed check on the item with the given `HirId`. If
1856 /// we get an `Unimplemented` error that matches the provided `Predicate`, return
1857 /// the cause of the newly created obligation.
1859 /// This is only used by error-reporting code to get a better cause (in particular, a better
1860 /// span) for an *existing* error. Therefore, it is best-effort, and may never handle
1861 /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
1862 /// because the `ty::Ty`-based wfcheck is always run.
1863 query diagnostic_hir_wf_check(key: (ty::Predicate<'tcx>, traits::WellFormedLoc)) -> Option<traits::ObligationCause<'tcx>> {
1866 desc { "performing HIR wf-checking for predicate {:?} at item {:?}", key.0, key.1 }