Skip to content

Commit 84b9b13

Browse files
committed
Rename some Cache type variables as C.
Currently type variables that impl `QueryCache` are called either `C` or `Cache`. I find the former clearer because single char type variables names are very common and longer type variable names are easy to mistake for type or trait names -- e.g. I find the trait bound `C: QueryCache` much easier and faster to read than `Cache: QueryCache`.
1 parent 54314d7 commit 84b9b13

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

compiler/rustc_middle/src/query/inner.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ where
3232
/// Shared implementation of `tcx.$query(..)` and `tcx.at(span).$query(..)`
3333
/// for all queries.
3434
#[inline(always)]
35-
pub(crate) fn query_get_at<'tcx, Cache>(
35+
pub(crate) fn query_get_at<'tcx, C>(
3636
tcx: TyCtxt<'tcx>,
37-
execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>,
38-
query_cache: &Cache,
37+
execute_query: fn(TyCtxt<'tcx>, Span, C::Key, QueryMode) -> Option<C::Value>,
38+
query_cache: &C,
3939
span: Span,
40-
key: Cache::Key,
41-
) -> Cache::Value
40+
key: C::Key,
41+
) -> C::Value
4242
where
43-
Cache: QueryCache,
43+
C: QueryCache,
4444
{
4545
match try_get_cached(tcx, query_cache, &key) {
4646
Some(value) => value,
@@ -51,14 +51,14 @@ where
5151
/// Shared implementation of `tcx.ensure_ok().$query(..)` for most queries,
5252
/// and `tcx.ensure_done().$query(..)` for all queries.
5353
#[inline]
54-
pub(crate) fn query_ensure<'tcx, Cache>(
54+
pub(crate) fn query_ensure<'tcx, C>(
5555
tcx: TyCtxt<'tcx>,
56-
execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>,
57-
query_cache: &Cache,
58-
key: Cache::Key,
56+
execute_query: fn(TyCtxt<'tcx>, Span, C::Key, QueryMode) -> Option<C::Value>,
57+
query_cache: &C,
58+
key: C::Key,
5959
check_cache: bool,
6060
) where
61-
Cache: QueryCache,
61+
C: QueryCache,
6262
{
6363
if try_get_cached(tcx, query_cache, &key).is_none() {
6464
execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure { check_cache });
@@ -68,15 +68,15 @@ pub(crate) fn query_ensure<'tcx, Cache>(
6868
/// Shared implementation of `tcx.ensure_ok().$query(..)` for queries that
6969
/// have the `return_result_from_ensure_ok` modifier.
7070
#[inline]
71-
pub(crate) fn query_ensure_error_guaranteed<'tcx, Cache, T>(
71+
pub(crate) fn query_ensure_error_guaranteed<'tcx, C, T>(
7272
tcx: TyCtxt<'tcx>,
73-
execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>,
74-
query_cache: &Cache,
75-
key: Cache::Key,
73+
execute_query: fn(TyCtxt<'tcx>, Span, C::Key, QueryMode) -> Option<C::Value>,
74+
query_cache: &C,
75+
key: C::Key,
7676
check_cache: bool,
7777
) -> Result<(), ErrorGuaranteed>
7878
where
79-
Cache: QueryCache<Value = Erased<Result<T, ErrorGuaranteed>>>,
79+
C: QueryCache<Value = Erased<Result<T, ErrorGuaranteed>>>,
8080
Result<T, ErrorGuaranteed>: Erasable,
8181
{
8282
if let Some(res) = try_get_cached(tcx, query_cache, &key) {
@@ -96,15 +96,15 @@ where
9696
}
9797

9898
/// Common implementation of query feeding, used by `define_feedable!`.
99-
pub(crate) fn query_feed<'tcx, Cache>(
99+
pub(crate) fn query_feed<'tcx, C>(
100100
tcx: TyCtxt<'tcx>,
101101
dep_kind: DepKind,
102-
query_vtable: &QueryVTable<'tcx, Cache>,
103-
key: Cache::Key,
104-
value: Cache::Value,
102+
query_vtable: &QueryVTable<'tcx, C>,
103+
key: C::Key,
104+
value: C::Value,
105105
) where
106-
Cache: QueryCache,
107-
Cache::Key: DepNodeKey<'tcx>,
106+
C: QueryCache,
107+
C::Key: DepNodeKey<'tcx>,
108108
{
109109
let format_value = query_vtable.format_value;
110110

compiler/rustc_query_impl/src/dep_kind_vtables.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,18 @@ mod non_query {
102102

103103
/// Shared implementation of the [`DepKindVTable`] constructor for queries.
104104
/// Called from macro-generated code for each query.
105-
pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q, Cache>(
105+
pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q, C>(
106106
is_anon: bool,
107107
is_eval_always: bool,
108108
) -> DepKindVTable<'tcx>
109109
where
110-
Q: QueryDispatcherUnerased<'tcx, Cache>,
111-
Cache: QueryCache + 'tcx,
110+
Q: QueryDispatcherUnerased<'tcx, C>,
111+
C: QueryCache + 'tcx,
112112
{
113113
let key_fingerprint_style = if is_anon {
114114
KeyFingerprintStyle::Opaque
115115
} else {
116-
<Cache::Key as DepNodeKey<'tcx>>::key_fingerprint_style()
116+
<C::Key as DepNodeKey<'tcx>>::key_fingerprint_style()
117117
};
118118

119119
if is_anon || !key_fingerprint_style.reconstructible() {

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ where
306306
QueryStackFrameExtra::new(description, span, def_kind)
307307
}
308308

309-
pub(crate) fn create_deferred_query_stack_frame<'tcx, Cache>(
309+
pub(crate) fn create_deferred_query_stack_frame<'tcx, C>(
310310
tcx: TyCtxt<'tcx>,
311-
vtable: &'tcx QueryVTable<'tcx, Cache>,
312-
key: Cache::Key,
311+
vtable: &'tcx QueryVTable<'tcx, C>,
312+
key: C::Key,
313313
) -> QueryStackFrame<QueryStackDeferred<'tcx>>
314314
where
315-
Cache: QueryCache,
316-
Cache::Key: Key + DynSend + DynSync,
317-
QueryVTable<'tcx, Cache>: DynSync,
315+
C: QueryCache,
316+
C::Key: Key + DynSend + DynSync,
317+
QueryVTable<'tcx, C>: DynSync,
318318
{
319319
let kind = vtable.dep_kind;
320320

0 commit comments

Comments
 (0)