Skip to content

Commit c5c1921

Browse files
committed
wip
1 parent 1c23d5c commit c5c1921

File tree

6 files changed

+165
-135
lines changed

6 files changed

+165
-135
lines changed

src/librustc/ty/query/caches.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::dep_graph::DepNodeIndex;
2-
use crate::ty::query::config::QueryAccessors;
32
use crate::ty::query::plumbing::{QueryLookup, QueryState, QueryStateShard};
43
use crate::ty::TyCtxt;
54

@@ -19,20 +18,20 @@ pub(crate) trait QueryCache<K, V>: Default {
1918
/// It returns the shard index and a lock guard to the shard,
2019
/// which will be used if the query is not in the cache and we need
2120
/// to compute it.
22-
fn lookup<'tcx, R, GetCache, OnHit, OnMiss, Q>(
21+
fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
2322
&self,
24-
state: &'tcx QueryState<'tcx, Q>,
23+
state: &'tcx QueryState<'tcx, K, V, Self>,
2524
get_cache: GetCache,
2625
key: K,
2726
// `on_hit` can be called while holding a lock to the query state shard.
2827
on_hit: OnHit,
2928
on_miss: OnMiss,
3029
) -> R
3130
where
32-
Q: QueryAccessors<'tcx>,
33-
GetCache: for<'a> Fn(&'a mut QueryStateShard<'tcx, Q>) -> &'a mut Self::Sharded,
31+
GetCache:
32+
for<'a> Fn(&'a mut QueryStateShard<'tcx, K, Self::Sharded>) -> &'a mut Self::Sharded,
3433
OnHit: FnOnce(&V, DepNodeIndex) -> R,
35-
OnMiss: FnOnce(K, QueryLookup<'tcx, Q>) -> R;
34+
OnMiss: FnOnce(K, QueryLookup<'tcx, K, Self::Sharded>) -> R;
3635

3736
fn complete(
3837
&self,
@@ -64,19 +63,19 @@ impl<K: Eq + Hash, V: Clone> QueryCache<K, V> for DefaultCache {
6463
type Sharded = FxHashMap<K, (V, DepNodeIndex)>;
6564

6665
#[inline(always)]
67-
fn lookup<'tcx, R, GetCache, OnHit, OnMiss, Q>(
66+
fn lookup<'tcx, R, GetCache, OnHit, OnMiss>(
6867
&self,
69-
state: &'tcx QueryState<'tcx, Q>,
68+
state: &'tcx QueryState<'tcx, K, V, Self>,
7069
get_cache: GetCache,
7170
key: K,
7271
on_hit: OnHit,
7372
on_miss: OnMiss,
7473
) -> R
7574
where
76-
Q: QueryAccessors<'tcx>,
77-
GetCache: for<'a> Fn(&'a mut QueryStateShard<'tcx, Q>) -> &'a mut Self::Sharded,
75+
GetCache:
76+
for<'a> Fn(&'a mut QueryStateShard<'tcx, K, Self::Sharded>) -> &'a mut Self::Sharded,
7877
OnHit: FnOnce(&V, DepNodeIndex) -> R,
79-
OnMiss: FnOnce(K, QueryLookup<'tcx, Q>) -> R,
78+
OnMiss: FnOnce(K, QueryLookup<'tcx, K, Self::Sharded>) -> R,
8079
{
8180
let mut lookup = state.get_lookup(&key);
8281
let lock = &mut *lookup.lock;

src/librustc/ty/query/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::dep_graph::{DepKind, DepNode};
33
use crate::ty::query::caches::QueryCache;
44
use crate::ty::query::plumbing::CycleError;
55
use crate::ty::query::queries;
6-
use crate::ty::query::{Query, QueryState};
6+
use crate::ty::query::{Query, QueryStateAccessor};
77
use crate::ty::TyCtxt;
88
use rustc_data_structures::profiling::ProfileCategory;
99
use rustc_hir::def_id::{CrateNum, DefId};
@@ -26,7 +26,7 @@ pub trait QueryConfig<'tcx> {
2626
type Value: Clone;
2727
}
2828

29-
pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
29+
pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> + Sized {
3030
const ANON: bool;
3131
const EVAL_ALWAYS: bool;
3232

@@ -35,7 +35,7 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
3535
fn query(key: Self::Key) -> Query<'tcx>;
3636

3737
// Don't use this method to access query results, instead use the methods on TyCtxt
38-
fn query_state<'a>(tcx: TyCtxt<'tcx>) -> &'a QueryState<'tcx, Self>;
38+
fn query_state<'a>(tcx: TyCtxt<'tcx>) -> &'a QueryStateAccessor<'tcx, Self>;
3939

4040
fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
4141

src/librustc/ty/query/erase.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
//! Defines the set of legal keys that can be used in queries.
2-
3-
use crate::infer::canonical::Canonical;
1+
//use crate::infer::canonical::Canonical;
42
use crate::mir;
53
use crate::traits;
64
use crate::ty::fast_reject::SimplifiedType;
7-
use crate::ty::query::caches::DefaultCacheSelector;
85
use crate::ty::subst::SubstsRef;
9-
use crate::ty::{self, Ty, TyCtxt};
10-
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE};
6+
use crate::ty::{self};
7+
use rustc_hir::def_id::{CrateNum, DefId, DefIndex};
118
use rustc_span::symbol::Symbol;
12-
use rustc_span::{Span, DUMMY_SP};
139
use std::mem::transmute;
1410

1511
pub(super) trait Erase {
@@ -18,7 +14,7 @@ pub(super) trait Erase {
1814
fn erase(self) -> Self::Erased;
1915
unsafe fn recover(erased: Self::Erased) -> Self;
2016
}
21-
17+
/*
2218
macro_rules! identity_impls {
2319
([$(lifetimes:tt)*] $($ty:ty),*) => {
2420
$(
@@ -38,7 +34,7 @@ macro_rules! identity_impls {
3834
)*
3935
};
4036
}
41-
37+
*/
4238
macro_rules! copy_impls {
4339
(impl $([$($params:tt)*] $ty:ty, $ety:ty),*) => {
4440
$(

0 commit comments

Comments
 (0)