]> git.proxmox.com Git - rustc.git/blob - src/librustc_query_system/query/mod.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_query_system / query / mod.rs
1 mod plumbing;
2 pub use self::plumbing::*;
3
4 mod job;
5 #[cfg(parallel_compiler)]
6 pub use self::job::deadlock;
7 pub use self::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo};
8
9 mod caches;
10 pub use self::caches::{CacheSelector, DefaultCacheSelector, QueryCache};
11
12 mod config;
13 pub use self::config::{QueryAccessors, QueryConfig, QueryDescription};
14
15 use crate::dep_graph::{DepContext, DepGraph};
16
17 use rustc_data_structures::fx::FxHashMap;
18 use rustc_data_structures::stable_hasher::HashStable;
19 use rustc_data_structures::sync::Lock;
20 use rustc_data_structures::thin_vec::ThinVec;
21 use rustc_errors::Diagnostic;
22 use rustc_span::def_id::DefId;
23
24 pub trait QueryContext: DepContext {
25 type Query: Clone + HashStable<Self::StableHashingContext>;
26
27 fn incremental_verify_ich(&self) -> bool;
28 fn verbose(&self) -> bool;
29
30 /// Get string representation from DefPath.
31 fn def_path_str(&self, def_id: DefId) -> String;
32
33 /// Access the DepGraph.
34 fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
35
36 /// Get the query information from the TLS context.
37 fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
38
39 fn try_collect_active_jobs(
40 &self,
41 ) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;
42
43 /// Executes a job by changing the `ImplicitCtxt` to point to the
44 /// new query job while it executes. It returns the diagnostics
45 /// captured during execution and the actual result.
46 fn start_query<R>(
47 &self,
48 token: QueryJobId<Self::DepKind>,
49 diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
50 compute: impl FnOnce(Self) -> R,
51 ) -> R;
52 }