@@ -70,6 +70,20 @@ use std::hash::Hash;
70
70
71
71
pub use rustc_query_system:: dep_graph:: { DepContext , DepNodeParams } ;
72
72
73
+ /// This struct stores metadata about each DepKind.
74
+ ///
75
+ /// Information is retrieved by indexing the `DEP_KINDS` array using the integer value
76
+ /// of the `DepKind`. Overall, this allows to implement `DepContext` using this manual
77
+ /// jump table instead of large matches.
78
+ pub struct DepKindStruct { }
79
+
80
+ impl std:: ops:: Deref for DepKind {
81
+ type Target = DepKindStruct ;
82
+ fn deref ( & self ) -> & DepKindStruct {
83
+ & DEP_KINDS [ * self as usize ]
84
+ }
85
+ }
86
+
73
87
// erase!() just makes tokens go away. It's used to specify which macro argument
74
88
// is repeated (i.e., which sub-expression of the macro we are in) but don't need
75
89
// to actually use any of the arguments.
@@ -103,14 +117,46 @@ macro_rules! contains_eval_always_attr {
103
117
( $( $attr: ident $( ( $( $attr_args: tt) * ) ) * ) ,* ) => ( { $( is_eval_always_attr!( $attr) | ) * false } ) ;
104
118
}
105
119
120
+ #[ allow( non_upper_case_globals) ]
121
+ pub mod dep_kind {
122
+ use super :: * ;
123
+
124
+ // We use this for most things when incr. comp. is turned off.
125
+ pub const Null : DepKindStruct = DepKindStruct { } ;
126
+
127
+ // Represents metadata from an extern crate.
128
+ pub const CrateMetadata : DepKindStruct = DepKindStruct { } ;
129
+
130
+ pub const TraitSelect : DepKindStruct = DepKindStruct { } ;
131
+
132
+ pub const CompileCodegenUnit : DepKindStruct = DepKindStruct { } ;
133
+
134
+ macro_rules! define_query_dep_kinds {
135
+ ( $(
136
+ [ $( $attrs: tt) * ]
137
+ $variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
138
+ , ) * ) => (
139
+ $( pub const $variant: DepKindStruct = {
140
+ DepKindStruct {
141
+ }
142
+ } ; ) *
143
+ ) ;
144
+ }
145
+
146
+ rustc_dep_node_append ! ( [ define_query_dep_kinds!] [ ] ) ;
147
+ }
148
+
106
149
macro_rules! define_dep_nodes {
107
150
( <$tcx: tt>
108
151
$(
109
152
[ $( $attrs: tt) * ]
110
153
$variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
111
154
, ) *
112
155
) => (
113
- #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Encodable , Decodable ) ]
156
+ static DEP_KINDS : & [ DepKindStruct ] = & [ $( dep_kind:: $variant) ,* ] ;
157
+
158
+ /// This enum serves as an index into the `DEP_KINDS` array.
159
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , Encodable , Decodable ) ]
114
160
#[ allow( non_camel_case_types) ]
115
161
pub enum DepKind {
116
162
$( $variant) ,*
0 commit comments