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