@@ -76,6 +76,9 @@ pub use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
76
76
/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
77
77
/// jump table instead of large matches.
78
78
pub struct DepKindStruct {
79
+ /// Whether the DepNode has parameters (query keys).
80
+ pub ( super ) has_params : bool ,
81
+
79
82
/// Anonymous queries cannot be replayed from one compiler invocation to the next.
80
83
/// When their result is needed, it is recomputed. They are useful for fine-grained
81
84
/// dependency tracking, and caching within one compiler invocation.
@@ -132,26 +135,31 @@ pub mod dep_kind {
132
135
use super :: * ;
133
136
134
137
// We use this for most things when incr. comp. is turned off.
135
- pub const Null : DepKindStruct = DepKindStruct { is_anon : false , is_eval_always : false } ;
138
+ pub const Null : DepKindStruct =
139
+ DepKindStruct { has_params : false , is_anon : false , is_eval_always : false } ;
136
140
137
141
// Represents metadata from an extern crate.
138
- pub const CrateMetadata : DepKindStruct = DepKindStruct { is_anon : false , is_eval_always : true } ;
142
+ pub const CrateMetadata : DepKindStruct =
143
+ DepKindStruct { has_params : true , is_anon : false , is_eval_always : true } ;
139
144
140
- pub const TraitSelect : DepKindStruct = DepKindStruct { is_anon : true , is_eval_always : false } ;
145
+ pub const TraitSelect : DepKindStruct =
146
+ DepKindStruct { has_params : false , is_anon : true , is_eval_always : false } ;
141
147
142
148
pub const CompileCodegenUnit : DepKindStruct =
143
- DepKindStruct { is_anon : false , is_eval_always : false } ;
149
+ DepKindStruct { has_params : true , is_anon : false , is_eval_always : false } ;
144
150
145
151
macro_rules! define_query_dep_kinds {
146
152
( $(
147
153
[ $( $attrs: tt) * ]
148
154
$variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
149
155
, ) * ) => (
150
156
$( pub const $variant: DepKindStruct = {
157
+ const has_params: bool = $( { erase!( $tuple_arg_ty) ; true } |) * false ;
151
158
const is_anon: bool = contains_anon_attr!( $( $attrs) * ) ;
152
159
const is_eval_always: bool = contains_eval_always_attr!( $( $attrs) * ) ;
153
160
154
161
DepKindStruct {
162
+ has_params,
155
163
is_anon,
156
164
is_eval_always,
157
165
}
@@ -199,23 +207,6 @@ macro_rules! define_dep_nodes {
199
207
) *
200
208
}
201
209
}
202
-
203
- #[ allow( unreachable_code) ]
204
- pub fn has_params( & self ) -> bool {
205
- match * self {
206
- $(
207
- DepKind :: $variant => {
208
- // tuple args
209
- $( {
210
- erase!( $tuple_arg_ty) ;
211
- return true ;
212
- } ) *
213
-
214
- false
215
- }
216
- ) *
217
- }
218
- }
219
210
}
220
211
221
212
pub struct DepConstructor ;
@@ -308,7 +299,7 @@ impl DepNodeExt for DepNode {
308
299
/// method will assert that the given DepKind actually requires a
309
300
/// single DefId/DefPathHash parameter.
310
301
fn from_def_path_hash ( def_path_hash : DefPathHash , kind : DepKind ) -> DepNode {
311
- debug_assert ! ( kind. can_reconstruct_query_key( ) && kind. has_params( ) ) ;
302
+ debug_assert ! ( kind. can_reconstruct_query_key( ) && kind. has_params) ;
312
303
DepNode { kind, hash : def_path_hash. 0 . into ( ) }
313
304
}
314
305
@@ -341,7 +332,7 @@ impl DepNodeExt for DepNode {
341
332
return Err ( ( ) ) ;
342
333
}
343
334
344
- if kind. has_params ( ) {
335
+ if kind. has_params {
345
336
Ok ( DepNode :: from_def_path_hash ( def_path_hash, kind) )
346
337
} else {
347
338
Ok ( DepNode :: new_no_params ( kind) )
0 commit comments