1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use dep_graph::SerializedDepNodeIndex;
12 use hir::def_id::{CrateNum, DefId, DefIndex};
13 use mir::interpret::{GlobalId};
14 use traits::query::{CanonicalProjectionGoal, CanonicalTyGoal};
15 use ty::{self, ParamEnvAnd, Ty, TyCtxt};
16 use ty::subst::Substs;
17 use ty::maps::queries;
20 use syntax_pos::symbol::InternedString;
22 /// Query configuration and description traits.
24 pub trait QueryConfig {
25 type Key: Eq + Hash + Clone;
29 pub(super) trait QueryDescription<'tcx>: QueryConfig {
30 fn describe(tcx: TyCtxt, key: Self::Key) -> String;
33 fn cache_on_disk(_: Self::Key) -> bool {
37 fn try_load_from_disk(_: TyCtxt<'_, 'tcx, 'tcx>,
38 _: SerializedDepNodeIndex)
39 -> Option<Self::Value> {
40 bug!("QueryDescription::load_from_disk() called for an unsupported query.")
44 impl<'tcx, M: QueryConfig<Key=DefId>> QueryDescription<'tcx> for M {
45 default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
46 if !tcx.sess.verbose() {
47 format!("processing `{}`", tcx.item_path_str(def_id))
49 let name = unsafe { ::std::intrinsics::type_name::<M>() };
50 format!("processing `{}` applied to `{:?}`", name, def_id)
55 impl<'tcx> QueryDescription<'tcx> for queries::normalize_projection_ty<'tcx> {
58 goal: CanonicalProjectionGoal<'tcx>,
60 format!("normalizing `{:?}`", goal)
64 impl<'tcx> QueryDescription<'tcx> for queries::dropck_outlives<'tcx> {
65 fn describe(_tcx: TyCtxt, goal: CanonicalTyGoal<'tcx>) -> String {
66 format!("computing dropck types for `{:?}`", goal)
70 impl<'tcx> QueryDescription<'tcx> for queries::normalize_ty_after_erasing_regions<'tcx> {
71 fn describe(_tcx: TyCtxt, goal: ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
72 format!("normalizing `{:?}`", goal)
76 impl<'tcx> QueryDescription<'tcx> for queries::is_copy_raw<'tcx> {
77 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
78 format!("computing whether `{}` is `Copy`", env.value)
82 impl<'tcx> QueryDescription<'tcx> for queries::is_sized_raw<'tcx> {
83 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
84 format!("computing whether `{}` is `Sized`", env.value)
88 impl<'tcx> QueryDescription<'tcx> for queries::is_freeze_raw<'tcx> {
89 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
90 format!("computing whether `{}` is freeze", env.value)
94 impl<'tcx> QueryDescription<'tcx> for queries::needs_drop_raw<'tcx> {
95 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
96 format!("computing whether `{}` needs drop", env.value)
100 impl<'tcx> QueryDescription<'tcx> for queries::layout_raw<'tcx> {
101 fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String {
102 format!("computing layout of `{}`", env.value)
106 impl<'tcx> QueryDescription<'tcx> for queries::super_predicates_of<'tcx> {
107 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
108 format!("computing the supertraits of `{}`",
109 tcx.item_path_str(def_id))
113 impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> {
114 fn describe(_tcx: TyCtxt, ty: Ty<'tcx>) -> String {
115 format!("erasing regions from `{:?}`", ty)
119 impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> {
120 fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String {
121 let id = tcx.hir.as_local_node_id(def_id).unwrap();
122 format!("computing the bounds for type parameter `{}`",
123 tcx.hir.ty_param_name(id))
127 impl<'tcx> QueryDescription<'tcx> for queries::coherent_trait<'tcx> {
128 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
129 format!("coherence checking all impls of trait `{}`",
130 tcx.item_path_str(def_id))
134 impl<'tcx> QueryDescription<'tcx> for queries::upstream_monomorphizations<'tcx> {
135 fn describe(_: TyCtxt, k: CrateNum) -> String {
136 format!("collecting available upstream monomorphizations `{:?}`", k)
140 impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls<'tcx> {
141 fn describe(_: TyCtxt, k: CrateNum) -> String {
142 format!("all inherent impls defined in crate `{:?}`", k)
146 impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls_overlap_check<'tcx> {
147 fn describe(_: TyCtxt, _: CrateNum) -> String {
148 format!("check for overlap between inherent impls defined in this crate")
152 impl<'tcx> QueryDescription<'tcx> for queries::crate_variances<'tcx> {
153 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
154 format!("computing the variances for items in this crate")
158 impl<'tcx> QueryDescription<'tcx> for queries::inferred_outlives_crate<'tcx> {
159 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
160 format!("computing the inferred outlives predicates for items in this crate")
164 impl<'tcx> QueryDescription<'tcx> for queries::mir_shims<'tcx> {
165 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
166 format!("generating MIR shim for `{}`",
167 tcx.item_path_str(def.def_id()))
171 impl<'tcx> QueryDescription<'tcx> for queries::privacy_access_levels<'tcx> {
172 fn describe(_: TyCtxt, _: CrateNum) -> String {
173 format!("privacy access levels")
177 impl<'tcx> QueryDescription<'tcx> for queries::typeck_item_bodies<'tcx> {
178 fn describe(_: TyCtxt, _: CrateNum) -> String {
179 format!("type-checking all item bodies")
183 impl<'tcx> QueryDescription<'tcx> for queries::reachable_set<'tcx> {
184 fn describe(_: TyCtxt, _: CrateNum) -> String {
185 format!("reachability")
189 impl<'tcx> QueryDescription<'tcx> for queries::const_eval<'tcx> {
190 fn describe(tcx: TyCtxt, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) -> String {
191 format!("const-evaluating `{}`", tcx.item_path_str(key.value.instance.def.def_id()))
195 fn cache_on_disk(_key: Self::Key) -> bool {
200 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
201 id: SerializedDepNodeIndex)
202 -> Option<Self::Value> {
203 tcx.on_disk_query_result_cache.try_load_query_result(tcx, id).map(Ok)
207 impl<'tcx> QueryDescription<'tcx> for queries::mir_keys<'tcx> {
208 fn describe(_: TyCtxt, _: CrateNum) -> String {
209 format!("getting a list of all mir_keys")
213 impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> {
214 fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String {
215 format!("computing the symbol for `{}`", instance)
219 fn cache_on_disk(_: Self::Key) -> bool {
224 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
225 id: SerializedDepNodeIndex)
226 -> Option<Self::Value> {
227 tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
231 impl<'tcx> QueryDescription<'tcx> for queries::describe_def<'tcx> {
232 fn describe(_: TyCtxt, _: DefId) -> String {
237 impl<'tcx> QueryDescription<'tcx> for queries::def_span<'tcx> {
238 fn describe(_: TyCtxt, _: DefId) -> String {
244 impl<'tcx> QueryDescription<'tcx> for queries::lookup_stability<'tcx> {
245 fn describe(_: TyCtxt, _: DefId) -> String {
250 impl<'tcx> QueryDescription<'tcx> for queries::lookup_deprecation_entry<'tcx> {
251 fn describe(_: TyCtxt, _: DefId) -> String {
256 impl<'tcx> QueryDescription<'tcx> for queries::item_attrs<'tcx> {
257 fn describe(_: TyCtxt, _: DefId) -> String {
262 impl<'tcx> QueryDescription<'tcx> for queries::is_reachable_non_generic<'tcx> {
263 fn describe(_: TyCtxt, _: DefId) -> String {
264 bug!("is_reachable_non_generic")
268 impl<'tcx> QueryDescription<'tcx> for queries::fn_arg_names<'tcx> {
269 fn describe(_: TyCtxt, _: DefId) -> String {
274 impl<'tcx> QueryDescription<'tcx> for queries::impl_parent<'tcx> {
275 fn describe(_: TyCtxt, _: DefId) -> String {
280 impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> {
281 fn describe(_: TyCtxt, _: DefId) -> String {
282 bug!("trait_of_item")
286 impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> {
287 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
288 format!("const checking if rvalue is promotable to static `{}`",
289 tcx.item_path_str(def_id))
293 fn cache_on_disk(_: Self::Key) -> bool {
298 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
299 id: SerializedDepNodeIndex)
300 -> Option<Self::Value> {
301 tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
305 impl<'tcx> QueryDescription<'tcx> for queries::rvalue_promotable_map<'tcx> {
306 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
307 format!("checking which parts of `{}` are promotable to static",
308 tcx.item_path_str(def_id))
312 impl<'tcx> QueryDescription<'tcx> for queries::is_mir_available<'tcx> {
313 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
314 format!("checking if item is mir available: `{}`",
315 tcx.item_path_str(def_id))
319 impl<'tcx> QueryDescription<'tcx> for queries::trans_fulfill_obligation<'tcx> {
320 fn describe(tcx: TyCtxt, key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> String {
321 format!("checking if `{}` fulfills its obligations", tcx.item_path_str(key.1.def_id()))
325 fn cache_on_disk(_: Self::Key) -> bool {
330 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
331 id: SerializedDepNodeIndex)
332 -> Option<Self::Value> {
333 tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
337 impl<'tcx> QueryDescription<'tcx> for queries::trait_impls_of<'tcx> {
338 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
339 format!("trait impls of `{}`", tcx.item_path_str(def_id))
343 impl<'tcx> QueryDescription<'tcx> for queries::is_object_safe<'tcx> {
344 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
345 format!("determine object safety of trait `{}`", tcx.item_path_str(def_id))
349 impl<'tcx> QueryDescription<'tcx> for queries::is_const_fn<'tcx> {
350 fn describe(tcx: TyCtxt, def_id: DefId) -> String {
351 format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id))
355 impl<'tcx> QueryDescription<'tcx> for queries::dylib_dependency_formats<'tcx> {
356 fn describe(_: TyCtxt, _: CrateNum) -> String {
357 "dylib dependency formats of crate".to_string()
361 impl<'tcx> QueryDescription<'tcx> for queries::is_panic_runtime<'tcx> {
362 fn describe(_: TyCtxt, _: CrateNum) -> String {
363 "checking if the crate is_panic_runtime".to_string()
367 impl<'tcx> QueryDescription<'tcx> for queries::is_compiler_builtins<'tcx> {
368 fn describe(_: TyCtxt, _: CrateNum) -> String {
369 "checking if the crate is_compiler_builtins".to_string()
373 impl<'tcx> QueryDescription<'tcx> for queries::has_global_allocator<'tcx> {
374 fn describe(_: TyCtxt, _: CrateNum) -> String {
375 "checking if the crate has_global_allocator".to_string()
379 impl<'tcx> QueryDescription<'tcx> for queries::extern_crate<'tcx> {
380 fn describe(_: TyCtxt, _: DefId) -> String {
381 "getting crate's ExternCrateData".to_string()
385 impl<'tcx> QueryDescription<'tcx> for queries::lint_levels<'tcx> {
386 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
387 format!("computing the lint levels for items in this crate")
391 impl<'tcx> QueryDescription<'tcx> for queries::specializes<'tcx> {
392 fn describe(_tcx: TyCtxt, _: (DefId, DefId)) -> String {
393 format!("computing whether impls specialize one another")
397 impl<'tcx> QueryDescription<'tcx> for queries::in_scope_traits_map<'tcx> {
398 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
399 format!("traits in scope at a block")
403 impl<'tcx> QueryDescription<'tcx> for queries::is_no_builtins<'tcx> {
404 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
405 format!("test whether a crate has #![no_builtins]")
409 impl<'tcx> QueryDescription<'tcx> for queries::panic_strategy<'tcx> {
410 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
411 format!("query a crate's configured panic strategy")
415 impl<'tcx> QueryDescription<'tcx> for queries::is_profiler_runtime<'tcx> {
416 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
417 format!("query a crate is #![profiler_runtime]")
421 impl<'tcx> QueryDescription<'tcx> for queries::is_sanitizer_runtime<'tcx> {
422 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
423 format!("query a crate is #![sanitizer_runtime]")
427 impl<'tcx> QueryDescription<'tcx> for queries::reachable_non_generics<'tcx> {
428 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
429 format!("looking up the exported symbols of a crate")
433 impl<'tcx> QueryDescription<'tcx> for queries::native_libraries<'tcx> {
434 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
435 format!("looking up the native libraries of a linked crate")
439 impl<'tcx> QueryDescription<'tcx> for queries::foreign_modules<'tcx> {
440 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
441 format!("looking up the foreign modules of a linked crate")
445 impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> {
446 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
447 format!("looking up the plugin registrar for a crate")
451 impl<'tcx> QueryDescription<'tcx> for queries::derive_registrar_fn<'tcx> {
452 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
453 format!("looking up the derive registrar for a crate")
457 impl<'tcx> QueryDescription<'tcx> for queries::crate_disambiguator<'tcx> {
458 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
459 format!("looking up the disambiguator a crate")
463 impl<'tcx> QueryDescription<'tcx> for queries::crate_hash<'tcx> {
464 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
465 format!("looking up the hash a crate")
469 impl<'tcx> QueryDescription<'tcx> for queries::original_crate_name<'tcx> {
470 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
471 format!("looking up the original name a crate")
475 impl<'tcx> QueryDescription<'tcx> for queries::extra_filename<'tcx> {
476 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
477 format!("looking up the extra filename for a crate")
481 impl<'tcx> QueryDescription<'tcx> for queries::implementations_of_trait<'tcx> {
482 fn describe(_tcx: TyCtxt, _: (CrateNum, DefId)) -> String {
483 format!("looking up implementations of a trait in a crate")
487 impl<'tcx> QueryDescription<'tcx> for queries::all_trait_implementations<'tcx> {
488 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
489 format!("looking up all (?) trait implementations")
493 impl<'tcx> QueryDescription<'tcx> for queries::link_args<'tcx> {
494 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
495 format!("looking up link arguments for a crate")
499 impl<'tcx> QueryDescription<'tcx> for queries::resolve_lifetimes<'tcx> {
500 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
501 format!("resolving lifetimes")
505 impl<'tcx> QueryDescription<'tcx> for queries::named_region_map<'tcx> {
506 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
507 format!("looking up a named region")
511 impl<'tcx> QueryDescription<'tcx> for queries::is_late_bound_map<'tcx> {
512 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
513 format!("testing if a region is late boudn")
517 impl<'tcx> QueryDescription<'tcx> for queries::object_lifetime_defaults_map<'tcx> {
518 fn describe(_tcx: TyCtxt, _: DefIndex) -> String {
519 format!("looking up lifetime defaults for a region")
523 impl<'tcx> QueryDescription<'tcx> for queries::dep_kind<'tcx> {
524 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
525 format!("fetching what a dependency looks like")
529 impl<'tcx> QueryDescription<'tcx> for queries::crate_name<'tcx> {
530 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
531 format!("fetching what a crate is named")
535 impl<'tcx> QueryDescription<'tcx> for queries::get_lang_items<'tcx> {
536 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
537 format!("calculating the lang items map")
541 impl<'tcx> QueryDescription<'tcx> for queries::defined_lang_items<'tcx> {
542 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
543 format!("calculating the lang items defined in a crate")
547 impl<'tcx> QueryDescription<'tcx> for queries::missing_lang_items<'tcx> {
548 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
549 format!("calculating the missing lang items in a crate")
553 impl<'tcx> QueryDescription<'tcx> for queries::visible_parent_map<'tcx> {
554 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
555 format!("calculating the visible parent map")
559 impl<'tcx> QueryDescription<'tcx> for queries::missing_extern_crate_item<'tcx> {
560 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
561 format!("seeing if we're missing an `extern crate` item for this crate")
565 impl<'tcx> QueryDescription<'tcx> for queries::used_crate_source<'tcx> {
566 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
567 format!("looking at the source for a crate")
571 impl<'tcx> QueryDescription<'tcx> for queries::postorder_cnums<'tcx> {
572 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
573 format!("generating a postorder list of CrateNums")
577 impl<'tcx> QueryDescription<'tcx> for queries::maybe_unused_extern_crates<'tcx> {
578 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
579 format!("looking up all possibly unused extern crates")
583 impl<'tcx> QueryDescription<'tcx> for queries::stability_index<'tcx> {
584 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
585 format!("calculating the stability index for the local crate")
589 impl<'tcx> QueryDescription<'tcx> for queries::all_traits<'tcx> {
590 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
591 format!("fetching all foreign and local traits")
595 impl<'tcx> QueryDescription<'tcx> for queries::all_crate_nums<'tcx> {
596 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
597 format!("fetching all foreign CrateNum instances")
601 impl<'tcx> QueryDescription<'tcx> for queries::exported_symbols<'tcx> {
602 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
603 format!("exported_symbols")
607 impl<'tcx> QueryDescription<'tcx> for queries::collect_and_partition_translation_items<'tcx> {
608 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
609 format!("collect_and_partition_translation_items")
613 impl<'tcx> QueryDescription<'tcx> for queries::codegen_unit<'tcx> {
614 fn describe(_tcx: TyCtxt, _: InternedString) -> String {
615 format!("codegen_unit")
619 impl<'tcx> QueryDescription<'tcx> for queries::compile_codegen_unit<'tcx> {
620 fn describe(_tcx: TyCtxt, _: InternedString) -> String {
621 format!("compile_codegen_unit")
625 impl<'tcx> QueryDescription<'tcx> for queries::output_filenames<'tcx> {
626 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
627 format!("output_filenames")
631 impl<'tcx> QueryDescription<'tcx> for queries::vtable_methods<'tcx> {
632 fn describe(tcx: TyCtxt, key: ty::PolyTraitRef<'tcx> ) -> String {
633 format!("finding all methods for trait {}", tcx.item_path_str(key.def_id()))
637 impl<'tcx> QueryDescription<'tcx> for queries::features_query<'tcx> {
638 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
639 format!("looking up enabled feature gates")
643 impl<'tcx> QueryDescription<'tcx> for queries::typeck_tables_of<'tcx> {
645 fn cache_on_disk(def_id: Self::Key) -> bool {
649 fn try_load_from_disk(tcx: TyCtxt<'_, 'tcx, 'tcx>,
650 id: SerializedDepNodeIndex)
651 -> Option<Self::Value> {
652 let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx
653 .on_disk_query_result_cache
654 .try_load_query_result(tcx, id);
656 typeck_tables.map(|tables| tcx.alloc_tables(tables))
660 impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> {
662 fn cache_on_disk(def_id: Self::Key) -> bool {
666 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
667 id: SerializedDepNodeIndex)
668 -> Option<Self::Value> {
669 let mir: Option<::mir::Mir<'tcx>> = tcx.on_disk_query_result_cache
670 .try_load_query_result(tcx, id);
671 mir.map(|x| tcx.alloc_mir(x))
675 impl<'tcx> QueryDescription<'tcx> for queries::substitute_normalize_and_test_predicates<'tcx> {
676 fn describe(tcx: TyCtxt, key: (DefId, &'tcx Substs<'tcx>)) -> String {
677 format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0))
681 impl<'tcx> QueryDescription<'tcx> for queries::target_features_whitelist<'tcx> {
682 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
683 format!("looking up the whitelist of target features")
687 impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx> {
688 fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String {
689 format!("estimating size for `{}`", tcx.item_path_str(def.def_id()))
693 impl<'tcx> QueryDescription<'tcx> for queries::wasm_custom_sections<'tcx> {
694 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
695 format!("custom wasm sections for a crate")
699 impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> {
701 fn cache_on_disk(def_id: Self::Key) -> bool {
705 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
706 id: SerializedDepNodeIndex)
707 -> Option<Self::Value> {
708 let generics: Option<ty::Generics> = tcx.on_disk_query_result_cache
709 .try_load_query_result(tcx, id);
710 generics.map(|x| tcx.alloc_generics(x))
714 impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for<'tcx> {
715 fn describe(_tcx: TyCtxt, _: DefId) -> String {
716 format!("generating chalk-style clauses")
720 impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for_env<'tcx> {
721 fn describe(_tcx: TyCtxt, _: ty::ParamEnv<'tcx>) -> String {
722 format!("generating chalk-style clauses for param env")
726 impl<'tcx> QueryDescription<'tcx> for queries::wasm_import_module_map<'tcx> {
727 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
728 format!("wasm import module map")
732 impl<'tcx> QueryDescription<'tcx> for queries::dllimport_foreign_items<'tcx> {
733 fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
734 format!("wasm import module map")
738 macro_rules! impl_disk_cacheable_query(
739 ($query_name:ident, |$key:tt| $cond:expr) => {
740 impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> {
742 fn cache_on_disk($key: Self::Key) -> bool {
747 fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
748 id: SerializedDepNodeIndex)
749 -> Option<Self::Value> {
750 tcx.on_disk_query_result_cache.try_load_query_result(tcx, id)
756 impl_disk_cacheable_query!(unsafety_check_result, |def_id| def_id.is_local());
757 impl_disk_cacheable_query!(borrowck, |def_id| def_id.is_local());
758 impl_disk_cacheable_query!(mir_borrowck, |def_id| def_id.is_local());
759 impl_disk_cacheable_query!(mir_const_qualif, |def_id| def_id.is_local());
760 impl_disk_cacheable_query!(check_match, |def_id| def_id.is_local());
761 impl_disk_cacheable_query!(def_symbol_name, |_| true);
762 impl_disk_cacheable_query!(type_of, |def_id| def_id.is_local());
763 impl_disk_cacheable_query!(predicates_of, |def_id| def_id.is_local());
764 impl_disk_cacheable_query!(used_trait_imports, |def_id| def_id.is_local());
765 impl_disk_cacheable_query!(trans_fn_attrs, |_| true);
766 impl_disk_cacheable_query!(specialization_graph_of, |_| true);