Skip to content

Commit 06cd823

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 e45224c commit 06cd823

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

compiler/rustc_middle/src/query/inner.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ where
3333
/// Shared implementation of `tcx.$query(..)` and `tcx.at(span).$query(..)`
3434
/// for all queries.
3535
#[inline(always)]
36-
pub(crate) fn query_get_at<'tcx, Cache>(
36+
pub(crate) fn query_get_at<'tcx, C>(
3737
tcx: TyCtxt<'tcx>,
38-
execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>,
39-
query_cache: &Cache,
38+
execute_query: fn(TyCtxt<'tcx>, Span, C::Key, QueryMode) -> Option<C::Value>,
39+
query_cache: &C,
4040
span: Span,
41-
key: Cache::Key,
42-
) -> Cache::Value
41+
key: C::Key,
42+
) -> C::Value
4343
where
44-
Cache: QueryCache,
44+
C: QueryCache,
4545
{
4646
match try_get_cached(tcx, query_cache, &key) {
4747
Some(value) => value,
@@ -52,14 +52,14 @@ where
5252
/// Shared implementation of `tcx.ensure_ok().$query(..)` for most queries,
5353
/// and `tcx.ensure_done().$query(..)` for all queries.
5454
#[inline]
55-
pub(crate) fn query_ensure<'tcx, Cache>(
55+
pub(crate) fn query_ensure<'tcx, C>(
5656
tcx: TyCtxt<'tcx>,
57-
execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>,
58-
query_cache: &Cache,
59-
key: Cache::Key,
57+
execute_query: fn(TyCtxt<'tcx>, Span, C::Key, QueryMode) -> Option<C::Value>,
58+
query_cache: &C,
59+
key: C::Key,
6060
ensure_mode: EnsureMode,
6161
) where
62-
Cache: QueryCache,
62+
C: QueryCache,
6363
{
6464
if try_get_cached(tcx, query_cache, &key).is_none() {
6565
execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure { ensure_mode });
@@ -69,17 +69,17 @@ pub(crate) fn query_ensure<'tcx, Cache>(
6969
/// Shared implementation of `tcx.ensure_ok().$query(..)` for queries that
7070
/// have the `return_result_from_ensure_ok` modifier.
7171
#[inline]
72-
pub(crate) fn query_ensure_error_guaranteed<'tcx, Cache, T>(
72+
pub(crate) fn query_ensure_error_guaranteed<'tcx, C, T>(
7373
tcx: TyCtxt<'tcx>,
74-
execute_query: fn(TyCtxt<'tcx>, Span, Cache::Key, QueryMode) -> Option<Cache::Value>,
75-
query_cache: &Cache,
76-
key: Cache::Key,
74+
execute_query: fn(TyCtxt<'tcx>, Span, C::Key, QueryMode) -> Option<C::Value>,
75+
query_cache: &C,
76+
key: C::Key,
7777
// This arg is needed to match the signature of `query_ensure`,
7878
// but should always be `EnsureMode::Ok`.
7979
ensure_mode: EnsureMode,
8080
) -> Result<(), ErrorGuaranteed>
8181
where
82-
Cache: QueryCache<Value = Erased<Result<T, ErrorGuaranteed>>>,
82+
C: QueryCache<Value = Erased<Result<T, ErrorGuaranteed>>>,
8383
Result<T, ErrorGuaranteed>: Erasable,
8484
{
8585
assert_matches!(ensure_mode, EnsureMode::Ok);
@@ -101,15 +101,15 @@ where
101101
}
102102

103103
/// Common implementation of query feeding, used by `define_feedable!`.
104-
pub(crate) fn query_feed<'tcx, Cache>(
104+
pub(crate) fn query_feed<'tcx, C>(
105105
tcx: TyCtxt<'tcx>,
106106
dep_kind: DepKind,
107-
query_vtable: &QueryVTable<'tcx, Cache>,
108-
key: Cache::Key,
109-
value: Cache::Value,
107+
query_vtable: &QueryVTable<'tcx, C>,
108+
key: C::Key,
109+
value: C::Value,
110110
) where
111-
Cache: QueryCache,
112-
Cache::Key: DepNodeKey<'tcx>,
111+
C: QueryCache,
112+
C::Key: DepNodeKey<'tcx>,
113113
{
114114
let format_value = query_vtable.format_value;
115115

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)