@@ -51,6 +51,9 @@ enum QueryModifier {
5151
5252 /// Generate a dep node based on the dependencies of the query
5353 Anon ,
54+
55+ // Always evaluate the query, ignoring its depdendencies
56+ EvalAlways ,
5457}
5558
5659impl Parse for QueryModifier {
@@ -104,6 +107,8 @@ impl Parse for QueryModifier {
104107 Ok ( QueryModifier :: NoForce )
105108 } else if modifier == "anon" {
106109 Ok ( QueryModifier :: Anon )
110+ } else if modifier == "eval_always" {
111+ Ok ( QueryModifier :: EvalAlways )
107112 } else {
108113 Err ( Error :: new ( modifier. span ( ) , "unknown query modifier" ) )
109114 }
@@ -210,6 +215,9 @@ struct QueryModifiers {
210215
211216 /// Generate a dep node based on the dependencies of the query
212217 anon : bool ,
218+
219+ // Always evaluate the query, ignoring its depdendencies
220+ eval_always : bool ,
213221}
214222
215223/// Process query modifiers into a struct, erroring on duplicates
@@ -221,6 +229,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
221229 let mut no_hash = false ;
222230 let mut no_force = false ;
223231 let mut anon = false ;
232+ let mut eval_always = false ;
224233 for modifier in query. modifiers . 0 . drain ( ..) {
225234 match modifier {
226235 QueryModifier :: LoadCached ( tcx, id, block) => {
@@ -265,6 +274,12 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
265274 }
266275 anon = true ;
267276 }
277+ QueryModifier :: EvalAlways => {
278+ if eval_always {
279+ panic ! ( "duplicate modifier `eval_always` for query `{}`" , query. name) ;
280+ }
281+ eval_always = true ;
282+ }
268283 }
269284 }
270285 QueryModifiers {
@@ -275,6 +290,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
275290 no_hash,
276291 no_force,
277292 anon,
293+ eval_always,
278294 }
279295}
280296
@@ -403,6 +419,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
403419 if modifiers. anon {
404420 attributes. push ( quote ! { anon } ) ;
405421 } ;
422+ // Pass on the eval_always modifier
423+ if modifiers. eval_always {
424+ attributes. push ( quote ! { eval_always } ) ;
425+ } ;
406426
407427 let mut attribute_stream = quote ! { } ;
408428 for e in attributes. into_iter ( ) . intersperse ( quote ! { , } ) {
0 commit comments