@@ -76,10 +76,6 @@ macro_rules! erase {
76
76
( $x: tt) => { { } } ;
77
77
}
78
78
79
- macro_rules! replace {
80
- ( $x: tt with $( $y: tt) * ) => ( $( $y) * )
81
- }
82
-
83
79
macro_rules! is_anon_attr {
84
80
( anon) => {
85
81
true
@@ -99,19 +95,18 @@ macro_rules! is_eval_always_attr {
99
95
}
100
96
101
97
macro_rules! contains_anon_attr {
102
- ( $( $attr: ident) ,* ) => ( { $( is_anon_attr!( $attr) | ) * false } ) ;
98
+ ( $( $attr: ident $ ( ( $ ( $attr_args : tt ) * ) ) * ) ,* ) => ( { $( is_anon_attr!( $attr) | ) * false } ) ;
103
99
}
104
100
105
101
macro_rules! contains_eval_always_attr {
106
- ( $( $attr: ident) ,* ) => ( { $( is_eval_always_attr!( $attr) | ) * false } ) ;
102
+ ( $( $attr: ident $ ( ( $ ( $attr_args : tt ) * ) ) * ) ,* ) => ( { $( is_eval_always_attr!( $attr) | ) * false } ) ;
107
103
}
108
104
109
105
macro_rules! define_dep_nodes {
110
106
( <$tcx: tt>
111
107
$(
112
- [ $( $attr : ident ) , * ]
108
+ [ $( $attrs : tt ) * ]
113
109
$variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
114
- $( { $( $struct_arg_name: ident : $struct_arg_ty: ty) ,* } ) *
115
110
, ) *
116
111
) => (
117
112
#[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ,
@@ -126,7 +121,7 @@ macro_rules! define_dep_nodes {
126
121
match * self {
127
122
$(
128
123
DepKind :: $variant => {
129
- if contains_anon_attr!( $( $attr ) , * ) {
124
+ if contains_anon_attr!( $( $attrs ) * ) {
130
125
return false ;
131
126
}
132
127
@@ -136,13 +131,6 @@ macro_rules! define_dep_nodes {
136
131
:: CAN_RECONSTRUCT_QUERY_KEY ;
137
132
} ) *
138
133
139
- // struct args
140
- $( {
141
-
142
- return <( $( $struct_arg_ty, ) * ) as DepNodeParams >
143
- :: CAN_RECONSTRUCT_QUERY_KEY ;
144
- } ) *
145
-
146
134
true
147
135
}
148
136
) *
@@ -152,15 +140,15 @@ macro_rules! define_dep_nodes {
152
140
pub fn is_anon( & self ) -> bool {
153
141
match * self {
154
142
$(
155
- DepKind :: $variant => { contains_anon_attr!( $( $attr ) , * ) }
143
+ DepKind :: $variant => { contains_anon_attr!( $( $attrs ) * ) }
156
144
) *
157
145
}
158
146
}
159
147
160
148
pub fn is_eval_always( & self ) -> bool {
161
149
match * self {
162
150
$(
163
- DepKind :: $variant => { contains_eval_always_attr!( $( $attr ) , * ) }
151
+ DepKind :: $variant => { contains_eval_always_attr!( $( $attrs ) * ) }
164
152
) *
165
153
}
166
154
}
@@ -176,24 +164,50 @@ macro_rules! define_dep_nodes {
176
164
return true ;
177
165
} ) *
178
166
179
- // struct args
180
- $( {
181
- $( erase!( $struct_arg_name) ; ) *
182
- return true ;
183
- } ) *
184
-
185
167
false
186
168
}
187
169
) *
188
170
}
189
171
}
190
172
}
191
173
192
- pub enum DepConstructor <$tcx> {
174
+ pub struct DepConstructor ;
175
+
176
+ impl DepConstructor {
193
177
$(
194
- $variant $( ( $tuple_arg_ty ) ) *
195
- $( { $( $struct_arg_name : $struct_arg_ty) ,* } ) *
196
- ) ,*
178
+ #[ inline( always) ]
179
+ #[ allow( unreachable_code, non_snake_case) ]
180
+ pub fn $variant<' tcx>( _tcx: TyCtxt <' tcx>, $( arg: $tuple_arg_ty) * ) -> DepNode {
181
+ // tuple args
182
+ $( {
183
+ erase!( $tuple_arg_ty) ;
184
+ let hash = DepNodeParams :: to_fingerprint( & arg, _tcx) ;
185
+ let dep_node = DepNode {
186
+ kind: DepKind :: $variant,
187
+ hash
188
+ } ;
189
+
190
+ #[ cfg( debug_assertions) ]
191
+ {
192
+ if !dep_node. kind. can_reconstruct_query_key( ) &&
193
+ ( _tcx. sess. opts. debugging_opts. incremental_info ||
194
+ _tcx. sess. opts. debugging_opts. query_dep_graph)
195
+ {
196
+ _tcx. dep_graph. register_dep_node_debug_str( dep_node, || {
197
+ arg. to_debug_str( _tcx)
198
+ } ) ;
199
+ }
200
+ }
201
+
202
+ return dep_node;
203
+ } ) *
204
+
205
+ DepNode {
206
+ kind: DepKind :: $variant,
207
+ hash: Fingerprint :: ZERO ,
208
+ }
209
+ }
210
+ ) *
197
211
}
198
212
199
213
#[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ,
@@ -204,75 +218,6 @@ macro_rules! define_dep_nodes {
204
218
}
205
219
206
220
impl DepNode {
207
- #[ allow( unreachable_code, non_snake_case) ]
208
- pub fn new<' tcx>( tcx: TyCtxt <' tcx>,
209
- dep: DepConstructor <' tcx>)
210
- -> DepNode
211
- {
212
- match dep {
213
- $(
214
- DepConstructor :: $variant $( ( replace!( ( $tuple_arg_ty) with arg) ) ) *
215
- $( { $( $struct_arg_name) ,* } ) *
216
- =>
217
- {
218
- // tuple args
219
- $( {
220
- erase!( $tuple_arg_ty) ;
221
- let hash = DepNodeParams :: to_fingerprint( & arg, tcx) ;
222
- let dep_node = DepNode {
223
- kind: DepKind :: $variant,
224
- hash
225
- } ;
226
-
227
- #[ cfg( debug_assertions) ]
228
- {
229
- if !dep_node. kind. can_reconstruct_query_key( ) &&
230
- ( tcx. sess. opts. debugging_opts. incremental_info ||
231
- tcx. sess. opts. debugging_opts. query_dep_graph)
232
- {
233
- tcx. dep_graph. register_dep_node_debug_str( dep_node, || {
234
- arg. to_debug_str( tcx)
235
- } ) ;
236
- }
237
- }
238
-
239
- return dep_node;
240
- } ) *
241
-
242
- // struct args
243
- $( {
244
- let tupled_args = ( $( $struct_arg_name, ) * ) ;
245
- let hash = DepNodeParams :: to_fingerprint( & tupled_args,
246
- tcx) ;
247
- let dep_node = DepNode {
248
- kind: DepKind :: $variant,
249
- hash
250
- } ;
251
-
252
- #[ cfg( debug_assertions) ]
253
- {
254
- if !dep_node. kind. can_reconstruct_query_key( ) &&
255
- ( tcx. sess. opts. debugging_opts. incremental_info ||
256
- tcx. sess. opts. debugging_opts. query_dep_graph)
257
- {
258
- tcx. dep_graph. register_dep_node_debug_str( dep_node, || {
259
- tupled_args. to_debug_str( tcx)
260
- } ) ;
261
- }
262
- }
263
-
264
- return dep_node;
265
- } ) *
266
-
267
- DepNode {
268
- kind: DepKind :: $variant,
269
- hash: Fingerprint :: ZERO ,
270
- }
271
- }
272
- ) *
273
- }
274
- }
275
-
276
221
/// Construct a DepNode from the given DepKind and DefPathHash. This
277
222
/// method will assert that the given DepKind actually requires a
278
223
/// single DefId/DefPathHash parameter.
0 commit comments