Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b089433

Browse files
committed
Unpack type arguments for QueryStateShard.
1 parent 1249032 commit b089433

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/librustc/ty/query/plumbing.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use crate::dep_graph::{DepNode, DepNodeIndex, SerializedDepNodeIndex};
66
use crate::ty::query::caches::QueryCache;
7-
use crate::ty::query::config::{QueryAccessors, QueryDescription};
7+
use crate::ty::query::config::{QueryAccessors, QueryConfig, QueryDescription};
88
use crate::ty::query::job::{QueryInfo, QueryJob, QueryJobId, QueryShardJobId};
99
use crate::ty::query::Query;
1010
use crate::ty::tls;
@@ -27,25 +27,32 @@ use std::ptr;
2727
#[cfg(debug_assertions)]
2828
use std::sync::atomic::{AtomicUsize, Ordering};
2929

30-
pub(crate) struct QueryStateShard<'tcx, D: QueryAccessors<'tcx> + ?Sized> {
31-
pub(super) cache: <<D as QueryAccessors<'tcx>>::Cache as QueryCache<D::Key, D::Value>>::Sharded,
32-
pub(super) active: FxHashMap<D::Key, QueryResult<'tcx>>,
30+
pub(crate) type QueryStateShard<'tcx, Q> = QueryStateShardImpl<
31+
'tcx,
32+
<Q as QueryConfig<'tcx>>::Key,
33+
<<Q as QueryAccessors<'tcx>>::Cache as QueryCache<
34+
<Q as QueryConfig<'tcx>>::Key,
35+
<Q as QueryConfig<'tcx>>::Value,
36+
>>::Sharded,
37+
>;
38+
39+
pub(crate) struct QueryStateShardImpl<'tcx, K, C> {
40+
pub(super) cache: C,
41+
pub(super) active: FxHashMap<K, QueryResult<'tcx>>,
3342

3443
/// Used to generate unique ids for active jobs.
3544
pub(super) jobs: u32,
3645
}
3746

38-
impl<'tcx, Q: QueryAccessors<'tcx>> QueryStateShard<'tcx, Q> {
39-
fn get_cache(
40-
&mut self,
41-
) -> &mut <<Q as QueryAccessors<'tcx>>::Cache as QueryCache<Q::Key, Q::Value>>::Sharded {
47+
impl<'tcx, K, C> QueryStateShardImpl<'tcx, K, C> {
48+
fn get_cache(&mut self) -> &mut C {
4249
&mut self.cache
4350
}
4451
}
4552

46-
impl<'tcx, Q: QueryAccessors<'tcx>> Default for QueryStateShard<'tcx, Q> {
47-
fn default() -> QueryStateShard<'tcx, Q> {
48-
QueryStateShard { cache: Default::default(), active: Default::default(), jobs: 0 }
53+
impl<'tcx, K, C: Default> Default for QueryStateShardImpl<'tcx, K, C> {
54+
fn default() -> QueryStateShardImpl<'tcx, K, C> {
55+
QueryStateShardImpl { cache: Default::default(), active: Default::default(), jobs: 0 }
4956
}
5057
}
5158

@@ -122,7 +129,7 @@ pub(super) struct JobOwner<'tcx, Q: QueryDescription<'tcx>> {
122129
id: QueryJobId,
123130
}
124131

125-
impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
132+
impl<'tcx, Q: QueryDescription<'tcx> + 'tcx> JobOwner<'tcx, Q> {
126133
/// Either gets a `JobOwner` corresponding the query, allowing us to
127134
/// start executing the query, or returns with the result of the query.
128135
/// This function assumes that `try_get_cached` is already called and returned `lookup`.
@@ -470,7 +477,7 @@ impl<'tcx> TyCtxt<'tcx> {
470477
}
471478

472479
#[inline(always)]
473-
pub(super) fn try_execute_query<Q: QueryDescription<'tcx>>(
480+
pub(super) fn try_execute_query<Q: QueryDescription<'tcx> + 'tcx>(
474481
self,
475482
span: Span,
476483
key: Q::Key,
@@ -634,7 +641,7 @@ impl<'tcx> TyCtxt<'tcx> {
634641
}
635642

636643
#[inline(always)]
637-
fn force_query_with_job<Q: QueryDescription<'tcx>>(
644+
fn force_query_with_job<Q: QueryDescription<'tcx> + 'tcx>(
638645
self,
639646
key: Q::Key,
640647
job: JobOwner<'tcx, Q>,

0 commit comments

Comments
 (0)