@@ -76,10 +76,6 @@ macro_rules! erase {
7676 ( $x: tt) => { { } } ;
7777}
7878
79- macro_rules! replace {
80- ( $x: tt with $( $y: tt) * ) => ( $( $y) * )
81- }
82-
8379macro_rules! is_anon_attr {
8480 ( anon) => {
8581 true
@@ -99,19 +95,18 @@ macro_rules! is_eval_always_attr {
9995}
10096
10197macro_rules! contains_anon_attr {
102- ( $( $attr: ident) ,* ) => ( { $( is_anon_attr!( $attr) | ) * false } ) ;
98+ ( $( $attr: ident $ ( ( $ ( $attr_args : tt ) * ) ) * ) ,* ) => ( { $( is_anon_attr!( $attr) | ) * false } ) ;
10399}
104100
105101macro_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 } ) ;
107103}
108104
109105macro_rules! define_dep_nodes {
110106 ( <$tcx: tt>
111107 $(
112- [ $( $attr : ident ) , * ]
108+ [ $( $attrs : tt ) * ]
113109 $variant: ident $( ( $tuple_arg_ty: ty $( , ) ? ) ) *
114- $( { $( $struct_arg_name: ident : $struct_arg_ty: ty) ,* } ) *
115110 , ) *
116111 ) => (
117112 #[ derive( Clone , Copy , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ,
@@ -126,7 +121,7 @@ macro_rules! define_dep_nodes {
126121 match * self {
127122 $(
128123 DepKind :: $variant => {
129- if contains_anon_attr!( $( $attr ) , * ) {
124+ if contains_anon_attr!( $( $attrs ) * ) {
130125 return false ;
131126 }
132127
@@ -136,13 +131,6 @@ macro_rules! define_dep_nodes {
136131 :: CAN_RECONSTRUCT_QUERY_KEY ;
137132 } ) *
138133
139- // struct args
140- $( {
141-
142- return <( $( $struct_arg_ty, ) * ) as DepNodeParams >
143- :: CAN_RECONSTRUCT_QUERY_KEY ;
144- } ) *
145-
146134 true
147135 }
148136 ) *
@@ -152,15 +140,15 @@ macro_rules! define_dep_nodes {
152140 pub fn is_anon( & self ) -> bool {
153141 match * self {
154142 $(
155- DepKind :: $variant => { contains_anon_attr!( $( $attr ) , * ) }
143+ DepKind :: $variant => { contains_anon_attr!( $( $attrs ) * ) }
156144 ) *
157145 }
158146 }
159147
160148 pub fn is_eval_always( & self ) -> bool {
161149 match * self {
162150 $(
163- DepKind :: $variant => { contains_eval_always_attr!( $( $attr ) , * ) }
151+ DepKind :: $variant => { contains_eval_always_attr!( $( $attrs ) * ) }
164152 ) *
165153 }
166154 }
@@ -176,24 +164,50 @@ macro_rules! define_dep_nodes {
176164 return true ;
177165 } ) *
178166
179- // struct args
180- $( {
181- $( erase!( $struct_arg_name) ; ) *
182- return true ;
183- } ) *
184-
185167 false
186168 }
187169 ) *
188170 }
189171 }
190172 }
191173
192- pub enum DepConstructor <$tcx> {
174+ pub struct DepConstructor ;
175+
176+ impl DepConstructor {
193177 $(
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+ ) *
197211 }
198212
199213 #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ,
@@ -204,75 +218,6 @@ macro_rules! define_dep_nodes {
204218 }
205219
206220 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-
276221 /// Construct a DepNode from the given DepKind and DefPathHash. This
277222 /// method will assert that the given DepKind actually requires a
278223 /// single DefId/DefPathHash parameter.
0 commit comments