@@ -10,6 +10,7 @@ use rustc_index::vec::IndexVec;
10
10
use std:: cell:: RefCell ;
11
11
use std:: default:: Default ;
12
12
use std:: hash:: Hash ;
13
+ use std:: marker:: PhantomData ;
13
14
14
15
pub ( crate ) trait CacheSelector < K , V > {
15
16
type Cache : QueryCache < K , V > ;
@@ -57,13 +58,18 @@ pub(crate) trait QueryCache<K, V>: Default {
57
58
pub struct DefaultCacheSelector ;
58
59
59
60
impl < K : Eq + Hash , V : Clone > CacheSelector < K , V > for DefaultCacheSelector {
60
- type Cache = DefaultCache ;
61
+ type Cache = DefaultCache < ( ) > ;
61
62
}
62
63
63
- #[ derive( Default ) ]
64
- pub struct DefaultCache ;
64
+ pub struct DefaultCache < D > ( PhantomData < D > ) ;
65
65
66
- impl < K : Eq + Hash , V : Clone > QueryCache < K , V > for DefaultCache {
66
+ impl < D > Default for DefaultCache < D > {
67
+ fn default ( ) -> Self {
68
+ DefaultCache ( PhantomData )
69
+ }
70
+ }
71
+
72
+ impl < D , K : Eq + Hash , V : Clone > QueryCache < K , V > for DefaultCache < D > {
67
73
type Sharded = FxHashMap < K , ( V , DepNodeIndex ) > ;
68
74
69
75
#[ inline( always) ]
@@ -114,9 +120,14 @@ impl<K: Eq + Hash, V: Clone> QueryCache<K, V> for DefaultCache {
114
120
}
115
121
}
116
122
123
+ #[ cfg( parallel_compiler) ]
124
+ pub type LocalDenseDefIdCacheSelector < V > = DefaultCache < V > ;
125
+ #[ cfg( not( parallel_compiler) ) ]
126
+ pub type LocalDenseDefIdCacheSelector < V > = LocalDenseDefIdCache < V > ;
127
+
117
128
pub struct LocalDenseDefIdCache < V > {
118
129
local : RefCell < IndexVec < DefIndex , Option < ( V , DepNodeIndex ) > > > ,
119
- other : DefaultCache ,
130
+ other : DefaultCache < ( ) > ,
120
131
}
121
132
122
133
impl < V > Default for LocalDenseDefIdCache < V > {
@@ -126,7 +137,7 @@ impl<V> Default for LocalDenseDefIdCache<V> {
126
137
}
127
138
128
139
impl < V : Clone > QueryCache < DefId , V > for LocalDenseDefIdCache < V > {
129
- type Sharded = <DefaultCache as QueryCache < DefId , V > >:: Sharded ;
140
+ type Sharded = <DefaultCache < ( ) > as QueryCache < DefId , V > >:: Sharded ;
130
141
131
142
#[ inline( always) ]
132
143
fn lookup < ' tcx , R , GetCache , OnHit , OnMiss , Q > (
0 commit comments