@@ -76,6 +76,9 @@ pub use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
7676/// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
7777/// jump table instead of large matches.
7878pub struct DepKindStruct {
79+ /// Whether the DepNode has parameters (query keys).
80+ pub ( super ) has_params : bool ,
81+
7982 /// Anonymous queries cannot be replayed from one compiler invocation to the next.
8083 /// When their result is needed, it is recomputed. They are useful for fine-grained
8184 /// dependency tracking, and caching within one compiler invocation.
@@ -132,26 +135,31 @@ pub mod dep_kind {
132135 use super :: * ;
133136
134137 // 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 } ;
136140
137141 // 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 } ;
139144
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 } ;
141147
142148 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 } ;
144150
145151 macro_rules! define_query_dep_kinds {
146152 ( $(
147153 [ $( $attrs: tt) * ]
148154 $variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
149155 , ) * ) => (
150156 $( pub const $variant: DepKindStruct = {
157+ const has_params: bool = $( { erase!( $tuple_arg_ty) ; true } |) * false ;
151158 const is_anon: bool = contains_anon_attr!( $( $attrs) * ) ;
152159 const is_eval_always: bool = contains_eval_always_attr!( $( $attrs) * ) ;
153160
154161 DepKindStruct {
162+ has_params,
155163 is_anon,
156164 is_eval_always,
157165 }
@@ -199,23 +207,6 @@ macro_rules! define_dep_nodes {
199207 ) *
200208 }
201209 }
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- }
219210 }
220211
221212 pub struct DepConstructor ;
@@ -308,7 +299,7 @@ impl DepNodeExt for DepNode {
308299 /// method will assert that the given DepKind actually requires a
309300 /// single DefId/DefPathHash parameter.
310301 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) ;
312303 DepNode { kind, hash : def_path_hash. 0 . into ( ) }
313304 }
314305
@@ -341,7 +332,7 @@ impl DepNodeExt for DepNode {
341332 return Err ( ( ) ) ;
342333 }
343334
344- if kind. has_params ( ) {
335+ if kind. has_params {
345336 Ok ( DepNode :: from_def_path_hash ( def_path_hash, kind) )
346337 } else {
347338 Ok ( DepNode :: new_no_params ( kind) )
0 commit comments