]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_query_impl/src/lib.rs
Rollup merge of #97269 - RalfJung:transmute, r=m-ou-se
[rust.git] / compiler / rustc_query_impl / src / lib.rs
1 //! Support for serializing the dep-graph and reloading it.
2
3 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
4 #![feature(min_specialization)]
5 #![feature(never_type)]
6 #![feature(once_cell)]
7 #![feature(rustc_attrs)]
8 #![recursion_limit = "256"]
9 #![allow(rustc::potential_query_instability)]
10
11 #[macro_use]
12 extern crate rustc_macros;
13 #[macro_use]
14 extern crate rustc_middle;
15
16 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
17 use rustc_data_structures::sync::AtomicU64;
18 use rustc_middle::arena::Arena;
19 use rustc_middle::dep_graph::{self, DepKindStruct, SerializedDepNodeIndex};
20 use rustc_middle::ty::query::{query_keys, query_storage, query_stored, query_values};
21 use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine};
22 use rustc_middle::ty::{self, TyCtxt};
23 use rustc_span::def_id::{LocalDefId, LOCAL_CRATE};
24 use rustc_span::Span;
25
26 #[macro_use]
27 mod plumbing;
28 pub use plumbing::QueryCtxt;
29 use rustc_query_system::query::*;
30
31 mod keys;
32 use keys::Key;
33
34 mod values;
35 use self::values::Value;
36
37 pub use rustc_query_system::query::QueryConfig;
38 pub(crate) use rustc_query_system::query::{QueryDescription, QueryVtable};
39
40 mod on_disk_cache;
41 pub use on_disk_cache::OnDiskCache;
42
43 mod profiling_support;
44 pub use self::profiling_support::alloc_self_profile_query_strings;
45
46 fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
47     if def_id.is_top_level_module() {
48         "top-level module".to_string()
49     } else {
50         format!("module `{}`", tcx.def_path_str(def_id.to_def_id()))
51     }
52 }
53
54 rustc_query_append! { [define_queries!][<'tcx>] }
55
56 impl<'tcx> Queries<'tcx> {
57     // Force codegen in the dyn-trait transformation in this crate.
58     pub fn as_dyn(&'tcx self) -> &'tcx dyn QueryEngine<'tcx> {
59         self
60     }
61 }