Skip to content

Commit 6d26ea8

Browse files
committed
Rename Ctxt and CTX to Tcx and Qcx
This makes it consistent and clear which context is used.
1 parent 16558bd commit 6d26ea8

File tree

7 files changed

+109
-109
lines changed

7 files changed

+109
-109
lines changed

compiler/rustc_query_system/src/cache.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<Key, Value> Cache<Key, Value> {
2626
}
2727

2828
impl<Key: Eq + Hash, Value: Clone> Cache<Key, Value> {
29-
pub fn get<CTX: DepContext>(&self, key: &Key, tcx: CTX) -> Option<Value> {
29+
pub fn get<Tcx: DepContext>(&self, key: &Key, tcx: Tcx) -> Option<Value> {
3030
Some(self.hashmap.borrow().get(key)?.get(tcx))
3131
}
3232

@@ -46,7 +46,7 @@ impl<T: Clone> WithDepNode<T> {
4646
WithDepNode { dep_node, cached_value }
4747
}
4848

49-
pub fn get<CTX: DepContext>(&self, tcx: CTX) -> T {
49+
pub fn get<Tcx: DepContext>(&self, tcx: Tcx) -> T {
5050
tcx.dep_graph().read_index(self.dep_node);
5151
self.cached_value.clone()
5252
}

compiler/rustc_query_system/src/dep_graph/dep_node.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ impl<K: DepKind> DepNode<K> {
6161
/// Creates a new, parameterless DepNode. This method will assert
6262
/// that the DepNode corresponding to the given DepKind actually
6363
/// does not require any parameters.
64-
pub fn new_no_params<Ctxt>(tcx: Ctxt, kind: K) -> DepNode<K>
64+
pub fn new_no_params<Tcx>(tcx: Tcx, kind: K) -> DepNode<K>
6565
where
66-
Ctxt: super::DepContext<DepKind = K>,
66+
Tcx: super::DepContext<DepKind = K>,
6767
{
6868
debug_assert_eq!(tcx.fingerprint_style(kind), FingerprintStyle::Unit);
6969
DepNode { kind, hash: Fingerprint::ZERO.into() }
7070
}
7171

72-
pub fn construct<Ctxt, Key>(tcx: Ctxt, kind: K, arg: &Key) -> DepNode<K>
72+
pub fn construct<Tcx, Key>(tcx: Tcx, kind: K, arg: &Key) -> DepNode<K>
7373
where
74-
Ctxt: super::DepContext<DepKind = K>,
75-
Key: DepNodeParams<Ctxt>,
74+
Tcx: super::DepContext<DepKind = K>,
75+
Key: DepNodeParams<Tcx>,
7676
{
7777
let hash = arg.to_fingerprint(tcx);
7878
let dep_node = DepNode { kind, hash: hash.into() };
@@ -93,9 +93,9 @@ impl<K: DepKind> DepNode<K> {
9393
/// Construct a DepNode from the given DepKind and DefPathHash. This
9494
/// method will assert that the given DepKind actually requires a
9595
/// single DefId/DefPathHash parameter.
96-
pub fn from_def_path_hash<Ctxt>(tcx: Ctxt, def_path_hash: DefPathHash, kind: K) -> Self
96+
pub fn from_def_path_hash<Tcx>(tcx: Tcx, def_path_hash: DefPathHash, kind: K) -> Self
9797
where
98-
Ctxt: super::DepContext<DepKind = K>,
98+
Tcx: super::DepContext<DepKind = K>,
9999
{
100100
debug_assert!(tcx.fingerprint_style(kind) == FingerprintStyle::DefPathHash);
101101
DepNode { kind, hash: def_path_hash.0.into() }
@@ -108,18 +108,18 @@ impl<K: DepKind> fmt::Debug for DepNode<K> {
108108
}
109109
}
110110

111-
pub trait DepNodeParams<Ctxt: DepContext>: fmt::Debug + Sized {
111+
pub trait DepNodeParams<Tcx: DepContext>: fmt::Debug + Sized {
112112
fn fingerprint_style() -> FingerprintStyle;
113113

114114
/// This method turns the parameters of a DepNodeConstructor into an opaque
115115
/// Fingerprint to be used in DepNode.
116116
/// Not all DepNodeParams support being turned into a Fingerprint (they
117117
/// don't need to if the corresponding DepNode is anonymous).
118-
fn to_fingerprint(&self, _: Ctxt) -> Fingerprint {
118+
fn to_fingerprint(&self, _: Tcx) -> Fingerprint {
119119
panic!("Not implemented. Accidentally called on anonymous node?")
120120
}
121121

122-
fn to_debug_str(&self, _: Ctxt) -> String {
122+
fn to_debug_str(&self, _: Tcx) -> String {
123123
format!("{:?}", self)
124124
}
125125

@@ -129,10 +129,10 @@ pub trait DepNodeParams<Ctxt: DepContext>: fmt::Debug + Sized {
129129
/// `fingerprint_style()` is not `FingerprintStyle::Opaque`.
130130
/// It is always valid to return `None` here, in which case incremental
131131
/// compilation will treat the query as having changed instead of forcing it.
132-
fn recover(tcx: Ctxt, dep_node: &DepNode<Ctxt::DepKind>) -> Option<Self>;
132+
fn recover(tcx: Tcx, dep_node: &DepNode<Tcx::DepKind>) -> Option<Self>;
133133
}
134134

135-
impl<Ctxt: DepContext, T> DepNodeParams<Ctxt> for T
135+
impl<Tcx: DepContext, T> DepNodeParams<Tcx> for T
136136
where
137137
T: for<'a> HashStable<StableHashingContext<'a>> + fmt::Debug,
138138
{
@@ -142,7 +142,7 @@ where
142142
}
143143

144144
#[inline(always)]
145-
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint {
145+
default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint {
146146
tcx.with_stable_hashing_context(|mut hcx| {
147147
let mut hasher = StableHasher::new();
148148
self.hash_stable(&mut hcx, &mut hasher);
@@ -151,12 +151,12 @@ where
151151
}
152152

153153
#[inline(always)]
154-
default fn to_debug_str(&self, _: Ctxt) -> String {
154+
default fn to_debug_str(&self, _: Tcx) -> String {
155155
format!("{:?}", *self)
156156
}
157157

158158
#[inline(always)]
159-
default fn recover(_: Ctxt, _: &DepNode<Ctxt::DepKind>) -> Option<Self> {
159+
default fn recover(_: Tcx, _: &DepNode<Tcx::DepKind>) -> Option<Self> {
160160
None
161161
}
162162
}
@@ -166,7 +166,7 @@ where
166166
/// Information is retrieved by indexing the `DEP_KINDS` array using the integer value
167167
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
168168
/// jump table instead of large matches.
169-
pub struct DepKindStruct<CTX: DepContext> {
169+
pub struct DepKindStruct<Tcx: DepContext> {
170170
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
171171
/// When their result is needed, it is recomputed. They are useful for fine-grained
172172
/// dependency tracking, and caching within one compiler invocation.
@@ -216,10 +216,10 @@ pub struct DepKindStruct<CTX: DepContext> {
216216
/// with kind `MirValidated`, we know that the GUID/fingerprint of the `DepNode`
217217
/// is actually a `DefPathHash`, and can therefore just look up the corresponding
218218
/// `DefId` in `tcx.def_path_hash_to_def_id`.
219-
pub force_from_dep_node: Option<fn(tcx: CTX, dep_node: DepNode<CTX::DepKind>) -> bool>,
219+
pub force_from_dep_node: Option<fn(tcx: Tcx, dep_node: DepNode<Tcx::DepKind>) -> bool>,
220220

221221
/// Invoke a query to put the on-disk cached value in memory.
222-
pub try_load_from_on_disk_cache: Option<fn(CTX, DepNode<CTX::DepKind>)>,
222+
pub try_load_from_on_disk_cache: Option<fn(Tcx, DepNode<Tcx::DepKind>)>,
223223
}
224224

225225
/// A "work product" corresponds to a `.o` (or other) file that we

compiler/rustc_query_system/src/dep_graph/graph.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ impl<K: DepKind> DepGraph<K> {
377377

378378
/// Executes something within an "anonymous" task, that is, a task the
379379
/// `DepNode` of which is determined by the list of inputs it read from.
380-
pub fn with_anon_task<Ctxt: DepContext<DepKind = K>, OP, R>(
380+
pub fn with_anon_task<Tcx: DepContext<DepKind = K>, OP, R>(
381381
&self,
382-
cx: Ctxt,
382+
cx: Tcx,
383383
dep_kind: K,
384384
op: OP,
385385
) -> (R, DepNodeIndex)
@@ -571,9 +571,9 @@ impl<K: DepKind> DepGraph<K> {
571571
/// A node will have an index, when it's already been marked green, or when we can mark it
572572
/// green. This function will mark the current task as a reader of the specified node, when
573573
/// a node index can be found for that node.
574-
pub fn try_mark_green<Ctxt: QueryContext<DepKind = K>>(
574+
pub fn try_mark_green<Qcx: QueryContext<DepKind = K>>(
575575
&self,
576-
qcx: Ctxt,
576+
qcx: Qcx,
577577
dep_node: &DepNode<K>,
578578
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> {
579579
debug_assert!(!qcx.dep_context().is_eval_always(dep_node.kind));
@@ -599,9 +599,9 @@ impl<K: DepKind> DepGraph<K> {
599599
}
600600

601601
#[instrument(skip(self, qcx, data, parent_dep_node_index), level = "debug")]
602-
fn try_mark_parent_green<Ctxt: QueryContext<DepKind = K>>(
602+
fn try_mark_parent_green<Qcx: QueryContext<DepKind = K>>(
603603
&self,
604-
qcx: Ctxt,
604+
qcx: Qcx,
605605
data: &DepGraphData<K>,
606606
parent_dep_node_index: SerializedDepNodeIndex,
607607
dep_node: &DepNode<K>,
@@ -687,9 +687,9 @@ impl<K: DepKind> DepGraph<K> {
687687

688688
/// Try to mark a dep-node which existed in the previous compilation session as green.
689689
#[instrument(skip(self, qcx, data, prev_dep_node_index), level = "debug")]
690-
fn try_mark_previous_green<Ctxt: QueryContext<DepKind = K>>(
690+
fn try_mark_previous_green<Qcx: QueryContext<DepKind = K>>(
691691
&self,
692-
qcx: Ctxt,
692+
qcx: Qcx,
693693
data: &DepGraphData<K>,
694694
prev_dep_node_index: SerializedDepNodeIndex,
695695
dep_node: &DepNode<K>,
@@ -755,9 +755,9 @@ impl<K: DepKind> DepGraph<K> {
755755
/// This may be called concurrently on multiple threads for the same dep node.
756756
#[cold]
757757
#[inline(never)]
758-
fn emit_side_effects<Ctxt: QueryContext<DepKind = K>>(
758+
fn emit_side_effects<Qcx: QueryContext<DepKind = K>>(
759759
&self,
760-
qcx: Ctxt,
760+
qcx: Qcx,
761761
data: &DepGraphData<K>,
762762
dep_node_index: DepNodeIndex,
763763
side_effects: QuerySideEffects,
@@ -799,7 +799,7 @@ impl<K: DepKind> DepGraph<K> {
799799
//
800800
// This method will only load queries that will end up in the disk cache.
801801
// Other queries will not be executed.
802-
pub fn exec_cache_promotions<Ctxt: DepContext<DepKind = K>>(&self, tcx: Ctxt) {
802+
pub fn exec_cache_promotions<Tcx: DepContext<DepKind = K>>(&self, tcx: Tcx) {
803803
let _prof_timer = tcx.profiler().generic_activity("incr_comp_query_cache_promotion");
804804

805805
let data = self.data.as_ref().unwrap();

compiler/rustc_query_system/src/query/config.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
1111
use std::fmt::Debug;
1212
use std::hash::Hash;
1313

14-
pub trait QueryConfig<CTX: QueryContext> {
14+
pub trait QueryConfig<Qcx: QueryContext> {
1515
const NAME: &'static str;
1616

1717
type Key: Eq + Hash + Clone + Debug;
@@ -21,47 +21,47 @@ pub trait QueryConfig<CTX: QueryContext> {
2121
type Cache: QueryCache<Key = Self::Key, Stored = Self::Stored, Value = Self::Value>;
2222

2323
// Don't use this method to access query results, instead use the methods on TyCtxt
24-
fn query_state<'a>(tcx: CTX) -> &'a QueryState<Self::Key>
24+
fn query_state<'a>(tcx: Qcx) -> &'a QueryState<Self::Key>
2525
where
26-
CTX: 'a;
26+
Qcx: 'a;
2727

2828
// Don't use this method to access query results, instead use the methods on TyCtxt
29-
fn query_cache<'a>(tcx: CTX) -> &'a Self::Cache
29+
fn query_cache<'a>(tcx: Qcx) -> &'a Self::Cache
3030
where
31-
CTX: 'a;
31+
Qcx: 'a;
3232

3333
// Don't use this method to compute query results, instead use the methods on TyCtxt
34-
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVTable<CTX, Self::Key, Self::Value>;
34+
fn make_vtable(tcx: Qcx, key: &Self::Key) -> QueryVTable<Qcx, Self::Key, Self::Value>;
3535

36-
fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool;
36+
fn cache_on_disk(tcx: Qcx::DepContext, key: &Self::Key) -> bool;
3737

3838
// Don't use this method to compute query results, instead use the methods on TyCtxt
39-
fn execute_query(tcx: CTX::DepContext, k: Self::Key) -> Self::Stored;
39+
fn execute_query(tcx: Qcx::DepContext, k: Self::Key) -> Self::Stored;
4040
}
4141

4242
#[derive(Copy, Clone)]
43-
pub struct QueryVTable<CTX: QueryContext, K, V> {
43+
pub struct QueryVTable<Qcx: QueryContext, K, V> {
4444
pub anon: bool,
45-
pub dep_kind: CTX::DepKind,
45+
pub dep_kind: Qcx::DepKind,
4646
pub eval_always: bool,
4747
pub depth_limit: bool,
4848

49-
pub compute: fn(CTX::DepContext, K) -> V,
49+
pub compute: fn(Qcx::DepContext, K) -> V,
5050
pub hash_result: Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>,
5151
pub handle_cycle_error: HandleCycleError,
5252
// NOTE: this is also `None` if `cache_on_disk()` returns false, not just if it's unsupported by the query
53-
pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>,
53+
pub try_load_from_disk: Option<fn(Qcx, SerializedDepNodeIndex) -> Option<V>>,
5454
}
5555

56-
impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> {
57-
pub(crate) fn to_dep_node(&self, tcx: CTX::DepContext, key: &K) -> DepNode<CTX::DepKind>
56+
impl<Qcx: QueryContext, K, V> QueryVTable<Qcx, K, V> {
57+
pub(crate) fn to_dep_node(&self, tcx: Qcx::DepContext, key: &K) -> DepNode<Qcx::DepKind>
5858
where
59-
K: crate::dep_graph::DepNodeParams<CTX::DepContext>,
59+
K: crate::dep_graph::DepNodeParams<Qcx::DepContext>,
6060
{
6161
DepNode::construct(tcx, self.dep_kind, key)
6262
}
6363

64-
pub(crate) fn compute(&self, tcx: CTX::DepContext, key: K) -> V {
64+
pub(crate) fn compute(&self, tcx: Qcx::DepContext, key: K) -> V {
6565
(self.compute)(tcx, key)
6666
}
6767
}

compiler/rustc_query_system/src/query/job.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ pub(crate) fn report_cycle<'a>(
596596
cycle_diag.into_diagnostic(&sess.parse_sess.span_diagnostic)
597597
}
598598

599-
pub fn print_query_stack<CTX: QueryContext>(
600-
qcx: CTX,
599+
pub fn print_query_stack<Qcx: QueryContext>(
600+
qcx: Qcx,
601601
mut current_query: Option<QueryJobId>,
602602
handler: &Handler,
603603
num_frames: Option<usize>,

0 commit comments

Comments
 (0)