@@ -30,6 +30,8 @@ pub trait QueryCache: Sized {
3030 fn complete ( & self , key : Self :: Key , value : Self :: Value , index : DepNodeIndex ) ;
3131
3232 fn iter ( & self , f : & mut dyn FnMut ( & Self :: Key , & Self :: Value , DepNodeIndex ) ) ;
33+
34+ fn len ( & self ) -> usize ;
3335}
3436
3537/// In-memory cache for queries whose keys aren't suitable for any of the
7173 }
7274 }
7375 }
76+
77+ fn len ( & self ) -> usize {
78+ self . cache . len ( )
79+ }
7480}
7581
7682/// In-memory cache for queries whose key type only has one value (e.g. `()`).
@@ -107,6 +113,10 @@ where
107113 f ( & ( ) , & value. 0 , value. 1 )
108114 }
109115 }
116+
117+ fn len ( & self ) -> usize {
118+ self . cache . get ( ) . is_some ( ) . into ( )
119+ }
110120}
111121
112122/// In-memory cache for queries whose key is a [`DefId`].
@@ -157,6 +167,10 @@ where
157167 } ) ;
158168 self . foreign . iter ( f) ;
159169 }
170+
171+ fn len ( & self ) -> usize {
172+ self . local . len ( ) + self . foreign . len ( )
173+ }
160174}
161175
162176impl < K , V > QueryCache for VecCache < K , V , DepNodeIndex >
@@ -180,4 +194,8 @@ where
180194 fn iter ( & self , f : & mut dyn FnMut ( & Self :: Key , & Self :: Value , DepNodeIndex ) ) {
181195 self . iter ( f)
182196 }
197+
198+ fn len ( & self ) -> usize {
199+ self . len ( )
200+ }
183201}
0 commit comments