]>
Commit | Line | Data |
---|---|---|
74b04a01 | 1 | use crate::dep_graph::SerializedDepNodeIndex; |
dfeec247 | 2 | use crate::mir::interpret::{GlobalId, LitToConstInput}; |
532ac7d7 XL |
3 | use crate::traits; |
4 | use crate::traits::query::{ | |
dfeec247 XL |
5 | CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, |
6 | CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal, | |
7 | CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, | |
532ac7d7 | 8 | }; |
dfeec247 | 9 | use crate::ty::query::queries; |
ba9703b0 | 10 | use crate::ty::subst::{GenericArg, SubstsRef}; |
dfeec247 | 11 | use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt}; |
ba9703b0 | 12 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; |
f9f354fc | 13 | use rustc_query_system::query::QueryDescription; |
532ac7d7 | 14 | |
dfeec247 | 15 | use rustc_span::symbol::Symbol; |
532ac7d7 | 16 | use std::borrow::Cow; |
dfeec247 | 17 | |
f035d41b | 18 | fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String { |
dfeec247 | 19 | if def_id.is_top_level_module() { |
74b04a01 | 20 | "top-level module".to_string() |
dfeec247 | 21 | } else { |
f035d41b | 22 | format!("module `{}`", tcx.def_path_str(def_id.to_def_id())) |
dfeec247 XL |
23 | } |
24 | } | |
532ac7d7 | 25 | |
532ac7d7 XL |
26 | // Each of these queries corresponds to a function pointer field in the |
27 | // `Providers` struct for requesting a value of that type, and a method | |
28 | // on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way | |
29 | // which memoizes and does dep-graph tracking, wrapping around the actual | |
30 | // `Providers` that the driver creates (using several `rustc_*` crates). | |
31 | // | |
32 | // The result type of each query must implement `Clone`, and additionally | |
33 | // `ty::query::values::Value`, which produces an appropriate placeholder | |
34 | // (error) value if the query resulted in a query cycle. | |
35 | // Queries marked with `fatal_cycle` do not need the latter implementation, | |
36 | // as they will raise an fatal error on query cycles instead. | |
37 | rustc_queries! { | |
60c5eb7d XL |
38 | Other { |
39 | query trigger_delay_span_bug(key: DefId) -> () { | |
40 | desc { "trigger a delay span bug" } | |
41 | } | |
42 | } | |
43 | ||
532ac7d7 | 44 | Other { |
74b04a01 XL |
45 | // Represents crate as a whole (as distinct from the top-level crate module). |
46 | // If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`), | |
47 | // we will have to assume that any change means that you need to be recompiled. | |
48 | // This is because the `hir_crate` query gives you access to all other items. | |
49 | // To avoid this fate, do not call `tcx.hir().krate()`; instead, | |
50 | // prefer wrappers like `tcx.visit_all_items_in_krate()`. | |
51 | query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> { | |
52 | eval_always | |
53 | no_hash | |
54 | desc { "get the crate HIR" } | |
55 | } | |
56 | ||
ba9703b0 XL |
57 | // The indexed HIR. This can be conveniently accessed by `tcx.hir()`. |
58 | // Avoid calling this query directly. | |
59 | query index_hir(_: CrateNum) -> &'tcx map::IndexedHir<'tcx> { | |
60 | eval_always | |
61 | no_hash | |
62 | desc { "index HIR" } | |
63 | } | |
64 | ||
65 | // The items in a module. | |
66 | // | |
67 | // This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`. | |
68 | // Avoid calling this query directly. | |
69 | query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems { | |
70 | eval_always | |
71 | desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) } | |
72 | } | |
73 | ||
74 | // Gives access to the HIR node for the HIR owner `key`. | |
75 | // | |
76 | // This can be conveniently accessed by methods on `tcx.hir()`. | |
77 | // Avoid calling this query directly. | |
78 | query hir_owner(key: LocalDefId) -> Option<&'tcx crate::hir::Owner<'tcx>> { | |
79 | eval_always | |
80 | desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) } | |
81 | } | |
82 | ||
83 | // Gives access to the HIR nodes and bodies inside the HIR owner `key`. | |
84 | // | |
85 | // This can be conveniently accessed by methods on `tcx.hir()`. | |
86 | // Avoid calling this query directly. | |
87 | query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx crate::hir::OwnerNodes<'tcx>> { | |
88 | eval_always | |
89 | desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) } | |
90 | } | |
91 | ||
532ac7d7 XL |
92 | /// Records the type of every item. |
93 | query type_of(key: DefId) -> Ty<'tcx> { | |
f9f354fc | 94 | desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) } |
dc9dc135 | 95 | cache_on_disk_if { key.is_local() } |
532ac7d7 XL |
96 | } |
97 | ||
74b04a01 XL |
98 | query analysis(key: CrateNum) -> Result<(), ErrorReported> { |
99 | eval_always | |
100 | desc { "running analysis passes on this crate" } | |
101 | } | |
102 | ||
532ac7d7 XL |
103 | /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its |
104 | /// associated generics. | |
f9f354fc XL |
105 | query generics_of(key: DefId) -> ty::Generics { |
106 | desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) } | |
107 | storage(ArenaCacheSelector<'tcx>) | |
dc9dc135 | 108 | cache_on_disk_if { key.is_local() } |
532ac7d7 XL |
109 | load_cached(tcx, id) { |
110 | let generics: Option<ty::Generics> = tcx.queries.on_disk_cache | |
111 | .try_load_query_result(tcx, id); | |
f9f354fc | 112 | generics |
532ac7d7 XL |
113 | } |
114 | } | |
115 | ||
116 | /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the | |
117 | /// predicates (where-clauses) that must be proven true in order | |
118 | /// to reference it. This is almost always the "predicates query" | |
119 | /// that you want. | |
120 | /// | |
121 | /// `predicates_of` builds on `predicates_defined_on` -- in fact, | |
122 | /// it is almost always the same as that query, except for the | |
123 | /// case of traits. For traits, `predicates_of` contains | |
124 | /// an additional `Self: Trait<...>` predicate that users don't | |
125 | /// actually write. This reflects the fact that to invoke the | |
126 | /// trait (e.g., via `Default::default`) you must supply types | |
127 | /// that actually implement the trait. (However, this extra | |
128 | /// predicate gets in the way of some checks, which are intended | |
129 | /// to operate over only the actual where-clauses written by the | |
130 | /// user.) | |
e74abb32 | 131 | query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { |
f9f354fc | 132 | desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } |
dc9dc135 XL |
133 | cache_on_disk_if { key.is_local() } |
134 | } | |
532ac7d7 | 135 | |
f035d41b XL |
136 | /// Returns the list of predicates that can be used for |
137 | /// `SelectionCandidate::ProjectionCandidate` and | |
138 | /// `ProjectionTyCandidate::TraitDef`. | |
139 | /// Specifically this is the bounds (equivalent to) those | |
140 | /// written on the trait's type definition, or those | |
141 | /// after the `impl` keyword | |
142 | /// | |
143 | /// type X: Bound + 'lt | |
144 | /// ^^^^^^^^^^^ | |
145 | /// impl Debug + Display | |
146 | /// ^^^^^^^^^^^^^^^ | |
147 | /// | |
148 | /// `key` is the `DefId` of the associated type or opaque type. | |
149 | query projection_predicates(key: DefId) -> &'tcx ty::List<ty::Predicate<'tcx>> { | |
150 | desc { |tcx| "finding projection predicates for `{}`", tcx.def_path_str(key) } | |
151 | } | |
152 | ||
f9f354fc | 153 | query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLib>> { |
532ac7d7 XL |
154 | desc { "looking up the native libraries of a linked crate" } |
155 | } | |
156 | ||
f9f354fc XL |
157 | query lint_levels(_: CrateNum) -> LintLevelMap { |
158 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
159 | eval_always |
160 | desc { "computing the lint levels for items in this crate" } | |
161 | } | |
74b04a01 | 162 | |
ba9703b0 | 163 | query parent_module_from_def_id(key: LocalDefId) -> LocalDefId { |
74b04a01 | 164 | eval_always |
ba9703b0 | 165 | desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) } |
74b04a01 | 166 | } |
532ac7d7 XL |
167 | } |
168 | ||
169 | Codegen { | |
170 | query is_panic_runtime(_: CrateNum) -> bool { | |
171 | fatal_cycle | |
172 | desc { "checking if the crate is_panic_runtime" } | |
173 | } | |
174 | } | |
175 | ||
176 | Codegen { | |
177 | /// Set of all the `DefId`s in this crate that have MIR associated with | |
178 | /// them. This includes all the body owners, but also things like struct | |
179 | /// constructors. | |
f9f354fc XL |
180 | query mir_keys(_: CrateNum) -> FxHashSet<LocalDefId> { |
181 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
182 | desc { "getting a list of all mir_keys" } |
183 | } | |
184 | ||
dc9dc135 | 185 | /// Maps DefId's that have an associated `mir::Body` to the result |
60c5eb7d XL |
186 | /// of the MIR const-checking pass. This is the set of qualifs in |
187 | /// the final value of a `const`. | |
188 | query mir_const_qualif(key: DefId) -> mir::ConstQualifs { | |
e74abb32 | 189 | desc { |tcx| "const checking `{}`", tcx.def_path_str(key) } |
dc9dc135 | 190 | cache_on_disk_if { key.is_local() } |
532ac7d7 XL |
191 | } |
192 | ||
193 | /// Fetch the MIR for a given `DefId` right after it's built - this includes | |
194 | /// unreachable code. | |
f9f354fc XL |
195 | query mir_built(key: LocalDefId) -> Steal<mir::Body<'tcx>> { |
196 | storage(ArenaCacheSelector<'tcx>) | |
197 | desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.to_def_id()) } | |
74b04a01 | 198 | } |
532ac7d7 XL |
199 | |
200 | /// Fetch the MIR for a given `DefId` up till the point where it is | |
f9f354fc | 201 | /// ready for const qualification. |
532ac7d7 XL |
202 | /// |
203 | /// See the README for the `mir` module for details. | |
f9f354fc XL |
204 | query mir_const(key: DefId) -> Steal<mir::Body<'tcx>> { |
205 | desc { |tcx| "processing MIR for `{}`", tcx.def_path_str(key) } | |
206 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
207 | no_hash |
208 | } | |
209 | ||
f035d41b XL |
210 | query mir_drops_elaborated_and_const_checked(key: LocalDefId) -> Steal<mir::Body<'tcx>> { |
211 | storage(ArenaCacheSelector<'tcx>) | |
212 | no_hash | |
213 | desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.to_def_id()) } | |
214 | } | |
215 | ||
f9f354fc | 216 | query mir_validated(key: LocalDefId) -> |
e1599b0c | 217 | ( |
f9f354fc XL |
218 | Steal<mir::Body<'tcx>>, |
219 | Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>> | |
e1599b0c | 220 | ) { |
f9f354fc | 221 | storage(ArenaCacheSelector<'tcx>) |
532ac7d7 | 222 | no_hash |
f9f354fc | 223 | desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) } |
532ac7d7 XL |
224 | } |
225 | ||
226 | /// MIR after our optimization passes have run. This is MIR that is ready | |
227 | /// for codegen. This is also the only query that can fetch non-local MIR, at present. | |
f9f354fc XL |
228 | query optimized_mir(key: DefId) -> mir::Body<'tcx> { |
229 | desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) } | |
230 | storage(ArenaCacheSelector<'tcx>) | |
dc9dc135 | 231 | cache_on_disk_if { key.is_local() } |
532ac7d7 | 232 | } |
416331ca | 233 | |
f035d41b XL |
234 | /// Returns coverage summary info for a function, after executing the `InstrumentCoverage` |
235 | /// MIR pass (assuming the -Zinstrument-coverage option is enabled). | |
236 | query coverageinfo(key: DefId) -> mir::CoverageInfo { | |
237 | desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key) } | |
238 | storage(ArenaCacheSelector<'tcx>) | |
239 | cache_on_disk_if { key.is_local() } | |
240 | } | |
241 | ||
f9f354fc XL |
242 | query promoted_mir(key: DefId) -> IndexVec<mir::Promoted, mir::Body<'tcx>> { |
243 | desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) } | |
244 | storage(ArenaCacheSelector<'tcx>) | |
e1599b0c | 245 | cache_on_disk_if { key.is_local() } |
e1599b0c | 246 | } |
532ac7d7 XL |
247 | } |
248 | ||
249 | TypeChecking { | |
250 | // Erases regions from `ty` to yield a new type. | |
251 | // Normally you would just use `tcx.erase_regions(&value)`, | |
252 | // however, which uses this query as a kind of cache. | |
253 | query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> { | |
254 | // This query is not expected to have input -- as a result, it | |
255 | // is not a good candidates for "replay" because it is essentially a | |
256 | // pure function of its input (and hence the expectation is that | |
257 | // no caller would be green **apart** from just these | |
258 | // queries). Making it anonymous avoids hashing the result, which | |
259 | // may save a bit of time. | |
260 | anon | |
532ac7d7 XL |
261 | desc { "erasing regions from `{:?}`", ty } |
262 | } | |
532ac7d7 XL |
263 | } |
264 | ||
265 | Linking { | |
f9f354fc XL |
266 | query wasm_import_module_map(_: CrateNum) -> FxHashMap<DefId, String> { |
267 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
268 | desc { "wasm import module map" } |
269 | } | |
270 | } | |
271 | ||
272 | Other { | |
273 | /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the | |
274 | /// predicates (where-clauses) directly defined on it. This is | |
275 | /// equal to the `explicit_predicates_of` predicates plus the | |
276 | /// `inferred_outlives_of` predicates. | |
f9f354fc XL |
277 | query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> { |
278 | desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } | |
279 | } | |
532ac7d7 | 280 | |
dc9dc135 | 281 | /// Returns the predicates written explicitly by the user. |
f9f354fc XL |
282 | query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { |
283 | desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) } | |
284 | } | |
532ac7d7 XL |
285 | |
286 | /// Returns the inferred outlives predicates (e.g., for `struct | |
287 | /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`). | |
f9f354fc XL |
288 | query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] { |
289 | desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) } | |
290 | } | |
532ac7d7 XL |
291 | |
292 | /// Maps from the `DefId` of a trait to the list of | |
293 | /// super-predicates. This is a subset of the full list of | |
294 | /// predicates. We store these in a separate map because we must | |
295 | /// evaluate them even during type conversion, often before the | |
296 | /// full predicates are available (note that supertraits have | |
297 | /// additional acyclicity requirements). | |
e74abb32 | 298 | query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { |
532ac7d7 XL |
299 | desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) } |
300 | } | |
301 | ||
302 | /// To avoid cycles within the predicates of a single item we compute | |
303 | /// per-type-parameter predicates for resolving `T::AssocTy`. | |
f9f354fc | 304 | query type_param_predicates(key: (DefId, LocalDefId)) -> ty::GenericPredicates<'tcx> { |
532ac7d7 | 305 | desc { |tcx| "computing the bounds for type parameter `{}`", { |
f9f354fc | 306 | let id = tcx.hir().as_local_hir_id(key.1); |
532ac7d7 XL |
307 | tcx.hir().ty_param_name(id) |
308 | }} | |
309 | } | |
310 | ||
f9f354fc XL |
311 | query trait_def(key: DefId) -> ty::TraitDef { |
312 | desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) } | |
313 | storage(ArenaCacheSelector<'tcx>) | |
314 | } | |
315 | query adt_def(key: DefId) -> &'tcx ty::AdtDef { | |
316 | desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) } | |
317 | } | |
318 | query adt_destructor(key: DefId) -> Option<ty::Destructor> { | |
319 | desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) } | |
320 | } | |
532ac7d7 XL |
321 | |
322 | // The cycle error here should be reported as an error by `check_representable`. | |
323 | // We consider the type as Sized in the meanwhile to avoid | |
324 | // further errors (done in impl Value for AdtSizedConstraint). | |
325 | // Use `cycle_delay_bug` to delay the cycle error here to be emitted later | |
326 | // in case we accidentally otherwise don't emit an error. | |
327 | query adt_sized_constraint( | |
f9f354fc | 328 | key: DefId |
532ac7d7 | 329 | ) -> AdtSizedConstraint<'tcx> { |
f9f354fc | 330 | desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) } |
532ac7d7 XL |
331 | cycle_delay_bug |
332 | } | |
333 | ||
334 | query adt_dtorck_constraint( | |
f9f354fc XL |
335 | key: DefId |
336 | ) -> Result<DtorckConstraint<'tcx>, NoSolution> { | |
337 | desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) } | |
338 | } | |
532ac7d7 | 339 | |
dc9dc135 XL |
340 | /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate |
341 | /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might | |
342 | /// not have the feature gate active). | |
532ac7d7 XL |
343 | /// |
344 | /// **Do not call this function manually.** It is only meant to cache the base data for the | |
345 | /// `is_const_fn` function. | |
346 | query is_const_fn_raw(key: DefId) -> bool { | |
347 | desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) } | |
348 | } | |
349 | ||
74b04a01 XL |
350 | /// Returns `true` if this is a const `impl`. **Do not call this function manually.** |
351 | /// | |
352 | /// This query caches the base data for the `is_const_impl` helper function, which also | |
353 | /// takes into account stability attributes (e.g., `#[rustc_const_unstable]`). | |
354 | query is_const_impl_raw(key: DefId) -> bool { | |
355 | desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) } | |
356 | } | |
357 | ||
e1599b0c XL |
358 | query asyncness(key: DefId) -> hir::IsAsync { |
359 | desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) } | |
360 | } | |
361 | ||
dc9dc135 | 362 | /// Returns `true` if calls to the function may be promoted. |
532ac7d7 XL |
363 | /// |
364 | /// This is either because the function is e.g., a tuple-struct or tuple-variant | |
365 | /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should | |
366 | /// be removed in the future in favour of some form of check which figures out whether the | |
367 | /// function does not inspect the bits of any of its arguments (so is essentially just a | |
368 | /// constructor function). | |
f9f354fc XL |
369 | query is_promotable_const_fn(key: DefId) -> bool { |
370 | desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) } | |
371 | } | |
532ac7d7 | 372 | |
f9f354fc XL |
373 | query const_fn_is_allowed_fn_ptr(key: DefId) -> bool { |
374 | desc { |tcx| "checking if const fn allows `fn()` types: `{}`", tcx.def_path_str(key) } | |
375 | } | |
48663c56 | 376 | |
dc9dc135 | 377 | /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`). |
f9f354fc XL |
378 | query is_foreign_item(key: DefId) -> bool { |
379 | desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) } | |
380 | } | |
532ac7d7 | 381 | |
48663c56 | 382 | /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item. |
f9f354fc XL |
383 | query static_mutability(def_id: DefId) -> Option<hir::Mutability> { |
384 | desc { |tcx| "looking up static mutability of `{}`", tcx.def_path_str(def_id) } | |
385 | } | |
48663c56 | 386 | |
74b04a01 | 387 | /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator. |
f9f354fc XL |
388 | query generator_kind(def_id: DefId) -> Option<hir::GeneratorKind> { |
389 | desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) } | |
390 | } | |
74b04a01 | 391 | |
dc9dc135 | 392 | /// Gets a map with the variance of every item; use `item_variance` instead. |
f9f354fc XL |
393 | query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> { |
394 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
395 | desc { "computing the variances for items in this crate" } |
396 | } | |
397 | ||
dc9dc135 | 398 | /// Maps from the `DefId` of a type or region parameter to its (inferred) variance. |
f9f354fc XL |
399 | query variances_of(def_id: DefId) -> &'tcx [ty::Variance] { |
400 | desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) } | |
401 | } | |
532ac7d7 XL |
402 | } |
403 | ||
404 | TypeChecking { | |
dc9dc135 | 405 | /// Maps from thee `DefId` of a type to its (inferred) outlives. |
532ac7d7 | 406 | query inferred_outlives_crate(_: CrateNum) |
f9f354fc XL |
407 | -> ty::CratePredicatesMap<'tcx> { |
408 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
409 | desc { "computing the inferred outlives predicates for items in this crate" } |
410 | } | |
411 | } | |
412 | ||
413 | Other { | |
dc9dc135 | 414 | /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items. |
f9f354fc XL |
415 | query associated_item_def_ids(key: DefId) -> &'tcx [DefId] { |
416 | desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) } | |
417 | } | |
532ac7d7 | 418 | |
dc9dc135 | 419 | /// Maps from a trait item to the trait item "descriptor". |
f9f354fc XL |
420 | query associated_item(key: DefId) -> ty::AssocItem { |
421 | desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) } | |
422 | storage(ArenaCacheSelector<'tcx>) | |
423 | } | |
532ac7d7 | 424 | |
74b04a01 | 425 | /// Collects the associated items defined on a trait or impl. |
f9f354fc XL |
426 | query associated_items(key: DefId) -> ty::AssociatedItems<'tcx> { |
427 | storage(ArenaCacheSelector<'tcx>) | |
74b04a01 XL |
428 | desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) } |
429 | } | |
430 | ||
f9f354fc XL |
431 | query impl_trait_ref(key: DefId) -> Option<ty::TraitRef<'tcx>> { |
432 | desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(key) } | |
433 | } | |
434 | query impl_polarity(key: DefId) -> ty::ImplPolarity { | |
435 | desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(key) } | |
436 | } | |
532ac7d7 | 437 | |
f9f354fc XL |
438 | query issue33140_self_ty(key: DefId) -> Option<ty::Ty<'tcx>> { |
439 | desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) } | |
440 | } | |
532ac7d7 XL |
441 | } |
442 | ||
443 | TypeChecking { | |
dc9dc135 | 444 | /// Maps a `DefId` of a type to a list of its inherent impls. |
532ac7d7 XL |
445 | /// Contains implementations of methods that are inherent to a type. |
446 | /// Methods in these implementations don't need to be exported. | |
f9f354fc XL |
447 | query inherent_impls(key: DefId) -> &'tcx [DefId] { |
448 | desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) } | |
532ac7d7 XL |
449 | eval_always |
450 | } | |
451 | } | |
452 | ||
453 | TypeChecking { | |
454 | /// The result of unsafety-checking this `DefId`. | |
f9f354fc XL |
455 | query unsafety_check_result(key: LocalDefId) -> mir::UnsafetyCheckResult { |
456 | desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) } | |
457 | cache_on_disk_if { true } | |
458 | storage(ArenaCacheSelector<'tcx>) | |
dc9dc135 | 459 | } |
532ac7d7 | 460 | |
f9f354fc XL |
461 | /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error. |
462 | /// | |
463 | /// Unsafety checking is executed for each method separately, but we only want | |
464 | /// to emit this error once per derive. As there are some impls with multiple | |
465 | /// methods, we use a query for deduplication. | |
466 | query unsafe_derive_on_repr_packed(key: LocalDefId) -> () { | |
467 | desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) } | |
468 | } | |
532ac7d7 | 469 | |
f9f354fc XL |
470 | /// The signature of functions. |
471 | query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> { | |
472 | desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } | |
473 | } | |
532ac7d7 XL |
474 | } |
475 | ||
476 | Other { | |
f9f354fc | 477 | query lint_mod(key: LocalDefId) -> () { |
f035d41b | 478 | desc { |tcx| "linting {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
479 | } |
480 | ||
dc9dc135 | 481 | /// Checks the attributes in the module. |
f035d41b | 482 | query check_mod_attrs(key: LocalDefId) -> () { |
dfeec247 | 483 | desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
484 | } |
485 | ||
f035d41b | 486 | query check_mod_unstable_api_usage(key: LocalDefId) -> () { |
dfeec247 | 487 | desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
488 | } |
489 | ||
60c5eb7d | 490 | /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`). |
f035d41b | 491 | query check_mod_const_bodies(key: LocalDefId) -> () { |
dfeec247 | 492 | desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) } |
60c5eb7d XL |
493 | } |
494 | ||
dc9dc135 | 495 | /// Checks the loops in the module. |
f035d41b | 496 | query check_mod_loops(key: LocalDefId) -> () { |
dfeec247 | 497 | desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
498 | } |
499 | ||
f035d41b | 500 | query check_mod_item_types(key: LocalDefId) -> () { |
dfeec247 | 501 | desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
502 | } |
503 | ||
f9f354fc | 504 | query check_mod_privacy(key: LocalDefId) -> () { |
f035d41b | 505 | desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
506 | } |
507 | ||
f035d41b | 508 | query check_mod_intrinsics(key: LocalDefId) -> () { |
dfeec247 | 509 | desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
510 | } |
511 | ||
f035d41b | 512 | query check_mod_liveness(key: LocalDefId) -> () { |
dfeec247 | 513 | desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
514 | } |
515 | ||
f035d41b | 516 | query check_mod_impl_wf(key: LocalDefId) -> () { |
dfeec247 | 517 | desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
518 | } |
519 | ||
f035d41b | 520 | query collect_mod_item_types(key: LocalDefId) -> () { |
dfeec247 | 521 | desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) } |
532ac7d7 XL |
522 | } |
523 | ||
dc9dc135 | 524 | /// Caches `CoerceUnsized` kinds for impls on custom types. |
f9f354fc XL |
525 | query coerce_unsized_info(key: DefId) |
526 | -> ty::adjustment::CoerceUnsizedInfo { | |
527 | desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) } | |
528 | } | |
532ac7d7 XL |
529 | } |
530 | ||
531 | TypeChecking { | |
532 | query typeck_item_bodies(_: CrateNum) -> () { | |
533 | desc { "type-checking all item bodies" } | |
534 | } | |
535 | ||
f9f354fc XL |
536 | query typeck_tables_of(key: LocalDefId) -> &'tcx ty::TypeckTables<'tcx> { |
537 | desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) } | |
538 | cache_on_disk_if { true } | |
532ac7d7 | 539 | } |
f9f354fc XL |
540 | query diagnostic_only_typeck_tables_of(key: LocalDefId) -> &'tcx ty::TypeckTables<'tcx> { |
541 | desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) } | |
542 | cache_on_disk_if { true } | |
dfeec247 XL |
543 | load_cached(tcx, id) { |
544 | let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx | |
545 | .queries.on_disk_cache | |
546 | .try_load_query_result(tcx, id); | |
547 | ||
f9f354fc | 548 | typeck_tables.map(|x| &*tcx.arena.alloc(x)) |
dfeec247 XL |
549 | } |
550 | } | |
532ac7d7 XL |
551 | } |
552 | ||
553 | Other { | |
f035d41b | 554 | query used_trait_imports(key: LocalDefId) -> &'tcx FxHashSet<LocalDefId> { |
f9f354fc XL |
555 | desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) } |
556 | cache_on_disk_if { true } | |
dc9dc135 | 557 | } |
532ac7d7 XL |
558 | } |
559 | ||
560 | TypeChecking { | |
f9f354fc XL |
561 | query has_typeck_tables(def_id: DefId) -> bool { |
562 | desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) } | |
563 | } | |
532ac7d7 XL |
564 | |
565 | query coherent_trait(def_id: DefId) -> () { | |
566 | desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) } | |
567 | } | |
568 | } | |
569 | ||
570 | BorrowChecking { | |
dc9dc135 | 571 | /// Borrow-checks the function body. If this is a closure, returns |
532ac7d7 | 572 | /// additional requirements that the closure's creator must verify. |
f9f354fc XL |
573 | query mir_borrowck(key: LocalDefId) -> mir::BorrowCheckResult<'tcx> { |
574 | storage(ArenaCacheSelector<'tcx>) | |
575 | desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) } | |
74b04a01 | 576 | cache_on_disk_if(tcx, opt_result) { |
f9f354fc XL |
577 | tcx.is_closure(key.to_def_id()) |
578 | || opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty()) | |
74b04a01 | 579 | } |
dc9dc135 | 580 | } |
532ac7d7 XL |
581 | } |
582 | ||
583 | TypeChecking { | |
584 | /// Gets a complete map from all types to their inherent impls. | |
585 | /// Not meant to be used directly outside of coherence. | |
586 | /// (Defined only for `LOCAL_CRATE`.) | |
587 | query crate_inherent_impls(k: CrateNum) | |
f9f354fc XL |
588 | -> CrateInherentImpls { |
589 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
590 | eval_always |
591 | desc { "all inherent impls defined in crate `{:?}`", k } | |
592 | } | |
593 | ||
594 | /// Checks all types in the crate for overlap in their inherent impls. Reports errors. | |
595 | /// Not meant to be used directly outside of coherence. | |
596 | /// (Defined only for `LOCAL_CRATE`.) | |
597 | query crate_inherent_impls_overlap_check(_: CrateNum) | |
598 | -> () { | |
599 | eval_always | |
600 | desc { "check for overlap between inherent impls defined in this crate" } | |
601 | } | |
602 | } | |
603 | ||
604 | Other { | |
dc9dc135 | 605 | /// Evaluates a constant without running sanity checks. |
532ac7d7 XL |
606 | /// |
607 | /// **Do not use this** outside const eval. Const eval uses this to break query cycles | |
608 | /// during validation. Please add a comment to every use site explaining why using | |
dfeec247 XL |
609 | /// `const_eval_validated` isn't sufficient. The returned constant also isn't in a suitable |
610 | /// form to be used outside of const eval. | |
532ac7d7 XL |
611 | query const_eval_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) |
612 | -> ConstEvalRawResult<'tcx> { | |
532ac7d7 XL |
613 | desc { |tcx| |
614 | "const-evaluating `{}`", | |
615 | tcx.def_path_str(key.value.instance.def.def_id()) | |
616 | } | |
532ac7d7 XL |
617 | } |
618 | ||
619 | /// Results of evaluating const items or constants embedded in | |
620 | /// other items (such as enum variant explicit discriminants). | |
dfeec247 XL |
621 | /// |
622 | /// In contrast to `const_eval_raw` this performs some validation on the constant, and | |
623 | /// returns a proper constant that is usable by the rest of the compiler. | |
624 | /// | |
625 | /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`, | |
74b04a01 | 626 | /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`. |
dfeec247 | 627 | query const_eval_validated(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) |
532ac7d7 | 628 | -> ConstEvalResult<'tcx> { |
532ac7d7 XL |
629 | desc { |tcx| |
630 | "const-evaluating + checking `{}`", | |
631 | tcx.def_path_str(key.value.instance.def.def_id()) | |
632 | } | |
dc9dc135 XL |
633 | cache_on_disk_if(_, opt_result) { |
634 | // Only store results without errors | |
635 | opt_result.map_or(true, |r| r.is_ok()) | |
532ac7d7 XL |
636 | } |
637 | } | |
dc9dc135 | 638 | |
ba9703b0 | 639 | /// Destructure a constant ADT or array into its variant index and its |
dfeec247 XL |
640 | /// field values. |
641 | query destructure_const( | |
642 | key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>> | |
643 | ) -> mir::DestructuredConst<'tcx> { | |
dfeec247 XL |
644 | desc { "destructure constant" } |
645 | } | |
646 | ||
74b04a01 | 647 | query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> { |
e74abb32 XL |
648 | desc { "get a &core::panic::Location referring to a span" } |
649 | } | |
dfeec247 XL |
650 | |
651 | query lit_to_const( | |
652 | key: LitToConstInput<'tcx> | |
653 | ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { | |
dfeec247 XL |
654 | desc { "converting literal to const" } |
655 | } | |
532ac7d7 XL |
656 | } |
657 | ||
658 | TypeChecking { | |
e74abb32 | 659 | query check_match(key: DefId) { |
f9f354fc | 660 | desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) } |
dc9dc135 XL |
661 | cache_on_disk_if { key.is_local() } |
662 | } | |
532ac7d7 XL |
663 | |
664 | /// Performs part of the privacy check and computes "access levels". | |
dc9dc135 | 665 | query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels { |
532ac7d7 XL |
666 | eval_always |
667 | desc { "privacy access levels" } | |
668 | } | |
669 | query check_private_in_public(_: CrateNum) -> () { | |
670 | eval_always | |
671 | desc { "checking for private elements in public interfaces" } | |
672 | } | |
673 | } | |
674 | ||
675 | Other { | |
ba9703b0 | 676 | query reachable_set(_: CrateNum) -> &'tcx HirIdSet { |
532ac7d7 XL |
677 | desc { "reachability" } |
678 | } | |
679 | ||
680 | /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body; | |
681 | /// in the case of closures, this will be redirected to the enclosing function. | |
f9f354fc XL |
682 | query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree { |
683 | desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) } | |
684 | } | |
532ac7d7 | 685 | |
f9f354fc XL |
686 | query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> { |
687 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
688 | desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) } |
689 | } | |
690 | ||
dfeec247 XL |
691 | /// The `symbol_name` query provides the symbol name for calling a |
692 | /// given instance from the local crate. In particular, it will also | |
693 | /// look up the correct symbol name of instances from upstream crates. | |
532ac7d7 | 694 | query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName { |
532ac7d7 | 695 | desc { "computing the symbol for `{}`", key } |
dc9dc135 | 696 | cache_on_disk_if { true } |
532ac7d7 XL |
697 | } |
698 | ||
f9f354fc XL |
699 | query def_kind(def_id: DefId) -> DefKind { |
700 | desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) } | |
701 | } | |
702 | query def_span(def_id: DefId) -> Span { | |
703 | desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) } | |
532ac7d7 XL |
704 | // FIXME(mw): DefSpans are not really inputs since they are derived from |
705 | // HIR. But at the moment HIR hashing still contains some hacks that allow | |
706 | // to make type debuginfo to be source location independent. Declaring | |
707 | // DefSpan an input makes sure that changes to these are always detected | |
708 | // regardless of HIR hashing. | |
709 | eval_always | |
710 | } | |
f9f354fc XL |
711 | query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> { |
712 | desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) } | |
713 | } | |
714 | query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> { | |
715 | desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) } | |
716 | } | |
717 | query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> { | |
718 | desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) } | |
719 | } | |
720 | query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] { | |
721 | desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) } | |
722 | } | |
532ac7d7 XL |
723 | } |
724 | ||
725 | Codegen { | |
f9f354fc XL |
726 | query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs { |
727 | desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) } | |
728 | storage(ArenaCacheSelector<'tcx>) | |
dc9dc135 XL |
729 | cache_on_disk_if { true } |
730 | } | |
532ac7d7 XL |
731 | } |
732 | ||
733 | Other { | |
f035d41b | 734 | query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] { |
f9f354fc XL |
735 | desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) } |
736 | } | |
532ac7d7 XL |
737 | /// Gets the rendered value of the specified constant or associated constant. |
738 | /// Used by rustdoc. | |
f9f354fc XL |
739 | query rendered_const(def_id: DefId) -> String { |
740 | desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) } | |
741 | } | |
742 | query impl_parent(def_id: DefId) -> Option<DefId> { | |
743 | desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) } | |
744 | } | |
532ac7d7 XL |
745 | } |
746 | ||
747 | TypeChecking { | |
f9f354fc XL |
748 | query trait_of_item(def_id: DefId) -> Option<DefId> { |
749 | desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(def_id) } | |
750 | } | |
532ac7d7 XL |
751 | } |
752 | ||
753 | Codegen { | |
754 | query is_mir_available(key: DefId) -> bool { | |
755 | desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) } | |
756 | } | |
757 | } | |
758 | ||
759 | Other { | |
760 | query vtable_methods(key: ty::PolyTraitRef<'tcx>) | |
48663c56 | 761 | -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] { |
532ac7d7 XL |
762 | desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) } |
763 | } | |
764 | } | |
765 | ||
766 | Codegen { | |
767 | query codegen_fulfill_obligation( | |
768 | key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) | |
f035d41b | 769 | ) -> Result<ImplSource<'tcx, ()>, ErrorReported> { |
dc9dc135 | 770 | cache_on_disk_if { true } |
532ac7d7 XL |
771 | desc { |tcx| |
772 | "checking if `{}` fulfills its obligations", | |
773 | tcx.def_path_str(key.1.def_id()) | |
774 | } | |
775 | } | |
776 | } | |
777 | ||
778 | TypeChecking { | |
ba9703b0 XL |
779 | query all_local_trait_impls(key: CrateNum) -> &'tcx BTreeMap<DefId, Vec<hir::HirId>> { |
780 | desc { "local trait impls" } | |
781 | } | |
f9f354fc XL |
782 | query trait_impls_of(key: DefId) -> ty::trait_def::TraitImpls { |
783 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
784 | desc { |tcx| "trait impls of `{}`", tcx.def_path_str(key) } |
785 | } | |
f9f354fc XL |
786 | query specialization_graph_of(key: DefId) -> specialization_graph::Graph { |
787 | storage(ArenaCacheSelector<'tcx>) | |
74b04a01 | 788 | desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(key) } |
dc9dc135 XL |
789 | cache_on_disk_if { true } |
790 | } | |
ba9703b0 | 791 | query object_safety_violations(key: DefId) -> &'tcx [traits::ObjectSafetyViolation] { |
532ac7d7 XL |
792 | desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(key) } |
793 | } | |
794 | ||
795 | /// Gets the ParameterEnvironment for a given item; this environment | |
f9f354fc | 796 | /// will be in "user-facing" mode, meaning that it is suitable for |
532ac7d7 XL |
797 | /// type-checking etc, and it does not normalize specializable |
798 | /// associated types. This is almost always what you want, | |
799 | /// unless you are doing MIR optimizations, in which case you | |
800 | /// might want to use `reveal_all()` method to change modes. | |
f9f354fc XL |
801 | query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> { |
802 | desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } | |
803 | } | |
532ac7d7 XL |
804 | |
805 | /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`, | |
806 | /// `ty.is_copy()`, etc, since that will prune the environment where possible. | |
807 | query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { | |
532ac7d7 XL |
808 | desc { "computing whether `{}` is `Copy`", env.value } |
809 | } | |
74b04a01 | 810 | /// Query backing `TyS::is_sized`. |
532ac7d7 | 811 | query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { |
532ac7d7 XL |
812 | desc { "computing whether `{}` is `Sized`", env.value } |
813 | } | |
74b04a01 | 814 | /// Query backing `TyS::is_freeze`. |
532ac7d7 | 815 | query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { |
532ac7d7 XL |
816 | desc { "computing whether `{}` is freeze", env.value } |
817 | } | |
74b04a01 XL |
818 | /// Query backing `TyS::needs_drop`. |
819 | query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { | |
532ac7d7 XL |
820 | desc { "computing whether `{}` needs drop", env.value } |
821 | } | |
822 | ||
f035d41b XL |
823 | /// Query backing `TyS::is_structural_eq_shallow`. |
824 | /// | |
825 | /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types | |
826 | /// correctly. | |
827 | query has_structural_eq_impls(ty: Ty<'tcx>) -> bool { | |
828 | desc { | |
829 | "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`", | |
830 | ty | |
831 | } | |
832 | } | |
833 | ||
74b04a01 XL |
834 | /// A list of types where the ADT requires drop if and only if any of |
835 | /// those types require drop. If the ADT is known to always need drop | |
836 | /// then `Err(AlwaysRequiresDrop)` is returned. | |
f9f354fc XL |
837 | query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> { |
838 | desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) } | |
74b04a01 XL |
839 | cache_on_disk_if { true } |
840 | } | |
841 | ||
532ac7d7 XL |
842 | query layout_raw( |
843 | env: ty::ParamEnvAnd<'tcx, Ty<'tcx>> | |
ba9703b0 | 844 | ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> { |
532ac7d7 XL |
845 | desc { "computing layout of `{}`", env.value } |
846 | } | |
847 | } | |
848 | ||
849 | Other { | |
850 | query dylib_dependency_formats(_: CrateNum) | |
dc9dc135 | 851 | -> &'tcx [(CrateNum, LinkagePreference)] { |
532ac7d7 XL |
852 | desc { "dylib dependency formats of crate" } |
853 | } | |
e74abb32 XL |
854 | |
855 | query dependency_formats(_: CrateNum) | |
856 | -> Lrc<crate::middle::dependency_format::Dependencies> | |
857 | { | |
858 | desc { "get the linkage format of all dependencies" } | |
859 | } | |
532ac7d7 XL |
860 | } |
861 | ||
862 | Codegen { | |
863 | query is_compiler_builtins(_: CrateNum) -> bool { | |
864 | fatal_cycle | |
865 | desc { "checking if the crate is_compiler_builtins" } | |
866 | } | |
867 | query has_global_allocator(_: CrateNum) -> bool { | |
868 | fatal_cycle | |
869 | desc { "checking if the crate has_global_allocator" } | |
870 | } | |
871 | query has_panic_handler(_: CrateNum) -> bool { | |
872 | fatal_cycle | |
873 | desc { "checking if the crate has_panic_handler" } | |
874 | } | |
532ac7d7 XL |
875 | query is_profiler_runtime(_: CrateNum) -> bool { |
876 | fatal_cycle | |
416331ca | 877 | desc { "query a crate is `#![profiler_runtime]`" } |
532ac7d7 XL |
878 | } |
879 | query panic_strategy(_: CrateNum) -> PanicStrategy { | |
880 | fatal_cycle | |
881 | desc { "query a crate's configured panic strategy" } | |
882 | } | |
883 | query is_no_builtins(_: CrateNum) -> bool { | |
884 | fatal_cycle | |
416331ca | 885 | desc { "test whether a crate has `#![no_builtins]`" } |
532ac7d7 | 886 | } |
dc9dc135 XL |
887 | query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion { |
888 | fatal_cycle | |
889 | desc { "query a crate's symbol mangling version" } | |
890 | } | |
532ac7d7 | 891 | |
f9f354fc | 892 | query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> { |
532ac7d7 XL |
893 | eval_always |
894 | desc { "getting crate's ExternCrateData" } | |
895 | } | |
896 | } | |
897 | ||
898 | TypeChecking { | |
899 | query specializes(_: (DefId, DefId)) -> bool { | |
532ac7d7 XL |
900 | desc { "computing whether impls specialize one another" } |
901 | } | |
ba9703b0 | 902 | query in_scope_traits_map(_: LocalDefId) |
dc9dc135 | 903 | -> Option<&'tcx FxHashMap<ItemLocalId, StableVec<TraitCandidate>>> { |
532ac7d7 XL |
904 | eval_always |
905 | desc { "traits in scope at a block" } | |
906 | } | |
907 | } | |
908 | ||
909 | Other { | |
f035d41b XL |
910 | query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export<LocalDefId>]> { |
911 | desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) } | |
532ac7d7 XL |
912 | eval_always |
913 | } | |
914 | } | |
915 | ||
916 | TypeChecking { | |
f9f354fc XL |
917 | query impl_defaultness(def_id: DefId) -> hir::Defaultness { |
918 | desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) } | |
919 | } | |
532ac7d7 | 920 | |
f9f354fc XL |
921 | query check_item_well_formed(key: LocalDefId) -> () { |
922 | desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } | |
923 | } | |
924 | query check_trait_item_well_formed(key: LocalDefId) -> () { | |
925 | desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } | |
926 | } | |
927 | query check_impl_item_well_formed(key: LocalDefId) -> () { | |
928 | desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } | |
929 | } | |
532ac7d7 XL |
930 | } |
931 | ||
f9f354fc | 932 | |
532ac7d7 | 933 | Linking { |
dc9dc135 | 934 | // The `DefId`s of all non-generic functions and statics in the given crate |
532ac7d7 XL |
935 | // that can be reached from outside the crate. |
936 | // | |
937 | // We expect this items to be available for being linked to. | |
938 | // | |
dc9dc135 | 939 | // This query can also be called for `LOCAL_CRATE`. In this case it will |
532ac7d7 XL |
940 | // compute which items will be reachable to other crates, taking into account |
941 | // the kind of crate that is currently compiled. Crates with only a | |
942 | // C interface have fewer reachable things. | |
943 | // | |
944 | // Does not include external symbols that don't have a corresponding DefId, | |
945 | // like the compiler-generated `main` function and so on. | |
946 | query reachable_non_generics(_: CrateNum) | |
f9f354fc XL |
947 | -> DefIdMap<SymbolExportLevel> { |
948 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
949 | desc { "looking up the exported symbols of a crate" } |
950 | } | |
f9f354fc XL |
951 | query is_reachable_non_generic(def_id: DefId) -> bool { |
952 | desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) } | |
953 | } | |
954 | query is_unreachable_local_definition(def_id: DefId) -> bool { | |
955 | desc { |tcx| | |
956 | "checking whether `{}` is reachable from outside the crate", | |
957 | tcx.def_path_str(def_id), | |
958 | } | |
959 | } | |
532ac7d7 XL |
960 | } |
961 | ||
962 | Codegen { | |
dfeec247 XL |
963 | /// The entire set of monomorphizations the local crate can safely link |
964 | /// to because they are exported from upstream crates. Do not depend on | |
965 | /// this directly, as its value changes anytime a monomorphization gets | |
966 | /// added or removed in any upstream crate. Instead use the narrower | |
967 | /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even | |
968 | /// better, `Instance::upstream_monomorphization()`. | |
532ac7d7 XL |
969 | query upstream_monomorphizations( |
970 | k: CrateNum | |
f9f354fc XL |
971 | ) -> DefIdMap<FxHashMap<SubstsRef<'tcx>, CrateNum>> { |
972 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
973 | desc { "collecting available upstream monomorphizations `{:?}`", k } |
974 | } | |
dfeec247 XL |
975 | |
976 | /// Returns the set of upstream monomorphizations available for the | |
977 | /// generic function identified by the given `def_id`. The query makes | |
978 | /// sure to make a stable selection if the same monomorphization is | |
979 | /// available in multiple upstream crates. | |
980 | /// | |
981 | /// You likely want to call `Instance::upstream_monomorphization()` | |
982 | /// instead of invoking this query directly. | |
f9f354fc XL |
983 | query upstream_monomorphizations_for(def_id: DefId) |
984 | -> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> { | |
985 | desc { |tcx| | |
986 | "collecting available upstream monomorphizations for `{}`", | |
987 | tcx.def_path_str(def_id), | |
988 | } | |
989 | } | |
dfeec247 XL |
990 | |
991 | /// Returns the upstream crate that exports drop-glue for the given | |
992 | /// type (`substs` is expected to be a single-item list containing the | |
993 | /// type one wants drop-glue for). | |
994 | /// | |
995 | /// This is a subset of `upstream_monomorphizations_for` in order to | |
996 | /// increase dep-tracking granularity. Otherwise adding or removing any | |
997 | /// type with drop-glue in any upstream crate would invalidate all | |
998 | /// functions calling drop-glue of an upstream type. | |
999 | /// | |
1000 | /// You likely want to call `Instance::upstream_monomorphization()` | |
1001 | /// instead of invoking this query directly. | |
1002 | /// | |
1003 | /// NOTE: This query could easily be extended to also support other | |
1004 | /// common functions that have are large set of monomorphizations | |
1005 | /// (like `Clone::clone` for example). | |
1006 | query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option<CrateNum> { | |
1007 | desc { "available upstream drop-glue for `{:?}`", substs } | |
dfeec247 | 1008 | } |
532ac7d7 XL |
1009 | } |
1010 | ||
1011 | Other { | |
dc9dc135 | 1012 | query foreign_modules(_: CrateNum) -> &'tcx [ForeignModule] { |
532ac7d7 XL |
1013 | desc { "looking up the foreign modules of a linked crate" } |
1014 | } | |
1015 | ||
1016 | /// Identifies the entry-point (e.g., the `main` function) for a given | |
1017 | /// crate, returning `None` if there is no entry point (such as for library crates). | |
f9f354fc | 1018 | query entry_fn(_: CrateNum) -> Option<(LocalDefId, EntryFnType)> { |
532ac7d7 XL |
1019 | desc { "looking up the entry function of a crate" } |
1020 | } | |
1021 | query plugin_registrar_fn(_: CrateNum) -> Option<DefId> { | |
1022 | desc { "looking up the plugin registrar for a crate" } | |
1023 | } | |
1024 | query proc_macro_decls_static(_: CrateNum) -> Option<DefId> { | |
1025 | desc { "looking up the derive registrar for a crate" } | |
1026 | } | |
1027 | query crate_disambiguator(_: CrateNum) -> CrateDisambiguator { | |
1028 | eval_always | |
1029 | desc { "looking up the disambiguator a crate" } | |
1030 | } | |
1031 | query crate_hash(_: CrateNum) -> Svh { | |
1032 | eval_always | |
1033 | desc { "looking up the hash a crate" } | |
1034 | } | |
e74abb32 XL |
1035 | query crate_host_hash(_: CrateNum) -> Option<Svh> { |
1036 | eval_always | |
1037 | desc { "looking up the hash of a host version of a crate" } | |
1038 | } | |
532ac7d7 XL |
1039 | query original_crate_name(_: CrateNum) -> Symbol { |
1040 | eval_always | |
1041 | desc { "looking up the original name a crate" } | |
1042 | } | |
1043 | query extra_filename(_: CrateNum) -> String { | |
1044 | eval_always | |
1045 | desc { "looking up the extra filename for a crate" } | |
1046 | } | |
f035d41b XL |
1047 | query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> { |
1048 | eval_always | |
1049 | desc { "looking up the paths for extern crates" } | |
1050 | } | |
532ac7d7 XL |
1051 | } |
1052 | ||
1053 | TypeChecking { | |
1054 | query implementations_of_trait(_: (CrateNum, DefId)) | |
dc9dc135 | 1055 | -> &'tcx [DefId] { |
532ac7d7 XL |
1056 | desc { "looking up implementations of a trait in a crate" } |
1057 | } | |
1058 | query all_trait_implementations(_: CrateNum) | |
dc9dc135 | 1059 | -> &'tcx [DefId] { |
532ac7d7 XL |
1060 | desc { "looking up all (?) trait implementations" } |
1061 | } | |
1062 | } | |
1063 | ||
1064 | Other { | |
1065 | query dllimport_foreign_items(_: CrateNum) | |
f9f354fc XL |
1066 | -> FxHashSet<DefId> { |
1067 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
1068 | desc { "dllimport_foreign_items" } |
1069 | } | |
f9f354fc XL |
1070 | query is_dllimport_foreign_item(def_id: DefId) -> bool { |
1071 | desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) } | |
1072 | } | |
1073 | query is_statically_included_foreign_item(def_id: DefId) -> bool { | |
1074 | desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) } | |
1075 | } | |
1076 | query native_library_kind(def_id: DefId) | |
1077 | -> Option<NativeLibKind> { | |
1078 | desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) } | |
1079 | } | |
532ac7d7 XL |
1080 | } |
1081 | ||
1082 | Linking { | |
1083 | query link_args(_: CrateNum) -> Lrc<Vec<String>> { | |
1084 | eval_always | |
1085 | desc { "looking up link arguments for a crate" } | |
1086 | } | |
1087 | } | |
1088 | ||
1089 | BorrowChecking { | |
e1599b0c | 1090 | /// Lifetime resolution. See `middle::resolve_lifetimes`. |
f9f354fc XL |
1091 | query resolve_lifetimes(_: CrateNum) -> ResolveLifetimes { |
1092 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
1093 | desc { "resolving lifetimes" } |
1094 | } | |
ba9703b0 | 1095 | query named_region_map(_: LocalDefId) -> |
dc9dc135 | 1096 | Option<&'tcx FxHashMap<ItemLocalId, Region>> { |
532ac7d7 XL |
1097 | desc { "looking up a named region" } |
1098 | } | |
ba9703b0 | 1099 | query is_late_bound_map(_: LocalDefId) -> |
dc9dc135 | 1100 | Option<&'tcx FxHashSet<ItemLocalId>> { |
532ac7d7 XL |
1101 | desc { "testing if a region is late bound" } |
1102 | } | |
ba9703b0 | 1103 | query object_lifetime_defaults_map(_: LocalDefId) |
dc9dc135 | 1104 | -> Option<&'tcx FxHashMap<ItemLocalId, Vec<ObjectLifetimeDefault>>> { |
532ac7d7 XL |
1105 | desc { "looking up lifetime defaults for a region" } |
1106 | } | |
1107 | } | |
1108 | ||
1109 | TypeChecking { | |
f9f354fc XL |
1110 | query visibility(def_id: DefId) -> ty::Visibility { |
1111 | desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) } | |
1112 | } | |
532ac7d7 XL |
1113 | } |
1114 | ||
1115 | Other { | |
1116 | query dep_kind(_: CrateNum) -> DepKind { | |
1117 | eval_always | |
1118 | desc { "fetching what a dependency looks like" } | |
1119 | } | |
1120 | query crate_name(_: CrateNum) -> Symbol { | |
1121 | eval_always | |
1122 | desc { "fetching what a crate is named" } | |
1123 | } | |
f9f354fc XL |
1124 | query item_children(def_id: DefId) -> &'tcx [Export<hir::HirId>] { |
1125 | desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) } | |
1126 | } | |
1127 | query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> { | |
1128 | desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) } | |
1129 | } | |
532ac7d7 | 1130 | |
f9f354fc XL |
1131 | query get_lib_features(_: CrateNum) -> LibFeatures { |
1132 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
1133 | eval_always |
1134 | desc { "calculating the lib features map" } | |
1135 | } | |
1136 | query defined_lib_features(_: CrateNum) | |
dc9dc135 | 1137 | -> &'tcx [(Symbol, Option<Symbol>)] { |
532ac7d7 XL |
1138 | desc { "calculating the lib features defined in a crate" } |
1139 | } | |
e1599b0c XL |
1140 | /// Returns the lang items defined in another crate by loading it from metadata. |
1141 | // FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid | |
1142 | // of that argument? | |
f9f354fc XL |
1143 | query get_lang_items(_: CrateNum) -> LanguageItems { |
1144 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
1145 | eval_always |
1146 | desc { "calculating the lang items map" } | |
1147 | } | |
e1599b0c XL |
1148 | |
1149 | /// Returns all diagnostic items defined in all crates. | |
f9f354fc XL |
1150 | query all_diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> { |
1151 | storage(ArenaCacheSelector<'tcx>) | |
e1599b0c XL |
1152 | eval_always |
1153 | desc { "calculating the diagnostic items map" } | |
1154 | } | |
1155 | ||
1156 | /// Returns the lang items defined in another crate by loading it from metadata. | |
dc9dc135 | 1157 | query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] { |
532ac7d7 XL |
1158 | desc { "calculating the lang items defined in a crate" } |
1159 | } | |
e1599b0c XL |
1160 | |
1161 | /// Returns the diagnostic items defined in a crate. | |
f9f354fc XL |
1162 | query diagnostic_items(_: CrateNum) -> FxHashMap<Symbol, DefId> { |
1163 | storage(ArenaCacheSelector<'tcx>) | |
e1599b0c XL |
1164 | desc { "calculating the diagnostic items map in a crate" } |
1165 | } | |
1166 | ||
dc9dc135 | 1167 | query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] { |
532ac7d7 XL |
1168 | desc { "calculating the missing lang items in a crate" } |
1169 | } | |
1170 | query visible_parent_map(_: CrateNum) | |
f9f354fc XL |
1171 | -> DefIdMap<DefId> { |
1172 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
1173 | desc { "calculating the visible parent map" } |
1174 | } | |
1175 | query missing_extern_crate_item(_: CrateNum) -> bool { | |
1176 | eval_always | |
1177 | desc { "seeing if we're missing an `extern crate` item for this crate" } | |
1178 | } | |
1179 | query used_crate_source(_: CrateNum) -> Lrc<CrateSource> { | |
1180 | eval_always | |
1181 | desc { "looking at the source for a crate" } | |
1182 | } | |
dc9dc135 | 1183 | query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] { |
532ac7d7 XL |
1184 | eval_always |
1185 | desc { "generating a postorder list of CrateNums" } | |
1186 | } | |
1187 | ||
f9f354fc XL |
1188 | query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> { |
1189 | desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } | |
532ac7d7 XL |
1190 | eval_always |
1191 | } | |
f9f354fc | 1192 | query maybe_unused_trait_import(def_id: LocalDefId) -> bool { |
532ac7d7 | 1193 | eval_always |
f9f354fc | 1194 | desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) } |
532ac7d7 XL |
1195 | } |
1196 | query maybe_unused_extern_crates(_: CrateNum) | |
f9f354fc | 1197 | -> &'tcx [(LocalDefId, Span)] { |
532ac7d7 XL |
1198 | eval_always |
1199 | desc { "looking up all possibly unused extern crates" } | |
1200 | } | |
f9f354fc XL |
1201 | query names_imported_by_glob_use(def_id: LocalDefId) |
1202 | -> &'tcx FxHashSet<Symbol> { | |
532ac7d7 | 1203 | eval_always |
f9f354fc | 1204 | desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) } |
532ac7d7 XL |
1205 | } |
1206 | ||
f9f354fc XL |
1207 | query stability_index(_: CrateNum) -> stability::Index<'tcx> { |
1208 | storage(ArenaCacheSelector<'tcx>) | |
532ac7d7 XL |
1209 | eval_always |
1210 | desc { "calculating the stability index for the local crate" } | |
1211 | } | |
dc9dc135 | 1212 | query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] { |
532ac7d7 XL |
1213 | eval_always |
1214 | desc { "fetching all foreign CrateNum instances" } | |
1215 | } | |
1216 | ||
1217 | /// A vector of every trait accessible in the whole crate | |
1218 | /// (i.e., including those from subcrates). This is used only for | |
1219 | /// error reporting. | |
dc9dc135 | 1220 | query all_traits(_: CrateNum) -> &'tcx [DefId] { |
532ac7d7 XL |
1221 | desc { "fetching all foreign and local traits" } |
1222 | } | |
1223 | } | |
1224 | ||
1225 | Linking { | |
dfeec247 XL |
1226 | /// The list of symbols exported from the given crate. |
1227 | /// | |
1228 | /// - All names contained in `exported_symbols(cnum)` are guaranteed to | |
1229 | /// correspond to a publicly visible symbol in `cnum` machine code. | |
1230 | /// - The `exported_symbols` sets of different crates do not intersect. | |
532ac7d7 | 1231 | query exported_symbols(_: CrateNum) |
ba9703b0 | 1232 | -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] { |
532ac7d7 XL |
1233 | desc { "exported_symbols" } |
1234 | } | |
1235 | } | |
1236 | ||
1237 | Codegen { | |
1238 | query collect_and_partition_mono_items(_: CrateNum) | |
ba9703b0 | 1239 | -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) { |
532ac7d7 XL |
1240 | eval_always |
1241 | desc { "collect_and_partition_mono_items" } | |
1242 | } | |
f9f354fc XL |
1243 | query is_codegened_item(def_id: DefId) -> bool { |
1244 | desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) } | |
1245 | } | |
ba9703b0 | 1246 | query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> { |
532ac7d7 XL |
1247 | desc { "codegen_unit" } |
1248 | } | |
1249 | query backend_optimization_level(_: CrateNum) -> OptLevel { | |
1250 | desc { "optimization level used by backend" } | |
1251 | } | |
1252 | } | |
1253 | ||
1254 | Other { | |
1255 | query output_filenames(_: CrateNum) -> Arc<OutputFilenames> { | |
1256 | eval_always | |
1257 | desc { "output_filenames" } | |
1258 | } | |
1259 | } | |
1260 | ||
1261 | TypeChecking { | |
1262 | /// Do not call this query directly: invoke `normalize` instead. | |
1263 | query normalize_projection_ty( | |
1264 | goal: CanonicalProjectionGoal<'tcx> | |
1265 | ) -> Result< | |
48663c56 | 1266 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>, |
532ac7d7 XL |
1267 | NoSolution, |
1268 | > { | |
532ac7d7 XL |
1269 | desc { "normalizing `{:?}`", goal } |
1270 | } | |
1271 | ||
1272 | /// Do not call this query directly: invoke `normalize_erasing_regions` instead. | |
ba9703b0 XL |
1273 | query normalize_generic_arg_after_erasing_regions( |
1274 | goal: ParamEnvAnd<'tcx, GenericArg<'tcx>> | |
1275 | ) -> GenericArg<'tcx> { | |
1276 | desc { "normalizing `{}`", goal.value } | |
532ac7d7 XL |
1277 | } |
1278 | ||
1279 | query implied_outlives_bounds( | |
1280 | goal: CanonicalTyGoal<'tcx> | |
1281 | ) -> Result< | |
48663c56 | 1282 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>, |
532ac7d7 XL |
1283 | NoSolution, |
1284 | > { | |
532ac7d7 XL |
1285 | desc { "computing implied outlives bounds for `{:?}`", goal } |
1286 | } | |
1287 | ||
1288 | /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead. | |
1289 | query dropck_outlives( | |
1290 | goal: CanonicalTyGoal<'tcx> | |
1291 | ) -> Result< | |
48663c56 | 1292 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, |
532ac7d7 XL |
1293 | NoSolution, |
1294 | > { | |
532ac7d7 XL |
1295 | desc { "computing dropck types for `{:?}`", goal } |
1296 | } | |
1297 | ||
1298 | /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or | |
1299 | /// `infcx.predicate_must_hold()` instead. | |
1300 | query evaluate_obligation( | |
1301 | goal: CanonicalPredicateGoal<'tcx> | |
1302 | ) -> Result<traits::EvaluationResult, traits::OverflowError> { | |
532ac7d7 XL |
1303 | desc { "evaluating trait selection obligation `{}`", goal.value.value } |
1304 | } | |
1305 | ||
f9f354fc XL |
1306 | query evaluate_goal( |
1307 | goal: traits::ChalkCanonicalGoal<'tcx> | |
1308 | ) -> Result< | |
1309 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, | |
1310 | NoSolution | |
1311 | > { | |
1312 | desc { "evaluating trait selection obligation `{}`", goal.value } | |
1313 | } | |
1314 | ||
1315 | query type_implements_trait( | |
1316 | key: (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>, ) | |
1317 | ) -> bool { | |
1318 | desc { "evaluating `type_implements_trait` `{:?}`", key } | |
1319 | } | |
1320 | ||
532ac7d7 XL |
1321 | /// Do not call this query directly: part of the `Eq` type-op |
1322 | query type_op_ascribe_user_type( | |
1323 | goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx> | |
1324 | ) -> Result< | |
48663c56 | 1325 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, |
532ac7d7 XL |
1326 | NoSolution, |
1327 | > { | |
532ac7d7 XL |
1328 | desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal } |
1329 | } | |
1330 | ||
1331 | /// Do not call this query directly: part of the `Eq` type-op | |
1332 | query type_op_eq( | |
1333 | goal: CanonicalTypeOpEqGoal<'tcx> | |
1334 | ) -> Result< | |
48663c56 | 1335 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, |
532ac7d7 XL |
1336 | NoSolution, |
1337 | > { | |
532ac7d7 XL |
1338 | desc { "evaluating `type_op_eq` `{:?}`", goal } |
1339 | } | |
1340 | ||
1341 | /// Do not call this query directly: part of the `Subtype` type-op | |
1342 | query type_op_subtype( | |
1343 | goal: CanonicalTypeOpSubtypeGoal<'tcx> | |
1344 | ) -> Result< | |
48663c56 | 1345 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, |
532ac7d7 XL |
1346 | NoSolution, |
1347 | > { | |
532ac7d7 XL |
1348 | desc { "evaluating `type_op_subtype` `{:?}`", goal } |
1349 | } | |
1350 | ||
1351 | /// Do not call this query directly: part of the `ProvePredicate` type-op | |
1352 | query type_op_prove_predicate( | |
1353 | goal: CanonicalTypeOpProvePredicateGoal<'tcx> | |
1354 | ) -> Result< | |
48663c56 | 1355 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, |
532ac7d7 XL |
1356 | NoSolution, |
1357 | > { | |
532ac7d7 XL |
1358 | desc { "evaluating `type_op_prove_predicate` `{:?}`", goal } |
1359 | } | |
1360 | ||
1361 | /// Do not call this query directly: part of the `Normalize` type-op | |
1362 | query type_op_normalize_ty( | |
1363 | goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>> | |
1364 | ) -> Result< | |
48663c56 | 1365 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>, |
532ac7d7 XL |
1366 | NoSolution, |
1367 | > { | |
532ac7d7 XL |
1368 | desc { "normalizing `{:?}`", goal } |
1369 | } | |
1370 | ||
1371 | /// Do not call this query directly: part of the `Normalize` type-op | |
1372 | query type_op_normalize_predicate( | |
1373 | goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>> | |
1374 | ) -> Result< | |
48663c56 | 1375 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>, |
532ac7d7 XL |
1376 | NoSolution, |
1377 | > { | |
532ac7d7 XL |
1378 | desc { "normalizing `{:?}`", goal } |
1379 | } | |
1380 | ||
1381 | /// Do not call this query directly: part of the `Normalize` type-op | |
1382 | query type_op_normalize_poly_fn_sig( | |
1383 | goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>> | |
1384 | ) -> Result< | |
48663c56 | 1385 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>, |
532ac7d7 XL |
1386 | NoSolution, |
1387 | > { | |
532ac7d7 XL |
1388 | desc { "normalizing `{:?}`", goal } |
1389 | } | |
1390 | ||
1391 | /// Do not call this query directly: part of the `Normalize` type-op | |
1392 | query type_op_normalize_fn_sig( | |
1393 | goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>> | |
1394 | ) -> Result< | |
48663c56 | 1395 | &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>, |
532ac7d7 XL |
1396 | NoSolution, |
1397 | > { | |
532ac7d7 XL |
1398 | desc { "normalizing `{:?}`", goal } |
1399 | } | |
1400 | ||
1401 | query substitute_normalize_and_test_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool { | |
532ac7d7 XL |
1402 | desc { |tcx| |
1403 | "testing substituted normalized predicates:`{}`", | |
1404 | tcx.def_path_str(key.0) | |
1405 | } | |
1406 | } | |
1407 | ||
1408 | query method_autoderef_steps( | |
1409 | goal: CanonicalTyGoal<'tcx> | |
1410 | ) -> MethodAutoderefStepsResult<'tcx> { | |
532ac7d7 XL |
1411 | desc { "computing autoderef types for `{:?}`", goal } |
1412 | } | |
1413 | } | |
1414 | ||
1415 | Other { | |
f035d41b | 1416 | query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> { |
f9f354fc | 1417 | storage(ArenaCacheSelector<'tcx>) |
532ac7d7 | 1418 | eval_always |
f035d41b | 1419 | desc { "looking up supported target features" } |
532ac7d7 XL |
1420 | } |
1421 | ||
1422 | // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning. | |
1423 | query instance_def_size_estimate(def: ty::InstanceDef<'tcx>) | |
1424 | -> usize { | |
532ac7d7 XL |
1425 | desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) } |
1426 | } | |
1427 | ||
60c5eb7d | 1428 | query features_query(_: CrateNum) -> &'tcx rustc_feature::Features { |
532ac7d7 XL |
1429 | eval_always |
1430 | desc { "looking up enabled feature gates" } | |
1431 | } | |
ba9703b0 | 1432 | |
f9f354fc XL |
1433 | /// Attempt to resolve the given `DefId` to an `Instance`, for the |
1434 | /// given generics args (`SubstsRef`), returning one of: | |
1435 | /// * `Ok(Some(instance))` on success | |
1436 | /// * `Ok(None)` when the `SubstsRef` are still too generic, | |
1437 | /// and therefore don't allow finding the final `Instance` | |
1438 | /// * `Err(ErrorReported)` when the `Instance` resolution process | |
1439 | /// couldn't complete due to errors elsewhere - this is distinct | |
1440 | /// from `Ok(None)` to avoid misleading diagnostics when an error | |
1441 | /// has already been/will be emitted, for the original cause | |
1442 | query resolve_instance( | |
1443 | key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)> | |
1444 | ) -> Result<Option<ty::Instance<'tcx>>, ErrorReported> { | |
1445 | desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) } | |
ba9703b0 | 1446 | } |
532ac7d7 XL |
1447 | } |
1448 | } |