@@ -51,6 +51,9 @@ enum QueryModifier {
51
51
52
52
/// Generate a dep node based on the dependencies of the query
53
53
Anon ,
54
+
55
+ // Always evaluate the query, ignoring its depdendencies
56
+ EvalAlways ,
54
57
}
55
58
56
59
impl Parse for QueryModifier {
@@ -104,6 +107,8 @@ impl Parse for QueryModifier {
104
107
Ok ( QueryModifier :: NoForce )
105
108
} else if modifier == "anon" {
106
109
Ok ( QueryModifier :: Anon )
110
+ } else if modifier == "eval_always" {
111
+ Ok ( QueryModifier :: EvalAlways )
107
112
} else {
108
113
Err ( Error :: new ( modifier. span ( ) , "unknown query modifier" ) )
109
114
}
@@ -210,6 +215,9 @@ struct QueryModifiers {
210
215
211
216
/// Generate a dep node based on the dependencies of the query
212
217
anon : bool ,
218
+
219
+ // Always evaluate the query, ignoring its depdendencies
220
+ eval_always : bool ,
213
221
}
214
222
215
223
/// Process query modifiers into a struct, erroring on duplicates
@@ -221,6 +229,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
221
229
let mut no_hash = false ;
222
230
let mut no_force = false ;
223
231
let mut anon = false ;
232
+ let mut eval_always = false ;
224
233
for modifier in query. modifiers . 0 . drain ( ..) {
225
234
match modifier {
226
235
QueryModifier :: LoadCached ( tcx, id, block) => {
@@ -265,6 +274,12 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
265
274
}
266
275
anon = true ;
267
276
}
277
+ QueryModifier :: EvalAlways => {
278
+ if eval_always {
279
+ panic ! ( "duplicate modifier `eval_always` for query `{}`" , query. name) ;
280
+ }
281
+ eval_always = true ;
282
+ }
268
283
}
269
284
}
270
285
QueryModifiers {
@@ -275,6 +290,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
275
290
no_hash,
276
291
no_force,
277
292
anon,
293
+ eval_always,
278
294
}
279
295
}
280
296
@@ -403,6 +419,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
403
419
if modifiers. anon {
404
420
attributes. push ( quote ! { anon } ) ;
405
421
} ;
422
+ // Pass on the eval_always modifier
423
+ if modifiers. eval_always {
424
+ attributes. push ( quote ! { eval_always } ) ;
425
+ } ;
406
426
407
427
let mut attribute_stream = quote ! { } ;
408
428
for e in attributes. into_iter ( ) . intersperse ( quote ! { , } ) {
0 commit comments