forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.rs
More file actions
86 lines (69 loc) · 2.44 KB
/
mod.rs
File metadata and controls
86 lines (69 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_query_system::dep_graph::{DEP_KIND_UNUSED_BITS, unused_dep_kind_bits};
use rustc_query_system::ich::StableHashingContext;
use rustc_session::Session;
use crate::ty::print::with_reduced_queries;
use crate::ty::{self, TyCtxt};
#[macro_use]
mod dep_node;
pub use dep_node::{
DEP_KIND_NAMES, DEP_KIND_VARIANTS, DepKind, DepNode, DepNodeExt, dep_kind_from_label,
dep_kinds, label_strs,
};
pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item, make_metadata};
pub use rustc_query_system::dep_graph::debug::{DepNodeFilter, EdgeFilter};
pub use rustc_query_system::dep_graph::{
DepContext, DepGraphQuery, DepNodeIndex, Deps, SerializedDepGraph, SerializedDepNodeIndex,
TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, hash_result,
};
pub type DepGraph = rustc_query_system::dep_graph::DepGraph;
pub type DepKindVTable<'tcx> = rustc_query_system::dep_graph::DepKindVTable<TyCtxt<'tcx>>;
pub struct DepsType;
impl Deps for DepsType {
fn with_deps<OP, R>(task_deps: TaskDepsRef<'_>, op: OP) -> R
where
OP: FnOnce() -> R,
{
ty::tls::with_context(|icx| {
let icx = ty::tls::ImplicitCtxt { task_deps, ..icx.clone() };
ty::tls::enter_context(&icx, op)
})
}
fn read_deps<OP>(op: OP)
where
OP: for<'a> FnOnce(TaskDepsRef<'a>),
{
ty::tls::with_context_opt(|icx| {
let Some(icx) = icx else { return };
op(icx.task_deps)
})
}
}
/// Verify that the unused bits for the dep kind matches the hardcoded value in `rustc_query_system`.
const _: [(); unused_dep_kind_bits(dep_node::DEP_KIND_VARIANTS)] = [(); DEP_KIND_UNUSED_BITS];
impl<'tcx> DepContext for TyCtxt<'tcx> {
type Deps = DepsType;
#[inline]
fn with_stable_hashing_context<R>(self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R {
TyCtxt::with_stable_hashing_context(self, f)
}
#[inline]
fn dep_graph(&self) -> &DepGraph {
&self.dep_graph
}
#[inline(always)]
fn profiler(&self) -> &SelfProfilerRef {
&self.prof
}
#[inline(always)]
fn sess(&self) -> &Session {
self.sess
}
#[inline]
fn dep_kind_vtable(&self, dk: DepKind) -> &DepKindVTable<'tcx> {
&self.dep_kind_vtables[dk.as_usize()]
}
fn with_reduced_queries<T>(self, f: impl FnOnce() -> T) -> T {
with_reduced_queries!(f())
}
}