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