1 //! Defines the various compiler queries.
3 //! For more information on the query system, see
4 //! ["Queries: demand-driven compilation"](https://rustc-dev-guide.rust-lang.org/query.html).
5 //! This chapter includes instructions for adding new queries.
7 // Each of these queries corresponds to a function pointer field in the
8 // `Providers` struct for requesting a value of that type, and a method
9 // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
10 // which memoizes and does dep-graph tracking, wrapping around the actual
11 // `Providers` that the driver creates (using several `rustc_*` crates).
13 // The result type of each query must implement `Clone`, and additionally
14 // `ty::query::values::Value`, which produces an appropriate placeholder
15 // (error) value if the query resulted in a query cycle.
16 // Queries marked with `fatal_cycle` do not need the latter implementation,
17 // as they will raise an fatal error on query cycles instead.
19 query
trigger_delay_span_bug(key
: DefId
) -> () {
20 desc { "trigger a delay span bug" }
23 query
resolutions(_
: ()) -> &'tcx ty
::ResolverOutputs
{
26 desc { "get the resolver outputs" }
29 /// Return the span for a definition.
30 /// Contrary to `def_span` below, this query returns the full absolute span of the definition.
31 /// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
32 /// of rustc_middle::hir::source_map.
33 query
source_span(key
: LocalDefId
) -> Span
{
34 desc { "get the source span" }
37 /// Represents crate as a whole (as distinct from the top-level crate module).
38 /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
39 /// we will have to assume that any change means that you need to be recompiled.
40 /// This is because the `hir_crate` query gives you access to all other items.
41 /// To avoid this fate, do not call `tcx.hir().krate()`; instead,
42 /// prefer wrappers like `tcx.visit_all_items_in_krate()`.
43 query
hir_crate(key
: ()) -> &'tcx Crate
<'tcx
> {
45 desc { "get the crate HIR" }
48 /// The items in a module.
50 /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
51 /// Avoid calling this query directly.
52 query
hir_module_items(key
: LocalDefId
) -> rustc_middle
::hir
::ModuleItems
{
53 storage(ArenaCacheSelector
<'tcx
>)
54 desc { |tcx| "HIR module items in `{}`
", tcx.def_path_str(key.to_def_id()) }
57 /// Gives access to the HIR node for the HIR owner `key`.
59 /// This can be conveniently accessed by methods on `tcx.hir()`.
60 /// Avoid calling this query directly.
61 query hir_owner(key: LocalDefId) -> Option<crate::hir::Owner<'tcx>> {
62 desc { |tcx| "HIR owner of `{}`", tcx
.def_path_str(key
.to_def_id()) }
65 /// Gives access to the HIR ID for the given `LocalDefId` owner `key`.
67 /// This can be conveniently accessed by methods on `tcx.hir()`.
68 /// Avoid calling this query directly.
69 query
local_def_id_to_hir_id(key
: LocalDefId
) -> hir
::HirId
{
70 desc { |tcx| "HIR ID of `{}`
", tcx.def_path_str(key.to_def_id()) }
73 /// Gives access to the HIR node's parent for the HIR owner `key`.
75 /// This can be conveniently accessed by methods on `tcx.hir()`.
76 /// Avoid calling this query directly.
77 query hir_owner_parent(key: LocalDefId) -> hir::HirId {
78 desc { |tcx| "HIR parent of `{}`", tcx
.def_path_str(key
.to_def_id()) }
81 /// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
83 /// This can be conveniently accessed by methods on `tcx.hir()`.
84 /// Avoid calling this query directly.
85 query
hir_owner_nodes(key
: LocalDefId
) -> hir
::MaybeOwner
<&'tcx hir
::OwnerNodes
<'tcx
>> {
86 desc { |tcx| "HIR owner items in `{}`
", tcx.def_path_str(key.to_def_id()) }
89 /// Gives access to the HIR attributes inside the HIR owner `key`.
91 /// This can be conveniently accessed by methods on `tcx.hir()`.
92 /// Avoid calling this query directly.
93 query hir_attrs(key: LocalDefId) -> &'tcx hir::AttributeMap<'tcx> {
94 desc { |tcx| "HIR owner attributes in `{}`", tcx
.def_path_str(key
.to_def_id()) }
97 /// Computes the `DefId` of the corresponding const parameter in case the `key` is a
98 /// const argument and returns `None` otherwise.
100 /// ```ignore (incomplete)
101 /// let a = foo::<7>();
102 /// // ^ Calling `opt_const_param_of` for this argument,
104 /// fn foo<const N: usize>()
105 /// // ^ returns this `DefId`.
108 /// // ^ While calling `opt_const_param_of` for other bodies returns `None`.
111 // It looks like caching this query on disk actually slightly
112 // worsened performance in #74376.
114 // Once const generics are more prevalently used, we might want to
115 // consider only caching calls returning `Some`.
116 query
opt_const_param_of(key
: LocalDefId
) -> Option
<DefId
> {
117 desc { |tcx| "computing the optional const parameter of `{}`
", tcx.def_path_str(key.to_def_id()) }
120 /// Given the def_id of a const-generic parameter, computes the associated default const
121 /// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
122 query const_param_default(param: DefId) -> ty::Const<'tcx> {
123 desc { |tcx| "compute const default for a given parameter `{}`", tcx
.def_path_str(param
) }
124 separate_provide_extern
127 /// Returns the [`Ty`][rustc_middle::ty::Ty] of the given [`DefId`]. If the [`DefId`] points
128 /// to an alias, it will "skip" this alias to return the aliased type.
130 /// [`DefId`]: rustc_hir::def_id::DefId
131 query
type_of(key
: DefId
) -> Ty
<'tcx
> {
135 use rustc_hir
::def
::DefKind
;
136 match tcx
.def_kind(key
) {
137 DefKind
::TyAlias
=> "expanding type alias",
138 DefKind
::TraitAlias
=> "expanding trait alias",
139 _
=> "computing type of",
142 path
= tcx
.def_path_str(key
),
144 cache_on_disk_if { key.is_local() }
145 separate_provide_extern
148 query
analysis(key
: ()) -> Result
<(), ErrorGuaranteed
> {
150 desc { "running analysis passes on this crate" }
153 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
154 /// associated generics.
155 query
generics_of(key
: DefId
) -> ty
::Generics
{
156 desc { |tcx| "computing generics of `{}`
", tcx.def_path_str(key) }
157 storage(ArenaCacheSelector<'tcx>)
158 cache_on_disk_if { key.is_local() }
159 separate_provide_extern
162 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
163 /// predicates (where-clauses) that must be proven true in order
164 /// to reference it. This is almost always the "predicates query
"
167 /// `predicates_of` builds on `predicates_defined_on` -- in fact,
168 /// it is almost always the same as that query, except for the
169 /// case of traits. For traits, `predicates_of` contains
170 /// an additional `Self: Trait<...>` predicate that users don't
171 /// actually write. This reflects the fact that to invoke the
172 /// trait (e.g., via `Default::default`) you must supply types
173 /// that actually implement the trait. (However, this extra
174 /// predicate gets in the way of some checks, which are intended
175 /// to operate over only the actual where-clauses written by the
177 query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
178 desc { |tcx| "computing predicates of `{}`", tcx
.def_path_str(key
) }
179 cache_on_disk_if { key.is_local() }
182 /// Returns the list of bounds that can be used for
183 /// `SelectionCandidate::ProjectionCandidate(_)` and
184 /// `ProjectionTyCandidate::TraitDef`.
185 /// Specifically this is the bounds written on the trait's type
186 /// definition, or those after the `impl` keyword
188 /// ```ignore (incomplete)
189 /// type X: Bound + 'lt
191 /// impl Debug + Display
192 /// // ^^^^^^^^^^^^^^^
195 /// `key` is the `DefId` of the associated type or opaque type.
197 /// Bounds from the parent (e.g. with nested impl trait) are not included.
198 query
explicit_item_bounds(key
: DefId
) -> &'tcx
[(ty
::Predicate
<'tcx
>, Span
)] {
199 desc { |tcx| "finding item bounds for `{}`
", tcx.def_path_str(key) }
200 separate_provide_extern
203 /// Elaborated version of the predicates from `explicit_item_bounds`.
209 /// type MyAType: Eq + ?Sized;
213 /// `explicit_item_bounds` returns `[<Self as MyTrait>::MyAType: Eq]`,
214 /// and `item_bounds` returns
217 /// <Self as Trait>::MyAType: Eq,
218 /// <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
222 /// Bounds from the parent (e.g. with nested impl trait) are not included.
223 query item_bounds(key: DefId) -> &'tcx ty::List<ty::Predicate<'tcx>> {
224 desc { |tcx| "elaborating item bounds for `{}`", tcx
.def_path_str(key
) }
227 query
native_libraries(_
: CrateNum
) -> Vec
<NativeLib
> {
228 storage(ArenaCacheSelector
<'tcx
>)
229 desc { "looking up the native libraries of a linked crate" }
230 separate_provide_extern
233 query
lint_levels(_
: ()) -> LintLevelMap
{
234 storage(ArenaCacheSelector
<'tcx
>)
236 desc { "computing the lint levels for items in this crate" }
239 query
parent_module_from_def_id(key
: LocalDefId
) -> LocalDefId
{
241 desc { |tcx| "parent module of `{}`
", tcx.def_path_str(key.to_def_id()) }
244 query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
245 // This query reads from untracked data in definitions.
247 desc { |tcx| "expansion that defined `{}`", tcx
.def_path_str(key
) }
248 separate_provide_extern
251 query
is_panic_runtime(_
: CrateNum
) -> bool
{
253 desc { "checking if the crate is_panic_runtime" }
254 separate_provide_extern
257 /// Fetch the THIR for a given body. If typeck for that body failed, returns an empty `Thir`.
258 query
thir_body(key
: ty
::WithOptConstParam
<LocalDefId
>)
259 -> Result
<(&'tcx Steal
<thir
::Thir
<'tcx
>>, thir
::ExprId
), ErrorGuaranteed
>
261 // Perf tests revealed that hashing THIR is inefficient (see #85729).
263 desc { |tcx| "building THIR for `{}`
", tcx.def_path_str(key.did.to_def_id()) }
266 /// Create a THIR tree for debugging.
267 query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String {
269 storage(ArenaCacheSelector<'tcx>)
270 desc { |tcx| "constructing THIR tree for `{}`", tcx
.def_path_str(key
.did
.to_def_id()) }
273 /// Set of all the `DefId`s in this crate that have MIR associated with
274 /// them. This includes all the body owners, but also things like struct
276 query
mir_keys(_
: ()) -> rustc_data_structures
::fx
::FxIndexSet
<LocalDefId
> {
277 storage(ArenaCacheSelector
<'tcx
>)
278 desc { "getting a list of all mir_keys" }
281 /// Maps DefId's that have an associated `mir::Body` to the result
282 /// of the MIR const-checking pass. This is the set of qualifs in
283 /// the final value of a `const`.
284 query
mir_const_qualif(key
: DefId
) -> mir
::ConstQualifs
{
285 desc { |tcx| "const checking `{}`
", tcx.def_path_str(key) }
286 cache_on_disk_if { key.is_local() }
287 separate_provide_extern
289 query mir_const_qualif_const_arg(
290 key: (LocalDefId, DefId)
291 ) -> mir::ConstQualifs {
293 |tcx| "const checking the
const argument `{}`
",
294 tcx.def_path_str(key.0.to_def_id())
298 /// Fetch the MIR for a given `DefId` right after it's built - this includes
299 /// unreachable code.
300 query mir_built(key: ty::WithOptConstParam<LocalDefId>) -> &'tcx Steal<mir::Body<'tcx>> {
301 desc { |tcx| "building MIR for `{}`", tcx
.def_path_str(key
.did
.to_def_id()) }
304 /// Fetch the MIR for a given `DefId` up till the point where it is
305 /// ready for const qualification.
307 /// See the README for the `mir` module for details.
308 query
mir_const(key
: ty
::WithOptConstParam
<LocalDefId
>) -> &'tcx Steal
<mir
::Body
<'tcx
>> {
310 |tcx
| "processing MIR for {}`{}`",
311 if key
.const_param_did
.is_some() { "the const argument " }
else { "" }
,
312 tcx
.def_path_str(key
.did
.to_def_id()),
317 /// Try to build an abstract representation of the given constant.
318 query
thir_abstract_const(
320 ) -> Result
<Option
<&'tcx
[thir
::abstract_const
::Node
<'tcx
>]>, ErrorGuaranteed
> {
322 |tcx
| "building an abstract representation for {}", tcx
.def_path_str(key
),
324 separate_provide_extern
326 /// Try to build an abstract representation of the given constant.
327 query
thir_abstract_const_of_const_arg(
328 key
: (LocalDefId
, DefId
)
329 ) -> Result
<Option
<&'tcx
[thir
::abstract_const
::Node
<'tcx
>]>, ErrorGuaranteed
> {
332 "building an abstract representation for the const argument {}",
333 tcx
.def_path_str(key
.0.to_def_id()),
337 query
try_unify_abstract_consts(key
:
338 ty
::ParamEnvAnd
<'tcx
, (ty
::Unevaluated
<'tcx
, ()>, ty
::Unevaluated
<'tcx
, ()>
341 |tcx
| "trying to unify the generic constants {} and {}",
342 tcx
.def_path_str(key
.value
.0.def
.did
), tcx
.def_path_str(key
.value
.1.def
.did
)
346 query
mir_drops_elaborated_and_const_checked(
347 key
: ty
::WithOptConstParam
<LocalDefId
>
348 ) -> &'tcx Steal
<mir
::Body
<'tcx
>> {
350 desc { |tcx| "elaborating drops for `{}`
", tcx.def_path_str(key.did.to_def_id()) }
355 ) -> &'tcx mir::Body<'tcx> {
356 desc { |tcx| "caching mir of `{}` for CTFE", tcx
.def_path_str(key
) }
357 cache_on_disk_if { key.is_local() }
358 separate_provide_extern
361 query
mir_for_ctfe_of_const_arg(key
: (LocalDefId
, DefId
)) -> &'tcx mir
::Body
<'tcx
> {
363 |tcx
| "MIR for CTFE of the const argument `{}`",
364 tcx
.def_path_str(key
.0.to_def_id())
368 query
mir_promoted(key
: ty
::WithOptConstParam
<LocalDefId
>) ->
370 &'tcx Steal
<mir
::Body
<'tcx
>>,
371 &'tcx Steal
<IndexVec
<mir
::Promoted
, mir
::Body
<'tcx
>>>
375 |tcx
| "processing {}`{}`",
376 if key
.const_param_did
.is_some() { "the const argument " }
else { "" }
,
377 tcx
.def_path_str(key
.did
.to_def_id()),
381 query
symbols_for_closure_captures(
382 key
: (LocalDefId
, DefId
)
383 ) -> Vec
<rustc_span
::Symbol
> {
384 storage(ArenaCacheSelector
<'tcx
>)
386 |tcx
| "symbols for captures of closure `{}` in `{}`",
387 tcx
.def_path_str(key
.1),
388 tcx
.def_path_str(key
.0.to_def_id())
392 /// MIR after our optimization passes have run. This is MIR that is ready
393 /// for codegen. This is also the only query that can fetch non-local MIR, at present.
394 query
optimized_mir(key
: DefId
) -> &'tcx mir
::Body
<'tcx
> {
395 desc { |tcx| "optimizing MIR for `{}`
", tcx.def_path_str(key) }
396 cache_on_disk_if { key.is_local() }
397 separate_provide_extern
400 /// Returns coverage summary info for a function, after executing the `InstrumentCoverage`
401 /// MIR pass (assuming the -Cinstrument-coverage option is enabled).
402 query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
403 desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx
.def_path_str(key
.def_id()) }
404 storage(ArenaCacheSelector
<'tcx
>)
407 /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the
408 /// function was optimized out before codegen, and before being added to the Coverage Map.
409 query
covered_code_regions(key
: DefId
) -> Vec
<&'tcx mir
::coverage
::CodeRegion
> {
411 |tcx
| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`",
412 tcx
.def_path_str(key
)
414 storage(ArenaCacheSelector
<'tcx
>)
415 cache_on_disk_if { key.is_local() }
418 /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
419 /// `DefId`. This function returns all promoteds in the specified body. The body references
420 /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
421 /// after inlining a body may refer to promoteds from other bodies. In that case you still
422 /// need to use the `DefId` of the original body.
423 query
promoted_mir(key
: DefId
) -> &'tcx IndexVec
<mir
::Promoted
, mir
::Body
<'tcx
>> {
424 desc { |tcx| "optimizing promoted MIR for `{}`
", tcx.def_path_str(key) }
425 cache_on_disk_if { key.is_local() }
426 separate_provide_extern
428 query promoted_mir_of_const_arg(
429 key: (LocalDefId, DefId)
430 ) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
432 |tcx| "optimizing promoted MIR
for the
const argument `{}`
",
433 tcx.def_path_str(key.0.to_def_id()),
437 /// Erases regions from `ty` to yield a new type.
438 /// Normally you would just use `tcx.erase_regions(value)`,
439 /// however, which uses this query as a kind of cache.
440 query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
441 // This query is not expected to have input -- as a result, it
442 // is not a good candidates for "replay
" because it is essentially a
443 // pure function of its input (and hence the expectation is that
444 // no caller would be green **apart** from just these
445 // queries). Making it anonymous avoids hashing the result, which
446 // may save a bit of time.
448 desc { "erasing regions from `{:?}`", ty
}
451 query
wasm_import_module_map(_
: CrateNum
) -> FxHashMap
<DefId
, String
> {
452 storage(ArenaCacheSelector
<'tcx
>)
453 desc { "wasm import module map" }
456 /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
457 /// predicates (where-clauses) directly defined on it. This is
458 /// equal to the `explicit_predicates_of` predicates plus the
459 /// `inferred_outlives_of` predicates.
460 query
predicates_defined_on(key
: DefId
) -> ty
::GenericPredicates
<'tcx
> {
461 desc { |tcx| "computing predicates of `{}`
", tcx.def_path_str(key) }
464 /// Returns everything that looks like a predicate written explicitly
465 /// by the user on a trait item.
467 /// Traits are unusual, because predicates on associated types are
468 /// converted into bounds on that type for backwards compatibility:
470 /// trait X where Self::U: Copy { type U; }
474 /// trait X { type U: Copy; }
476 /// `explicit_predicates_of` and `explicit_item_bounds` will then take
477 /// the appropriate subsets of the predicates here.
478 query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
479 desc { |tcx| "computing explicit predicates of trait `{}`", tcx
.def_path_str(key
.to_def_id()) }
482 /// Returns the predicates written explicitly by the user.
483 query
explicit_predicates_of(key
: DefId
) -> ty
::GenericPredicates
<'tcx
> {
484 desc { |tcx| "computing explicit predicates of `{}`
", tcx.def_path_str(key) }
485 separate_provide_extern
488 /// Returns the inferred outlives predicates (e.g., for `struct
489 /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
490 query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] {
491 desc { |tcx| "computing inferred outlives predicates of `{}`", tcx
.def_path_str(key
) }
492 separate_provide_extern
495 /// Maps from the `DefId` of a trait to the list of
496 /// super-predicates. This is a subset of the full list of
497 /// predicates. We store these in a separate map because we must
498 /// evaluate them even during type conversion, often before the
499 /// full predicates are available (note that supertraits have
500 /// additional acyclicity requirements).
501 query
super_predicates_of(key
: DefId
) -> ty
::GenericPredicates
<'tcx
> {
502 desc { |tcx| "computing the super predicates of `{}`
", tcx.def_path_str(key) }
503 separate_provide_extern
506 /// The `Option<Ident>` is the name of an associated type. If it is `None`, then this query
507 /// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
508 /// subset of super-predicates that reference traits that define the given associated type.
509 /// This is used to avoid cycles in resolving types like `T::Item`.
510 query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
511 desc { |tcx| "computing the super traits of `{}`{}",
512 tcx
.def_path_str(key
.0),
513 if let Some(assoc_name
) = key
.1 { format!(" with associated type name `{}`
", assoc_name) } else { "".to_string() },
517 /// To avoid cycles within the predicates of a single item we compute
518 /// per-type-parameter predicates for resolving `T::AssocTy`.
519 query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
520 desc { |tcx| "computing the bounds for type parameter `{}`", {
521 let id
= tcx
.hir().local_def_id_to_hir_id(key
.1);
522 tcx
.hir().ty_param_name(id
)
526 query
trait_def(key
: DefId
) -> ty
::TraitDef
{
527 desc { |tcx| "computing trait definition for `{}`
", tcx.def_path_str(key) }
528 storage(ArenaCacheSelector<'tcx>)
529 separate_provide_extern
531 query adt_def(key: DefId) -> ty::AdtDef<'tcx> {
532 desc { |tcx| "computing ADT definition for `{}`", tcx
.def_path_str(key
) }
533 cache_on_disk_if { key.is_local() }
534 separate_provide_extern
536 query
adt_destructor(key
: DefId
) -> Option
<ty
::Destructor
> {
537 desc { |tcx| "computing `Drop` impl for `{}`
", tcx.def_path_str(key) }
538 separate_provide_extern
541 // The cycle error here should be reported as an error by `check_representable`.
542 // We consider the type as Sized in the meanwhile to avoid
543 // further errors (done in impl Value for AdtSizedConstraint).
544 // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
545 // in case we accidentally otherwise don't emit an error.
546 query adt_sized_constraint(
548 ) -> AdtSizedConstraint<'tcx> {
549 desc { |tcx| "computing `Sized` constraints for `{}`", tcx
.def_path_str(key
) }
553 query
adt_dtorck_constraint(
555 ) -> Result
<&'tcx DropckConstraint
<'tcx
>, NoSolution
> {
556 desc { |tcx| "computing drop-check constraints for `{}`
", tcx.def_path_str(key) }
559 /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
560 /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
561 /// not have the feature gate active).
563 /// **Do not call this function manually.** It is only meant to cache the base data for the
564 /// `is_const_fn` function.
565 query impl_constness(key: DefId) -> hir::Constness {
566 desc { |tcx| "checking if item is const fn: `{}`", tcx
.def_path_str(key
) }
567 separate_provide_extern
570 query
asyncness(key
: DefId
) -> hir
::IsAsync
{
571 desc { |tcx| "checking if the function is async: `{}`
", tcx.def_path_str(key) }
572 separate_provide_extern
575 /// Returns `true` if calls to the function may be promoted.
577 /// This is either because the function is e.g., a tuple-struct or tuple-variant
578 /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
579 /// be removed in the future in favour of some form of check which figures out whether the
580 /// function does not inspect the bits of any of its arguments (so is essentially just a
581 /// constructor function).
582 query is_promotable_const_fn(key: DefId) -> bool {
583 desc { |tcx| "checking if item is promotable: `{}`", tcx
.def_path_str(key
) }
586 /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`).
587 query
is_foreign_item(key
: DefId
) -> bool
{
588 desc { |tcx| "checking if `{}` is a foreign item
", tcx.def_path_str(key) }
589 separate_provide_extern
592 /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator.
593 query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> {
594 desc { |tcx| "looking up generator kind of `{}`", tcx
.def_path_str(def_id
) }
595 separate_provide_extern
598 /// Gets a map with the variance of every item; use `item_variance` instead.
599 query
crate_variances(_
: ()) -> ty
::CrateVariancesMap
<'tcx
> {
600 storage(ArenaCacheSelector
<'tcx
>)
601 desc { "computing the variances for items in this crate" }
604 /// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
605 query
variances_of(def_id
: DefId
) -> &'tcx
[ty
::Variance
] {
606 desc { |tcx| "computing the variances of `{}`
", tcx.def_path_str(def_id) }
607 separate_provide_extern
610 /// Maps from thee `DefId` of a type to its (inferred) outlives.
611 query inferred_outlives_crate(_: ()) -> ty::CratePredicatesMap<'tcx> {
612 storage(ArenaCacheSelector<'tcx>)
613 desc { "computing the inferred outlives predicates for items in this crate" }
616 /// Maps from an impl/trait `DefId` to a list of the `DefId`s of its items.
617 query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
618 desc { |tcx| "collecting associated items of `{}`", tcx
.def_path_str(key
) }
619 separate_provide_extern
622 /// Maps from a trait item to the trait item "descriptor".
623 query
associated_item(key
: DefId
) -> ty
::AssocItem
{
624 desc { |tcx| "computing associated item data for `{}`
", tcx.def_path_str(key) }
625 storage(ArenaCacheSelector<'tcx>)
626 separate_provide_extern
629 /// Collects the associated items defined on a trait or impl.
630 query associated_items(key: DefId) -> ty::AssocItems<'tcx> {
631 storage(ArenaCacheSelector<'tcx>)
632 desc { |tcx| "collecting associated items of {}", tcx
.def_path_str(key
) }
635 /// Maps from associated items on a trait to the corresponding associated
636 /// item on the impl specified by `impl_id`.
638 /// For example, with the following code
643 /// trait Trait { // trait_id
644 /// fn f(); // trait_f
645 /// fn g() {} // trait_g
648 /// impl Trait for Type { // impl_id
649 /// fn f() {} // impl_f
650 /// fn g() {} // impl_g
654 /// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
655 ///`{ trait_f: impl_f, trait_g: impl_g }`
656 query
impl_item_implementor_ids(impl_id
: DefId
) -> FxHashMap
<DefId
, DefId
> {
657 storage(ArenaCacheSelector
<'tcx
>)
658 desc { |tcx| "comparing impl items against trait for {}
", tcx.def_path_str(impl_id) }
661 /// Given an `impl_id`, return the trait it implements.
662 /// Return `None` if this is an inherent impl.
663 query impl_trait_ref(impl_id: DefId) -> Option<ty::TraitRef<'tcx>> {
664 desc { |tcx| "computing trait implemented by `{}`", tcx
.def_path_str(impl_id
) }
665 separate_provide_extern
667 query
impl_polarity(impl_id
: DefId
) -> ty
::ImplPolarity
{
668 desc { |tcx| "computing implementation polarity of `{}`
", tcx.def_path_str(impl_id) }
669 separate_provide_extern
672 query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> {
673 desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx
.def_path_str(key
) }
676 /// Maps a `DefId` of a type to a list of its inherent impls.
677 /// Contains implementations of methods that are inherent to a type.
678 /// Methods in these implementations don't need to be exported.
679 query
inherent_impls(key
: DefId
) -> &'tcx
[DefId
] {
680 desc { |tcx| "collecting inherent impls for `{}`
", tcx.def_path_str(key) }
681 separate_provide_extern
684 query incoherent_impls(key: SimplifiedType) -> &'tcx [DefId] {
685 desc { |tcx| "collecting all inherent impls for `{:?}`", key
}
688 /// The result of unsafety-checking this `LocalDefId`.
689 query
unsafety_check_result(key
: LocalDefId
) -> &'tcx mir
::UnsafetyCheckResult
{
690 desc { |tcx| "unsafety-checking `{}`
", tcx.def_path_str(key.to_def_id()) }
691 cache_on_disk_if { true }
693 query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult {
695 |tcx| "unsafety
-checking the
const argument `{}`
",
696 tcx.def_path_str(key.0.to_def_id())
700 /// Unsafety-check this `LocalDefId` with THIR unsafeck. This should be
701 /// used with `-Zthir-unsafeck`.
702 query thir_check_unsafety(key: LocalDefId) {
703 desc { |tcx| "unsafety-checking `{}`", tcx
.def_path_str(key
.to_def_id()) }
704 cache_on_disk_if { true }
706 query
thir_check_unsafety_for_const_arg(key
: (LocalDefId
, DefId
)) {
708 |tcx
| "unsafety-checking the const argument `{}`",
709 tcx
.def_path_str(key
.0.to_def_id())
713 /// HACK: when evaluated, this reports an "unsafe derive on repr(packed)" error.
715 /// Unsafety checking is executed for each method separately, but we only want
716 /// to emit this error once per derive. As there are some impls with multiple
717 /// methods, we use a query for deduplication.
718 query
unsafe_derive_on_repr_packed(key
: LocalDefId
) -> () {
719 desc { |tcx| "processing `{}`
", tcx.def_path_str(key.to_def_id()) }
722 /// Computes the signature of the function.
723 query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> {
724 desc { |tcx| "computing function signature of `{}`", tcx
.def_path_str(key
) }
725 separate_provide_extern
728 /// Performs lint checking for the module.
729 query
lint_mod(key
: LocalDefId
) -> () {
730 desc { |tcx| "linting {}
", describe_as_module(key, tcx) }
733 /// Checks the attributes in the module.
734 query check_mod_attrs(key: LocalDefId) -> () {
735 desc { |tcx| "checking attributes in {}", describe_as_module(key
, tcx
) }
738 /// Checks for uses of unstable APIs in the module.
739 query
check_mod_unstable_api_usage(key
: LocalDefId
) -> () {
740 desc { |tcx| "checking for unstable API usage in {}
", describe_as_module(key, tcx) }
743 /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
744 query check_mod_const_bodies(key: LocalDefId) -> () {
745 desc { |tcx| "checking consts in {}", describe_as_module(key
, tcx
) }
748 /// Checks the loops in the module.
749 query
check_mod_loops(key
: LocalDefId
) -> () {
750 desc { |tcx| "checking loops in {}
", describe_as_module(key, tcx) }
753 query check_mod_naked_functions(key: LocalDefId) -> () {
754 desc { |tcx| "checking naked functions in {}", describe_as_module(key
, tcx
) }
757 query
check_mod_item_types(key
: LocalDefId
) -> () {
758 desc { |tcx| "checking item types in {}
", describe_as_module(key, tcx) }
761 query check_mod_privacy(key: LocalDefId) -> () {
762 desc { |tcx| "checking privacy in {}", describe_as_module(key
, tcx
) }
765 query
check_mod_intrinsics(key
: LocalDefId
) -> () {
766 desc { |tcx| "checking intrinsics in {}
", describe_as_module(key, tcx) }
769 query check_mod_liveness(key: LocalDefId) -> () {
770 desc { |tcx| "checking liveness of variables in {}", describe_as_module(key
, tcx
) }
773 /// Return the live symbols in the crate for dead code check.
775 /// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and
776 /// their respective impl (i.e., part of the derive macro)
777 query
live_symbols_and_ignored_derived_traits(_
: ()) -> (
778 FxHashSet
<LocalDefId
>,
779 FxHashMap
<LocalDefId
, Vec
<(DefId
, DefId
)>>
781 storage(ArenaCacheSelector
<'tcx
>)
782 desc { "find live symbols in crate" }
785 query
check_mod_deathness(key
: LocalDefId
) -> () {
786 desc { |tcx| "checking deathness of variables in {}
", describe_as_module(key, tcx) }
789 query check_mod_impl_wf(key: LocalDefId) -> () {
790 desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key
, tcx
) }
793 query
collect_mod_item_types(key
: LocalDefId
) -> () {
794 desc { |tcx| "collecting item types in {}
", describe_as_module(key, tcx) }
797 /// Caches `CoerceUnsized` kinds for impls on custom types.
798 query coerce_unsized_info(key: DefId) -> ty::adjustment::CoerceUnsizedInfo {
799 desc { |tcx| "computing CoerceUnsized info for `{}`", tcx
.def_path_str(key
) }
800 separate_provide_extern
803 query
typeck_item_bodies(_
: ()) -> () {
804 desc { "type-checking all item bodies" }
807 query
typeck(key
: LocalDefId
) -> &'tcx ty
::TypeckResults
<'tcx
> {
808 desc { |tcx| "type-checking `{}`
", tcx.def_path_str(key.to_def_id()) }
809 cache_on_disk_if { true }
811 query typeck_const_arg(
812 key: (LocalDefId, DefId)
813 ) -> &'tcx ty::TypeckResults<'tcx> {
815 |tcx| "type-checking the
const argument `{}`
",
816 tcx.def_path_str(key.0.to_def_id()),
819 query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
820 desc { |tcx| "type-checking `{}`", tcx
.def_path_str(key
.to_def_id()) }
821 cache_on_disk_if { true }
822 load_cached(tcx
, id
) {
823 let typeck_results
: Option
<ty
::TypeckResults
<'tcx
>> = tcx
824 .on_disk_cache().as_ref()
825 .and_then(|c
| c
.try_load_query_result(*tcx
, id
));
827 typeck_results
.map(|x
| &*tcx
.arena
.alloc(x
))
831 query
used_trait_imports(key
: LocalDefId
) -> &'tcx FxHashSet
<LocalDefId
> {
832 desc { |tcx| "used_trait_imports `{}`
", tcx.def_path_str(key.to_def_id()) }
833 cache_on_disk_if { true }
836 query has_typeck_results(def_id: DefId) -> bool {
837 desc { |tcx| "checking whether `{}` has a body", tcx
.def_path_str(def_id
) }
840 query
coherent_trait(def_id
: DefId
) -> () {
841 desc { |tcx| "coherence checking all impls of trait `{}`
", tcx.def_path_str(def_id) }
844 /// Borrow-checks the function body. If this is a closure, returns
845 /// additional requirements that the closure's creator must verify.
846 query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
847 desc { |tcx| "borrow-checking `{}`", tcx
.def_path_str(key
.to_def_id()) }
848 cache_on_disk_if(tcx
) { tcx.is_typeck_child(key.to_def_id()) }
850 query
mir_borrowck_const_arg(key
: (LocalDefId
, DefId
)) -> &'tcx mir
::BorrowCheckResult
<'tcx
> {
852 |tcx
| "borrow-checking the const argument`{}`",
853 tcx
.def_path_str(key
.0.to_def_id())
857 /// Gets a complete map from all types to their inherent impls.
858 /// Not meant to be used directly outside of coherence.
859 query
crate_inherent_impls(k
: ()) -> CrateInherentImpls
{
860 storage(ArenaCacheSelector
<'tcx
>)
861 desc { "all inherent impls defined in crate" }
864 /// Checks all types in the crate for overlap in their inherent impls. Reports errors.
865 /// Not meant to be used directly outside of coherence.
866 query
crate_inherent_impls_overlap_check(_
: ()) -> () {
867 desc { "check for overlap between inherent impls defined in this crate" }
870 /// Checks whether all impls in the crate pass the overlap check, returning
871 /// which impls fail it. If all impls are correct, the returned slice is empty.
872 query
orphan_check_crate(_
: ()) -> &'tcx
[LocalDefId
] {
874 "checking whether the immpl in the this crate follow the orphan rules",
878 /// Check whether the function has any recursion that could cause the inliner to trigger
879 /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
880 /// current function, just all intermediate functions.
881 query
mir_callgraph_reachable(key
: (ty
::Instance
<'tcx
>, LocalDefId
)) -> bool
{
884 "computing if `{}` (transitively) calls `{}`",
886 tcx
.def_path_str(key
.1.to_def_id()),
890 /// Obtain all the calls into other local functions
891 query
mir_inliner_callees(key
: ty
::InstanceDef
<'tcx
>) -> &'tcx
[(DefId
, SubstsRef
<'tcx
>)] {
894 "computing all local function calls in `{}`",
895 tcx
.def_path_str(key
.def_id()),
899 /// Evaluates a constant and returns the computed allocation.
901 /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper.
902 query
eval_to_allocation_raw(key
: ty
::ParamEnvAnd
<'tcx
, GlobalId
<'tcx
>>)
903 -> EvalToAllocationRawResult
<'tcx
> {
905 "const-evaluating + checking `{}`",
906 key
.value
.display(tcx
)
908 cache_on_disk_if { true }
911 /// Evaluates const items or anonymous constants
912 /// (such as enum variant explicit discriminants or array lengths)
913 /// into a representation suitable for the type system and const generics.
915 /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
916 /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
917 query
eval_to_const_value_raw(key
: ty
::ParamEnvAnd
<'tcx
, GlobalId
<'tcx
>>)
918 -> EvalToConstValueResult
<'tcx
> {
920 "simplifying constant for the type system `{}`",
921 key
.value
.display(tcx
)
923 cache_on_disk_if { true }
926 /// Convert an evaluated constant to a type level constant or
927 /// return `None` if that is not possible.
928 query
const_to_valtree(
929 key
: ty
::ParamEnvAnd
<'tcx
, ConstAlloc
<'tcx
>>
930 ) -> Option
<ty
::ValTree
<'tcx
>> {
931 desc { "destructure constant" }
935 /// Destructure a constant ADT or array into its variant index and its
936 /// field values or return `None` if constant is invalid.
938 /// Use infallible `TyCtxt::destructure_const` when you know that constant is valid.
939 query
try_destructure_const(
940 key
: ty
::ParamEnvAnd
<'tcx
, ty
::Const
<'tcx
>>
941 ) -> Option
<mir
::DestructuredConst
<'tcx
>> {
942 desc { "destructure constant" }
946 /// Dereference a constant reference or raw pointer and turn the result into a constant
949 key
: ty
::ParamEnvAnd
<'tcx
, ty
::Const
<'tcx
>>
950 ) -> ty
::Const
<'tcx
> {
951 desc { "deref constant" }
955 query
const_caller_location(key
: (rustc_span
::Symbol
, u32, u32)) -> ConstValue
<'tcx
> {
956 desc { "get a &core::panic::Location referring to a span" }
959 // FIXME get rid of this with valtrees
961 key
: LitToConstInput
<'tcx
>
962 ) -> Result
<ty
::Const
<'tcx
>, LitToConstError
> {
963 desc { "converting literal to const" }
966 query
check_match(key
: DefId
) {
967 desc { |tcx| "match-checking `{}`
", tcx.def_path_str(key) }
968 cache_on_disk_if { key.is_local() }
971 /// Performs part of the privacy check and computes "access levels
".
972 query privacy_access_levels(_: ()) -> &'tcx AccessLevels {
974 desc { "privacy access levels" }
976 query check_private_in_public(_: ()) -> () {
978 desc { "checking for private elements in public interfaces" }
981 query reachable_set(_: ()) -> FxHashSet<LocalDefId> {
982 storage(ArenaCacheSelector<'tcx>)
983 desc { "reachability" }
986 /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
987 /// in the case of closures, this will be redirected to the enclosing function.
988 query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree {
989 desc { |tcx| "computing drop scopes for `{}`", tcx
.def_path_str(def_id
) }
992 /// Generates a MIR body for the shim.
993 query
mir_shims(key
: ty
::InstanceDef
<'tcx
>) -> mir
::Body
<'tcx
> {
994 storage(ArenaCacheSelector
<'tcx
>)
995 desc { |tcx| "generating MIR shim for `{}`
", tcx.def_path_str(key.def_id()) }
998 /// The `symbol_name` query provides the symbol name for calling a
999 /// given instance from the local crate. In particular, it will also
1000 /// look up the correct symbol name of instances from upstream crates.
1001 query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
1002 desc { "computing the symbol for `{}`", key
}
1003 cache_on_disk_if { true }
1006 query
opt_def_kind(def_id
: DefId
) -> Option
<DefKind
> {
1007 desc { |tcx| "looking up definition kind of `{}`
", tcx.def_path_str(def_id) }
1008 separate_provide_extern
1011 /// Gets the span for the definition.
1012 query def_span(def_id: DefId) -> Span {
1013 desc { |tcx| "looking up span for `{}`", tcx
.def_path_str(def_id
) }
1014 separate_provide_extern
1017 /// Gets the span for the identifier of the definition.
1018 query
def_ident_span(def_id
: DefId
) -> Option
<Span
> {
1019 desc { |tcx| "looking up span for `{}`'s identifier
", tcx.def_path_str(def_id) }
1020 separate_provide_extern
1023 query lookup_stability(def_id: DefId) -> Option<attr::Stability> {
1024 desc { |tcx| "looking up stability of `{}`", tcx
.def_path_str(def_id
) }
1025 separate_provide_extern
1028 query
lookup_const_stability(def_id
: DefId
) -> Option
<attr
::ConstStability
> {
1029 desc { |tcx| "looking up const stability of `{}`
", tcx.def_path_str(def_id) }
1030 separate_provide_extern
1033 query should_inherit_track_caller(def_id: DefId) -> bool {
1034 desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx
.def_path_str(def_id
) }
1037 query
lookup_deprecation_entry(def_id
: DefId
) -> Option
<DeprecationEntry
> {
1038 desc { |tcx| "checking whether `{}` is deprecated
", tcx.def_path_str(def_id) }
1039 separate_provide_extern
1042 /// Determines whether an item is annotated with `doc(hidden)`.
1043 query is_doc_hidden(def_id: DefId) -> bool {
1044 desc { |tcx| "checking whether `{}` is `doc(hidden)`", tcx
.def_path_str(def_id
) }
1047 query
item_attrs(def_id
: DefId
) -> &'tcx
[ast
::Attribute
] {
1048 desc { |tcx| "collecting attributes of `{}`
", tcx.def_path_str(def_id) }
1049 separate_provide_extern
1052 query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs {
1053 desc { |tcx| "computing codegen attributes of `{}`", tcx
.def_path_str(def_id
) }
1054 storage(ArenaCacheSelector
<'tcx
>)
1055 cache_on_disk_if { true }
1058 query
asm_target_features(def_id
: DefId
) -> &'tcx FxHashSet
<Symbol
> {
1059 desc { |tcx| "computing target features for inline asm of `{}`
", tcx.def_path_str(def_id) }
1062 query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
1063 desc { |tcx| "looking up function parameter names for `{}`", tcx
.def_path_str(def_id
) }
1064 separate_provide_extern
1066 /// Gets the rendered value of the specified constant or associated constant.
1067 /// Used by rustdoc.
1068 query
rendered_const(def_id
: DefId
) -> String
{
1069 storage(ArenaCacheSelector
<'tcx
>)
1070 desc { |tcx| "rendering constant intializer of `{}`
", tcx.def_path_str(def_id) }
1071 separate_provide_extern
1073 query impl_parent(def_id: DefId) -> Option<DefId> {
1074 desc { |tcx| "computing specialization parent impl of `{}`", tcx
.def_path_str(def_id
) }
1075 separate_provide_extern
1078 /// Given an `associated_item`, find the trait it belongs to.
1079 /// Return `None` if the `DefId` is not an associated item.
1080 query
trait_of_item(associated_item
: DefId
) -> Option
<DefId
> {
1081 desc { |tcx| "finding trait defining `{}`
", tcx.def_path_str(associated_item) }
1082 separate_provide_extern
1085 query is_ctfe_mir_available(key: DefId) -> bool {
1086 desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx
.def_path_str(key
) }
1087 separate_provide_extern
1089 query
is_mir_available(key
: DefId
) -> bool
{
1090 desc { |tcx| "checking if item has mir available: `{}`
", tcx.def_path_str(key) }
1091 separate_provide_extern
1094 query own_existential_vtable_entries(
1095 key: ty::PolyExistentialTraitRef<'tcx>
1096 ) -> &'tcx [DefId] {
1097 desc { |tcx| "finding all existential vtable entries for trait {}", tcx
.def_path_str(key
.def_id()) }
1100 query
vtable_entries(key
: ty
::PolyTraitRef
<'tcx
>)
1101 -> &'tcx
[ty
::VtblEntry
<'tcx
>] {
1102 desc { |tcx| "finding all vtable entries for trait {}
", tcx.def_path_str(key.def_id()) }
1105 query vtable_trait_upcasting_coercion_new_vptr_slot(key: (ty::Ty<'tcx>, ty::Ty<'tcx>)) -> Option<usize> {
1106 desc { |tcx| "finding the slot within vtable for trait object {} vtable ptr during trait upcasting coercion from {} vtable",
1110 query
vtable_allocation(key
: (Ty
<'tcx
>, Option
<ty
::PolyExistentialTraitRef
<'tcx
>>)) -> mir
::interpret
::AllocId
{
1111 desc { |tcx| "vtable const allocation for <{}
as {}
>",
1113 key.1.map(|trait_ref| format!("{}
", trait_ref)).unwrap_or("_
".to_owned())
1117 query codegen_fulfill_obligation(
1118 key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
1119 ) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorGuaranteed> {
1120 cache_on_disk_if { true }
1122 "checking
if `{}` fulfills its obligations
",
1123 tcx.def_path_str(key.1.def_id())
1127 /// Return all `impl` blocks in the current crate.
1128 query all_local_trait_impls(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexMap<DefId, Vec<LocalDefId>> {
1129 desc { "local trait impls" }
1132 /// Given a trait `trait_id`, return all known `impl` blocks.
1133 query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls {
1134 storage(ArenaCacheSelector<'tcx>)
1135 desc { |tcx| "trait impls of `{}`", tcx
.def_path_str(trait_id
) }
1138 query
specialization_graph_of(trait_id
: DefId
) -> specialization_graph
::Graph
{
1139 storage(ArenaCacheSelector
<'tcx
>)
1140 desc { |tcx| "building specialization graph of trait `{}`
", tcx.def_path_str(trait_id) }
1141 cache_on_disk_if { true }
1143 query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] {
1144 desc { |tcx| "determine object safety of trait `{}`", tcx
.def_path_str(trait_id
) }
1147 /// Gets the ParameterEnvironment for a given item; this environment
1148 /// will be in "user-facing" mode, meaning that it is suitable for
1149 /// type-checking etc, and it does not normalize specializable
1150 /// associated types. This is almost always what you want,
1151 /// unless you are doing MIR optimizations, in which case you
1152 /// might want to use `reveal_all()` method to change modes.
1153 query
param_env(def_id
: DefId
) -> ty
::ParamEnv
<'tcx
> {
1154 desc { |tcx| "computing normalized predicates of `{}`
", tcx.def_path_str(def_id) }
1157 /// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
1158 /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
1159 /// as this method is more efficient.
1160 query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
1161 desc { |tcx| "computing revealed normalized predicates of `{}`", tcx
.def_path_str(def_id
) }
1164 /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
1165 /// `ty.is_copy()`, etc, since that will prune the environment where possible.
1166 query
is_copy_raw(env
: ty
::ParamEnvAnd
<'tcx
, Ty
<'tcx
>>) -> bool
{
1167 desc { "computing whether `{}` is `Copy`
", env.value }
1170 /// Query backing `Ty::is_sized`.
1171 query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1172 desc { "computing whether `{}` is `Sized`", env
.value
}
1175 /// Query backing `Ty::is_freeze`.
1176 query
is_freeze_raw(env
: ty
::ParamEnvAnd
<'tcx
, Ty
<'tcx
>>) -> bool
{
1177 desc { "computing whether `{}` is freeze
", env.value }
1180 /// Query backing `Ty::is_unpin`.
1181 query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1182 desc { "computing whether `{}` is `Unpin`", env
.value
}
1185 /// Query backing `Ty::needs_drop`.
1186 query
needs_drop_raw(env
: ty
::ParamEnvAnd
<'tcx
, Ty
<'tcx
>>) -> bool
{
1187 desc { "computing whether `{}` needs drop
", env.value }
1190 /// Query backing `Ty::has_significant_drop_raw`.
1191 query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1192 desc { "computing whether `{}` has a significant drop", env
.value
}
1196 /// Query backing `Ty::is_structural_eq_shallow`.
1198 /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
1200 query
has_structural_eq_impls(ty
: Ty
<'tcx
>) -> bool
{
1202 "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`",
1207 /// A list of types where the ADT requires drop if and only if any of
1208 /// those types require drop. If the ADT is known to always need drop
1209 /// then `Err(AlwaysRequiresDrop)` is returned.
1210 query
adt_drop_tys(def_id
: DefId
) -> Result
<&'tcx ty
::List
<Ty
<'tcx
>>, AlwaysRequiresDrop
> {
1211 desc { |tcx| "computing when `{}` needs drop
", tcx.def_path_str(def_id) }
1212 cache_on_disk_if { true }
1215 /// A list of types where the ADT requires drop if and only if any of those types
1216 /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
1217 /// is considered to not be significant. A drop is significant if it is implemented
1218 /// by the user or does anything that will have any observable behavior (other than
1219 /// freeing up memory). If the ADT is known to have a significant destructor then
1220 /// `Err(AlwaysRequiresDrop)` is returned.
1221 query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
1222 desc { |tcx| "computing when `{}` has a significant destructor", tcx
.def_path_str(def_id
) }
1223 cache_on_disk_if { false }
1226 /// Computes the layout of a type. Note that this implicitly
1227 /// executes in "reveal all" mode, and will normalize the input type.
1229 key
: ty
::ParamEnvAnd
<'tcx
, Ty
<'tcx
>>
1230 ) -> Result
<ty
::layout
::TyAndLayout
<'tcx
>, ty
::layout
::LayoutError
<'tcx
>> {
1231 desc { "computing layout of `{}`
", key.value }
1235 /// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
1237 /// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
1238 /// instead, where the instance is an `InstanceDef::Virtual`.
1239 query fn_abi_of_fn_ptr(
1240 key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
1241 ) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
1242 desc { "computing call ABI of `{}` function pointers", key
.value
.0 }
1246 /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
1247 /// direct calls to an `fn`.
1249 /// NB: that includes virtual calls, which are represented by "direct calls"
1250 /// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
1251 query
fn_abi_of_instance(
1252 key
: ty
::ParamEnvAnd
<'tcx
, (ty
::Instance
<'tcx
>, &'tcx ty
::List
<Ty
<'tcx
>>)>
1253 ) -> Result
<&'tcx abi
::call
::FnAbi
<'tcx
, Ty
<'tcx
>>, ty
::layout
::FnAbiError
<'tcx
>> {
1254 desc { "computing call ABI of `{}`
", key.value.0 }
1258 query dylib_dependency_formats(_: CrateNum)
1259 -> &'tcx [(CrateNum, LinkagePreference)] {
1260 desc { "dylib dependency formats of crate" }
1261 separate_provide_extern
1264 query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
1265 storage(ArenaCacheSelector<'tcx>)
1266 desc { "get the linkage format of all dependencies" }
1269 query is_compiler_builtins(_: CrateNum) -> bool {
1271 desc { "checking if the crate is_compiler_builtins" }
1272 separate_provide_extern
1274 query has_global_allocator(_: CrateNum) -> bool {
1275 // This query depends on untracked global state in CStore
1278 desc { "checking if the crate has_global_allocator" }
1279 separate_provide_extern
1281 query has_panic_handler(_: CrateNum) -> bool {
1283 desc { "checking if the crate has_panic_handler" }
1284 separate_provide_extern
1286 query is_profiler_runtime(_: CrateNum) -> bool {
1288 desc { "query a crate is `#![profiler_runtime]`" }
1289 separate_provide_extern
1291 query panic_strategy(_: CrateNum) -> PanicStrategy {
1293 desc { "query a crate's configured panic strategy" }
1294 separate_provide_extern
1296 query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
1298 desc { "query a crate's configured panic-in-drop strategy" }
1299 separate_provide_extern
1301 query is_no_builtins(_: CrateNum) -> bool {
1303 desc { "test whether a crate has `#![no_builtins]`" }
1304 separate_provide_extern
1306 query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
1308 desc { "query a crate's symbol mangling version" }
1309 separate_provide_extern
1312 query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
1314 desc { "getting crate's ExternCrateData" }
1315 separate_provide_extern
1318 query specializes(_: (DefId, DefId)) -> bool {
1319 desc { "computing whether impls specialize one another" }
1321 query in_scope_traits_map(_: LocalDefId)
1322 -> Option<&'tcx FxHashMap<ItemLocalId, Box<[TraitCandidate]>>> {
1323 desc { "traits in scope at a block" }
1326 query module_reexports(def_id: LocalDefId) -> Option<&'tcx [ModChild]> {
1327 desc { |tcx| "looking up reexports of module `{}`", tcx
.def_path_str(def_id
.to_def_id()) }
1330 query
impl_defaultness(def_id
: DefId
) -> hir
::Defaultness
{
1331 desc { |tcx| "looking up whether `{}` is a
default impl", tcx.def_path_str(def_id) }
1332 separate_provide_extern
1335 query check_item_well_formed(key: LocalDefId) -> () {
1336 desc { |tcx| "checking that `{}` is well-formed", tcx
.def_path_str(key
.to_def_id()) }
1338 query
check_trait_item_well_formed(key
: LocalDefId
) -> () {
1339 desc { |tcx| "checking that `{}` is well
-formed
", tcx.def_path_str(key.to_def_id()) }
1341 query check_impl_item_well_formed(key: LocalDefId) -> () {
1342 desc { |tcx| "checking that `{}` is well-formed", tcx
.def_path_str(key
.to_def_id()) }
1345 // The `DefId`s of all non-generic functions and statics in the given crate
1346 // that can be reached from outside the crate.
1348 // We expect this items to be available for being linked to.
1350 // This query can also be called for `LOCAL_CRATE`. In this case it will
1351 // compute which items will be reachable to other crates, taking into account
1352 // the kind of crate that is currently compiled. Crates with only a
1353 // C interface have fewer reachable things.
1355 // Does not include external symbols that don't have a corresponding DefId,
1356 // like the compiler-generated `main` function and so on.
1357 query
reachable_non_generics(_
: CrateNum
)
1358 -> DefIdMap
<SymbolExportLevel
> {
1359 storage(ArenaCacheSelector
<'tcx
>)
1360 desc { "looking up the exported symbols of a crate" }
1361 separate_provide_extern
1363 query
is_reachable_non_generic(def_id
: DefId
) -> bool
{
1364 desc { |tcx| "checking whether `{}` is an exported symbol
", tcx.def_path_str(def_id) }
1365 separate_provide_extern
1367 query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
1369 "checking whether `{}` is reachable from outside the
crate",
1370 tcx.def_path_str(def_id.to_def_id()),
1374 /// The entire set of monomorphizations the local crate can safely link
1375 /// to because they are exported from upstream crates. Do not depend on
1376 /// this directly, as its value changes anytime a monomorphization gets
1377 /// added or removed in any upstream crate. Instead use the narrower
1378 /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
1379 /// better, `Instance::upstream_monomorphization()`.
1380 query upstream_monomorphizations(_: ()) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> {
1381 storage(ArenaCacheSelector<'tcx>)
1382 desc { "collecting available upstream monomorphizations" }
1385 /// Returns the set of upstream monomorphizations available for the
1386 /// generic function identified by the given `def_id`. The query makes
1387 /// sure to make a stable selection if the same monomorphization is
1388 /// available in multiple upstream crates.
1390 /// You likely want to call `Instance::upstream_monomorphization()`
1391 /// instead of invoking this query directly.
1392 query upstream_monomorphizations_for(def_id: DefId)
1393 -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>>
1395 storage(ArenaCacheSelector<'tcx>)
1397 "collecting available upstream monomorphizations
for `{}`
",
1398 tcx.def_path_str(def_id),
1400 separate_provide_extern
1403 /// Returns the upstream crate that exports drop-glue for the given
1404 /// type (`substs` is expected to be a single-item list containing the
1405 /// type one wants drop-glue for).
1407 /// This is a subset of `upstream_monomorphizations_for` in order to
1408 /// increase dep-tracking granularity. Otherwise adding or removing any
1409 /// type with drop-glue in any upstream crate would invalidate all
1410 /// functions calling drop-glue of an upstream type.
1412 /// You likely want to call `Instance::upstream_monomorphization()`
1413 /// instead of invoking this query directly.
1415 /// NOTE: This query could easily be extended to also support other
1416 /// common functions that have are large set of monomorphizations
1417 /// (like `Clone::clone` for example).
1418 query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> {
1419 desc { "available upstream drop-glue for `{:?}`", substs
}
1422 query
foreign_modules(_
: CrateNum
) -> FxHashMap
<DefId
, ForeignModule
> {
1423 storage(ArenaCacheSelector
<'tcx
>)
1424 desc { "looking up the foreign modules of a linked crate" }
1425 separate_provide_extern
1428 /// Identifies the entry-point (e.g., the `main` function) for a given
1429 /// crate, returning `None` if there is no entry point (such as for library crates).
1430 query
entry_fn(_
: ()) -> Option
<(DefId
, EntryFnType
)> {
1431 desc { "looking up the entry function of a crate" }
1433 query
proc_macro_decls_static(_
: ()) -> Option
<LocalDefId
> {
1434 desc { "looking up the derive registrar for a crate" }
1436 // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1437 // Changing the name should cause a compiler error, but in case that changes, be aware.
1438 query
crate_hash(_
: CrateNum
) -> Svh
{
1440 desc { "looking up the hash a crate" }
1441 separate_provide_extern
1443 query
crate_host_hash(_
: CrateNum
) -> Option
<Svh
> {
1445 desc { "looking up the hash of a host version of a crate" }
1446 separate_provide_extern
1448 query
extra_filename(_
: CrateNum
) -> String
{
1449 storage(ArenaCacheSelector
<'tcx
>)
1451 desc { "looking up the extra filename for a crate" }
1452 separate_provide_extern
1454 query
crate_extern_paths(_
: CrateNum
) -> Vec
<PathBuf
> {
1455 storage(ArenaCacheSelector
<'tcx
>)
1457 desc { "looking up the paths for extern crates" }
1458 separate_provide_extern
1461 /// Given a crate and a trait, look up all impls of that trait in the crate.
1462 /// Return `(impl_id, self_ty)`.
1463 query
implementations_of_trait(_
: (CrateNum
, DefId
)) -> &'tcx
[(DefId
, Option
<SimplifiedType
>)] {
1464 desc { "looking up implementations of a trait in a crate" }
1465 separate_provide_extern
1468 /// Collects all incoherent impls for the given crate and type.
1470 /// Do not call this directly, but instead use the `incoherent_impls` query.
1471 /// This query is only used to get the data necessary for that query.
1472 query
crate_incoherent_impls(key
: (CrateNum
, SimplifiedType
)) -> &'tcx
[DefId
] {
1473 desc { |tcx| "collecting all impls for a type in a crate" }
1474 separate_provide_extern
1477 query
is_dllimport_foreign_item(def_id
: DefId
) -> bool
{
1478 desc { |tcx| "is_dllimport_foreign_item({}
)", tcx.def_path_str(def_id) }
1480 query is_statically_included_foreign_item(def_id: DefId) -> bool {
1481 desc { |tcx| "is_statically_included_foreign_item({})", tcx
.def_path_str(def_id
) }
1483 query
native_library_kind(def_id
: DefId
)
1484 -> Option
<NativeLibKind
> {
1485 desc { |tcx| "native_library_kind({}
)", tcx.def_path_str(def_id) }
1488 /// Does lifetime resolution, but does not descend into trait items. This
1489 /// should only be used for resolving lifetimes of on trait definitions,
1490 /// and is used to avoid cycles. Importantly, `resolve_lifetimes` still visits
1491 /// the same lifetimes and is responsible for diagnostics.
1492 /// See `rustc_resolve::late::lifetimes for details.
1493 query resolve_lifetimes_trait_definition(_: LocalDefId) -> ResolveLifetimes {
1494 storage(ArenaCacheSelector<'tcx>)
1495 desc { "resolving lifetimes for a trait definition" }
1497 /// Does lifetime resolution on items. Importantly, we can't resolve
1498 /// lifetimes directly on things like trait methods, because of trait params.
1499 /// See `rustc_resolve::late::lifetimes for details.
1500 query resolve_lifetimes(_: LocalDefId) -> ResolveLifetimes {
1501 storage(ArenaCacheSelector<'tcx>)
1502 desc { "resolving lifetimes" }
1504 query named_region_map(_: LocalDefId) ->
1505 Option<&'tcx FxHashMap<ItemLocalId, Region>> {
1506 desc { "looking up a named region" }
1508 query is_late_bound_map(_: LocalDefId) ->
1509 Option<(LocalDefId, &'tcx FxHashSet<ItemLocalId>)> {
1510 desc { "testing if a region is late bound" }
1512 /// For a given item (like a struct), gets the default lifetimes to be used
1513 /// for each parameter if a trait object were to be passed for that parameter.
1514 /// For example, for `struct Foo<'a, T, U>`, this would be `['static, 'static]`.
1515 /// For `struct Foo<'a, T: 'a, U>`, this would instead be `['a, 'static]`.
1516 query object_lifetime_defaults(_: LocalDefId) -> Option<&'tcx [ObjectLifetimeDefault]> {
1517 desc { "looking up lifetime defaults for a region on an item" }
1519 query late_bound_vars_map(_: LocalDefId)
1520 -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
1521 desc { "looking up late bound vars" }
1524 query lifetime_scope_map(_: LocalDefId) -> Option<FxHashMap<ItemLocalId, LifetimeScopeForPath>> {
1525 storage(ArenaCacheSelector<'tcx>)
1526 desc { "finds the lifetime scope for an HirId of a PathSegment" }
1529 query visibility(def_id: DefId) -> ty::Visibility {
1530 desc { |tcx| "computing visibility of `{}`", tcx
.def_path_str(def_id
) }
1531 separate_provide_extern
1534 /// Computes the set of modules from which this type is visibly uninhabited.
1535 /// To check whether a type is uninhabited at all (not just from a given module), you could
1536 /// check whether the forest is empty.
1537 query
type_uninhabited_from(
1538 key
: ty
::ParamEnvAnd
<'tcx
, Ty
<'tcx
>>
1539 ) -> ty
::inhabitedness
::DefIdForest
<'tcx
> {
1540 desc { "computing the inhabitedness of `{:?}`
", key }
1544 query dep_kind(_: CrateNum) -> CrateDepKind {
1546 desc { "fetching what a dependency looks like" }
1547 separate_provide_extern
1550 /// Gets the name of the crate.
1551 query crate_name(_: CrateNum) -> Symbol {
1553 desc { "fetching what a crate is named" }
1554 separate_provide_extern
1556 query module_children(def_id: DefId) -> &'tcx [ModChild] {
1557 desc { |tcx| "collecting child items of module `{}`", tcx
.def_path_str(def_id
) }
1558 separate_provide_extern
1560 query
extern_mod_stmt_cnum(def_id
: LocalDefId
) -> Option
<CrateNum
> {
1561 desc { |tcx| "computing crate imported by `{}`
", tcx.def_path_str(def_id.to_def_id()) }
1564 query lib_features(_: ()) -> LibFeatures {
1565 storage(ArenaCacheSelector<'tcx>)
1566 desc { "calculating the lib features map" }
1568 query defined_lib_features(_: CrateNum)
1569 -> &'tcx [(Symbol, Option<Symbol>)] {
1570 desc { "calculating the lib features defined in a crate" }
1571 separate_provide_extern
1573 /// Returns the lang items defined in another crate by loading it from metadata.
1574 query get_lang_items(_: ()) -> LanguageItems {
1575 storage(ArenaCacheSelector<'tcx>)
1577 desc { "calculating the lang items map" }
1580 /// Returns all diagnostic items defined in all crates.
1581 query all_diagnostic_items(_: ()) -> rustc_hir::diagnostic_items::DiagnosticItems {
1582 storage(ArenaCacheSelector<'tcx>)
1584 desc { "calculating the diagnostic items map" }
1587 /// Returns the lang items defined in another crate by loading it from metadata.
1588 query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] {
1589 desc { "calculating the lang items defined in a crate" }
1590 separate_provide_extern
1593 /// Returns the diagnostic items defined in a crate.
1594 query diagnostic_items(_: CrateNum) -> rustc_hir::diagnostic_items::DiagnosticItems {
1595 storage(ArenaCacheSelector<'tcx>)
1596 desc { "calculating the diagnostic items map in a crate" }
1597 separate_provide_extern
1600 query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
1601 desc { "calculating the missing lang items in a crate" }
1602 separate_provide_extern
1604 query visible_parent_map(_: ()) -> DefIdMap<DefId> {
1605 storage(ArenaCacheSelector<'tcx>)
1606 desc { "calculating the visible parent map" }
1608 query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
1609 storage(ArenaCacheSelector<'tcx>)
1610 desc { "calculating trimmed def paths" }
1612 query missing_extern_crate_item(_: CrateNum) -> bool {
1614 desc { "seeing if we're missing an `extern crate` item for this crate" }
1615 separate_provide_extern
1617 query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
1618 storage(ArenaCacheSelector<'tcx>)
1620 desc { "looking at the source for a crate" }
1621 separate_provide_extern
1623 query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
1625 desc { "generating a postorder list of CrateNums" }
1627 /// Returns whether or not the crate with CrateNum 'cnum'
1628 /// is marked as a private dependency
1629 query is_private_dep(c: CrateNum) -> bool {
1631 desc { "check whether crate {} is a private dependency", c
}
1632 separate_provide_extern
1634 query
allocator_kind(_
: ()) -> Option
<AllocatorKind
> {
1636 desc { "allocator kind for the current crate" }
1639 query
upvars_mentioned(def_id
: DefId
) -> Option
<&'tcx FxIndexMap
<hir
::HirId
, hir
::Upvar
>> {
1640 desc { |tcx| "collecting upvars mentioned in `{}`
", tcx.def_path_str(def_id) }
1642 query maybe_unused_trait_import(def_id: LocalDefId) -> bool {
1643 desc { |tcx| "maybe_unused_trait_import for `{}`", tcx
.def_path_str(def_id
.to_def_id()) }
1645 query
maybe_unused_extern_crates(_
: ()) -> &'tcx
[(LocalDefId
, Span
)] {
1646 desc { "looking up all possibly unused extern crates" }
1648 query
names_imported_by_glob_use(def_id
: LocalDefId
) -> &'tcx FxHashSet
<Symbol
> {
1649 desc { |tcx| "names_imported_by_glob_use for `{}`
", tcx.def_path_str(def_id.to_def_id()) }
1652 query stability_index(_: ()) -> stability::Index {
1653 storage(ArenaCacheSelector<'tcx>)
1655 desc { "calculating the stability index for the local crate" }
1657 query crates(_: ()) -> &'tcx [CrateNum] {
1659 desc { "fetching all foreign CrateNum instances" }
1662 /// A list of all traits in a crate, used by rustdoc and error reporting.
1663 /// NOTE: Not named just `traits` due to a naming conflict.
1664 query traits_in_crate(_: CrateNum) -> &'tcx [DefId] {
1665 desc { "fetching all traits in a crate" }
1666 separate_provide_extern
1669 /// The list of symbols exported from the given crate.
1671 /// - All names contained in `exported_symbols(cnum)` are guaranteed to
1672 /// correspond to a publicly visible symbol in `cnum` machine code.
1673 /// - The `exported_symbols` sets of different crates do not intersect.
1674 query exported_symbols(_: CrateNum)
1675 -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] {
1676 desc { "exported_symbols" }
1677 separate_provide_extern
1680 query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
1682 desc { "collect_and_partition_mono_items" }
1684 query is_codegened_item(def_id: DefId) -> bool {
1685 desc { |tcx| "determining whether `{}` needs codegen", tcx
.def_path_str(def_id
) }
1688 /// All items participating in code generation together with items inlined into them.
1689 query
codegened_and_inlined_items(_
: ()) -> &'tcx DefIdSet
{
1691 desc { "codegened_and_inlined_items" }
1694 query
codegen_unit(_
: Symbol
) -> &'tcx CodegenUnit
<'tcx
> {
1695 desc { "codegen_unit" }
1697 query
unused_generic_params(key
: ty
::InstanceDef
<'tcx
>) -> FiniteBitSet
<u32> {
1698 cache_on_disk_if { key.def_id().is_local() }
1700 |tcx
| "determining which generic parameters are unused by `{}`",
1701 tcx
.def_path_str(key
.def_id())
1703 separate_provide_extern
1705 query
backend_optimization_level(_
: ()) -> OptLevel
{
1706 desc { "optimization level used by backend" }
1709 /// Return the filenames where output artefacts shall be stored.
1711 /// This query returns an `&Arc` because codegen backends need the value even after the `TyCtxt`
1712 /// has been destroyed.
1713 query
output_filenames(_
: ()) -> &'tcx Arc
<OutputFilenames
> {
1715 desc { "output_filenames" }
1718 /// Do not call this query directly: invoke `normalize` instead.
1719 query
normalize_projection_ty(
1720 goal
: CanonicalProjectionGoal
<'tcx
>
1722 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, NormalizationResult
<'tcx
>>>,
1725 desc { "normalizing `{:?}`
", goal }
1729 /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
1730 query try_normalize_generic_arg_after_erasing_regions(
1731 goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
1732 ) -> Result<GenericArg<'tcx>, NoSolution> {
1733 desc { "normalizing `{}`", goal
.value
}
1737 /// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
1738 query
try_normalize_mir_const_after_erasing_regions(
1739 goal
: ParamEnvAnd
<'tcx
, mir
::ConstantKind
<'tcx
>>
1740 ) -> Result
<mir
::ConstantKind
<'tcx
>, NoSolution
> {
1741 desc { "normalizing `{}`
", goal.value }
1745 query implied_outlives_bounds(
1746 goal: CanonicalTyGoal<'tcx>
1748 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
1751 desc { "computing implied outlives bounds for `{:?}`", goal
}
1755 /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
1756 query
dropck_outlives(
1757 goal
: CanonicalTyGoal
<'tcx
>
1759 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, DropckOutlivesResult
<'tcx
>>>,
1762 desc { "computing dropck types for `{:?}`
", goal }
1766 /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
1767 /// `infcx.predicate_must_hold()` instead.
1768 query evaluate_obligation(
1769 goal: CanonicalPredicateGoal<'tcx>
1770 ) -> Result<traits::EvaluationResult, traits::OverflowError> {
1771 desc { "evaluating trait selection obligation `{}`", goal
.value
.value
}
1774 query
evaluate_goal(
1775 goal
: traits
::CanonicalChalkEnvironmentAndGoal
<'tcx
>
1777 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, ()>>,
1780 desc { "evaluating trait selection obligation `{}`
", goal.value }
1783 /// Do not call this query directly: part of the `Eq` type-op
1784 query type_op_ascribe_user_type(
1785 goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
1787 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1790 desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal
}
1794 /// Do not call this query directly: part of the `Eq` type-op
1796 goal
: CanonicalTypeOpEqGoal
<'tcx
>
1798 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, ()>>,
1801 desc { "evaluating `type_op_eq` `{:?}`
", goal }
1805 /// Do not call this query directly: part of the `Subtype` type-op
1806 query type_op_subtype(
1807 goal: CanonicalTypeOpSubtypeGoal<'tcx>
1809 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
1812 desc { "evaluating `type_op_subtype` `{:?}`", goal
}
1816 /// Do not call this query directly: part of the `ProvePredicate` type-op
1817 query
type_op_prove_predicate(
1818 goal
: CanonicalTypeOpProvePredicateGoal
<'tcx
>
1820 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, ()>>,
1823 desc { "evaluating `type_op_prove_predicate` `{:?}`
", goal }
1826 /// Do not call this query directly: part of the `Normalize` type-op
1827 query type_op_normalize_ty(
1828 goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
1830 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
1833 desc { "normalizing `{:?}`", goal
}
1837 /// Do not call this query directly: part of the `Normalize` type-op
1838 query
type_op_normalize_predicate(
1839 goal
: CanonicalTypeOpNormalizeGoal
<'tcx
, ty
::Predicate
<'tcx
>>
1841 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, ty
::Predicate
<'tcx
>>>,
1844 desc { "normalizing `{:?}`
", goal }
1848 /// Do not call this query directly: part of the `Normalize` type-op
1849 query type_op_normalize_poly_fn_sig(
1850 goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
1852 &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
1855 desc { "normalizing `{:?}`", goal
}
1859 /// Do not call this query directly: part of the `Normalize` type-op
1860 query
type_op_normalize_fn_sig(
1861 goal
: CanonicalTypeOpNormalizeGoal
<'tcx
, ty
::FnSig
<'tcx
>>
1863 &'tcx Canonical
<'tcx
, canonical
::QueryResponse
<'tcx
, ty
::FnSig
<'tcx
>>>,
1866 desc { "normalizing `{:?}`
", goal }
1870 query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
1872 "impossible substituted predicates
:`{}`
",
1873 tcx.def_path_str(key.0)
1877 query method_autoderef_steps(
1878 goal: CanonicalTyGoal<'tcx>
1879 ) -> MethodAutoderefStepsResult<'tcx> {
1880 desc { "computing autoderef types for `{:?}`", goal
}
1884 query
supported_target_features(_
: CrateNum
) -> FxHashMap
<String
, Option
<Symbol
>> {
1885 storage(ArenaCacheSelector
<'tcx
>)
1887 desc { "looking up supported target features" }
1890 /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
1891 query
instance_def_size_estimate(def
: ty
::InstanceDef
<'tcx
>)
1893 desc { |tcx| "estimating size for `{}`
", tcx.def_path_str(def.def_id()) }
1896 query features_query(_: ()) -> &'tcx rustc_feature::Features {
1898 desc { "looking up enabled feature gates" }
1901 /// Attempt to resolve the given `DefId` to an `Instance`, for the
1902 /// given generics args (`SubstsRef`), returning one of:
1903 /// * `Ok(Some(instance))` on success
1904 /// * `Ok(None)` when the `SubstsRef` are still too generic,
1905 /// and therefore don't allow finding the final `Instance`
1906 /// * `Err(ErrorGuaranteed)` when the `Instance` resolution process
1907 /// couldn't complete due to errors elsewhere - this is distinct
1908 /// from `Ok(None)` to avoid misleading diagnostics when an error
1909 /// has already been/will be emitted, for the original cause
1910 query resolve_instance(
1911 key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
1912 ) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
1913 desc { "resolving instance `{}`", ty
::Instance
::new(key
.value
.0, key
.value
.1) }
1917 query
resolve_instance_of_const_arg(
1918 key
: ty
::ParamEnvAnd
<'tcx
, (LocalDefId
, DefId
, SubstsRef
<'tcx
>)>
1919 ) -> Result
<Option
<ty
::Instance
<'tcx
>>, ErrorGuaranteed
> {
1921 "resolving instance of the const argument `{}`",
1922 ty
::Instance
::new(key
.value
.0.to_def_id(), key
.value
.2),
1927 query
normalize_opaque_types(key
: &'tcx ty
::List
<ty
::Predicate
<'tcx
>>) -> &'tcx ty
::List
<ty
::Predicate
<'tcx
>> {
1928 desc { "normalizing opaque types in {:?}
", key }
1931 /// Checks whether a type is definitely uninhabited. This is
1932 /// conservative: for some types that are uninhabited we return `false`,
1933 /// but we only return `true` for types that are definitely uninhabited.
1934 /// `ty.conservative_is_privately_uninhabited` implies that any value of type `ty`
1935 /// will be `Abi::Uninhabited`. (Note that uninhabited types may have nonzero
1936 /// size, to account for partial initialisation. See #49298 for details.)
1937 query conservative_is_privately_uninhabited(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
1938 desc { "conservatively checking if {:?} is privately uninhabited", key
}
1942 query
limits(key
: ()) -> Limits
{
1943 desc { "looking up limits" }
1946 /// Performs an HIR-based well-formed check on the item with the given `HirId`. If
1947 /// we get an `Unimplemented` error that matches the provided `Predicate`, return
1948 /// the cause of the newly created obligation.
1950 /// This is only used by error-reporting code to get a better cause (in particular, a better
1951 /// span) for an *existing* error. Therefore, it is best-effort, and may never handle
1952 /// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
1953 /// because the `ty::Ty`-based wfcheck is always run.
1954 query
diagnostic_hir_wf_check(key
: (ty
::Predicate
<'tcx
>, traits
::WellFormedLoc
)) -> Option
<traits
::ObligationCause
<'tcx
>> {
1955 storage(ArenaCacheSelector
<'tcx
>)
1958 desc { "performing HIR wf-checking for predicate {:?} at item {:?}
", key.0, key.1 }
1962 /// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
1963 /// `--target` and similar).
1964 query global_backend_features(_: ()) -> Vec<String> {
1965 storage(ArenaCacheSelector<'tcx>)
1967 desc { "computing the backend features for CLI flags" }