Skip to content

Commit 8e2c9c6

Browse files
committed
Eliminate some 'a lifetimes.
Putting `+ 'tcx` on the `QueryDispatcher` trait lets a few other places be simplified.
1 parent 4ff360e commit 8e2c9c6

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

compiler/rustc_query_impl/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ where
8686
}
8787

8888
#[inline(always)]
89-
fn query_state<'a>(self, qcx: QueryCtxt<'tcx>) -> &'a QueryState<'tcx, Self::Key>
90-
where
91-
QueryCtxt<'tcx>: 'a,
92-
{
89+
fn query_state(self, qcx: QueryCtxt<'tcx>) -> &'tcx QueryState<'tcx, Self::Key> {
9390
// Safety:
9491
// This is just manually doing the subfield referencing through pointer math.
9592
unsafe {
@@ -100,7 +97,7 @@ where
10097
}
10198

10299
#[inline(always)]
103-
fn query_cache<'a>(self, qcx: QueryCtxt<'tcx>) -> &'a Self::Cache {
100+
fn query_cache(self, qcx: QueryCtxt<'tcx>) -> &'tcx Self::Cache {
104101
// Safety:
105102
// This is just manually doing the subfield referencing through pointer math.
106103
unsafe {
@@ -216,12 +213,12 @@ trait QueryDispatcherUnerased<'tcx> {
216213
) -> Self::UnerasedValue;
217214
}
218215

219-
pub fn query_system<'a>(
216+
pub fn query_system<'tcx>(
220217
local_providers: Providers,
221218
extern_providers: ExternProviders,
222219
on_disk_cache: Option<OnDiskCache>,
223220
incremental: bool,
224-
) -> QuerySystem<'a> {
221+
) -> QuerySystem<'tcx> {
225222
QuerySystem {
226223
states: Default::default(),
227224
arenas: Default::default(),

compiler/rustc_query_system/src/query/dispatcher.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type DepContextOf<'tcx, This: QueryDispatcher<'tcx>> =
2525
/// Those types are not visible from this `rustc_query_system` crate.
2626
///
2727
/// "Dispatcher" should be understood as a near-synonym of "vtable".
28-
pub trait QueryDispatcher<'tcx>: Copy {
28+
pub trait QueryDispatcher<'tcx>: Copy + 'tcx {
2929
fn name(self) -> &'static str;
3030

3131
/// Query context used by this dispatcher, i.e. `rustc_query_impl::QueryCtxt`.
@@ -41,10 +41,10 @@ pub trait QueryDispatcher<'tcx>: Copy {
4141
fn format_value(self) -> fn(&Self::Value) -> String;
4242

4343
// Don't use this method to access query results, instead use the methods on TyCtxt
44-
fn query_state<'a>(self, tcx: Self::Qcx) -> &'a QueryState<'tcx, Self::Key>;
44+
fn query_state(self, tcx: Self::Qcx) -> &'tcx QueryState<'tcx, Self::Key>;
4545

4646
// Don't use this method to access query results, instead use the methods on TyCtxt
47-
fn query_cache<'a>(self, tcx: Self::Qcx) -> &'a Self::Cache;
47+
fn query_cache(self, tcx: Self::Qcx) -> &'tcx Self::Cache;
4848

4949
fn will_cache_on_disk_for_key(self, tcx: DepContextOf<'tcx, Self>, key: &Self::Key) -> bool;
5050

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ impl<'tcx, K> Default for QueryState<'tcx, K> {
127127

128128
/// A type representing the responsibility to execute the job in the `job` field.
129129
/// This will poison the relevant query if dropped.
130-
struct JobOwner<'a, 'tcx, K>
130+
struct JobOwner<'tcx, K>
131131
where
132132
K: Eq + Hash + Copy,
133133
{
134-
state: &'a QueryState<'tcx, K>,
134+
state: &'tcx QueryState<'tcx, K>,
135135
key: K,
136136
}
137137

@@ -181,7 +181,7 @@ where
181181
}
182182
}
183183

184-
impl<'a, 'tcx, K> JobOwner<'a, 'tcx, K>
184+
impl<'tcx, K> JobOwner<'tcx, K>
185185
where
186186
K: Eq + Hash + Copy,
187187
{
@@ -218,7 +218,7 @@ where
218218
}
219219
}
220220

221-
impl<'a, 'tcx, K> Drop for JobOwner<'a, 'tcx, K>
221+
impl<'tcx, K> Drop for JobOwner<'tcx, K>
222222
where
223223
K: Eq + Hash + Copy,
224224
{
@@ -422,7 +422,7 @@ where
422422
fn execute_job<'tcx, Q, const INCR: bool>(
423423
query: Q,
424424
qcx: Q::Qcx,
425-
state: &QueryState<'tcx, Q::Key>,
425+
state: &'tcx QueryState<'tcx, Q::Key>,
426426
key: Q::Key,
427427
key_hash: u64,
428428
id: QueryJobId,

0 commit comments

Comments
 (0)