Skip to main content

rustc_middle/query/
mod.rs

1use rustc_data_structures::jobserver::Proxy;
2use rustc_hir::def_id::LocalDefId;
3use rustc_query_system::query::QuerySideEffect;
4
5pub use self::caches::{
6    DefIdCache, DefaultCache, QueryCache, QueryCacheKey, SingleCache, VecCache,
7};
8pub use self::job::{QueryInfo, QueryJob, QueryJobId, QueryLatch, QueryWaiter};
9pub use self::keys::{AsLocalKey, Key, LocalCrate};
10pub use self::plumbing::{
11    ActiveKeyStatus, CycleError, CycleErrorHandling, IntoQueryParam, QueryMode, QueryState,
12    TyCtxtAt, TyCtxtEnsureDone, TyCtxtEnsureOk,
13};
14pub use self::stack::{QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra};
15use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
16pub use crate::queries::Providers;
17use crate::ty::TyCtxt;
18
19pub(crate) mod arena_cached;
20mod caches;
21pub mod erase;
22pub(crate) mod inner;
23mod job;
24mod keys;
25pub mod on_disk_cache;
26#[macro_use]
27pub mod plumbing;
28pub(crate) mod modifiers;
29mod stack;
30
31pub fn describe_as_module(def_id: impl Into<LocalDefId>, tcx: TyCtxt<'_>) -> String {
32    let def_id = def_id.into();
33    if def_id.is_top_level_module() {
34        "top-level module".to_string()
35    } else {
36        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("module `{0}`",
                tcx.def_path_str(def_id)))
    })format!("module `{}`", tcx.def_path_str(def_id))
37    }
38}
39
40pub trait QueryContext<'tcx>: HasDepContext {
41    /// Gets a jobserver reference which is used to release then acquire
42    /// a token while waiting on a query.
43    fn jobserver_proxy(&self) -> &Proxy;
44
45    /// Load a side effect associated to the node in the previous session.
46    fn load_side_effect(
47        self,
48        prev_dep_node_index: SerializedDepNodeIndex,
49    ) -> Option<QuerySideEffect>;
50
51    /// Register a side effect for the given node, for use in next session.
52    fn store_side_effect(self, dep_node_index: DepNodeIndex, side_effect: QuerySideEffect);
53}