@@ -48,6 +48,9 @@ enum QueryModifier {
4848
4949 /// Don't force the query
5050 NoForce ,
51+
52+ /// Generate a dep node based on the dependencies of the query
53+ Anon ,
5154}
5255
5356impl Parse for QueryModifier {
@@ -99,6 +102,8 @@ impl Parse for QueryModifier {
99102 Ok ( QueryModifier :: NoHash )
100103 } else if modifier == "no_force" {
101104 Ok ( QueryModifier :: NoForce )
105+ } else if modifier == "anon" {
106+ Ok ( QueryModifier :: Anon )
102107 } else {
103108 Err ( Error :: new ( modifier. span ( ) , "unknown query modifier" ) )
104109 }
@@ -202,6 +207,9 @@ struct QueryModifiers {
202207
203208 /// Don't force the query
204209 no_force : bool ,
210+
211+ /// Generate a dep node based on the dependencies of the query
212+ anon : bool ,
205213}
206214
207215/// Process query modifiers into a struct, erroring on duplicates
@@ -212,6 +220,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
212220 let mut fatal_cycle = false ;
213221 let mut no_hash = false ;
214222 let mut no_force = false ;
223+ let mut anon = false ;
215224 for modifier in query. modifiers . 0 . drain ( ..) {
216225 match modifier {
217226 QueryModifier :: LoadCached ( tcx, id, block) => {
@@ -250,6 +259,12 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
250259 }
251260 no_force = true ;
252261 }
262+ QueryModifier :: Anon => {
263+ if anon {
264+ panic ! ( "duplicate modifier `anon` for query `{}`" , query. name) ;
265+ }
266+ anon = true ;
267+ }
253268 }
254269 }
255270 QueryModifiers {
@@ -259,6 +274,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
259274 fatal_cycle,
260275 no_hash,
261276 no_force,
277+ anon,
262278 }
263279}
264280
@@ -381,9 +397,20 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
381397 [ #attribute_stream] fn #name: #name( #arg) #result,
382398 } ) ;
383399
400+ let mut attributes = Vec :: new ( ) ;
401+
402+ // Pass on the anon modifier
403+ if modifiers. anon {
404+ attributes. push ( quote ! { anon } ) ;
405+ } ;
406+
407+ let mut attribute_stream = quote ! { } ;
408+ for e in attributes. into_iter ( ) . intersperse ( quote ! { , } ) {
409+ attribute_stream. extend ( e) ;
410+ }
384411 // Create a dep node for the query
385412 dep_node_def_stream. extend ( quote ! {
386- [ ] #name( #arg) ,
413+ [ #attribute_stream ] #name( #arg) ,
387414 } ) ;
388415
389416 if modifiers. no_force {
0 commit comments