@@ -314,6 +314,17 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
314314 let mut query_description_stream = quote ! { } ;
315315 let mut query_cached_stream = quote ! { } ;
316316 let mut feedable_queries = quote ! { } ;
317+ let mut errors = quote ! { } ;
318+
319+ macro_rules! assert {
320+ ( $cond: expr, $span: expr, $( $tt: tt ) + ) => {
321+ if !$cond {
322+ errors. extend(
323+ Error :: new( $span, format!( $( $tt) * ) ) . into_compile_error( ) ,
324+ ) ;
325+ }
326+ }
327+ }
317328
318329 for query in queries. 0 {
319330 let Query { name, arg, modifiers, .. } = & query;
@@ -369,10 +380,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
369380 [ #attribute_stream] fn #name( #arg) #result,
370381 } ) ;
371382
372- if modifiers. feedable . is_some ( ) {
373- assert ! ( modifiers. anon. is_none( ) , "Query {name} cannot be both `feedable` and `anon`." ) ;
383+ if let Some ( feedable) = & modifiers. feedable {
384+ assert ! (
385+ modifiers. anon. is_none( ) ,
386+ feedable. span( ) ,
387+ "Query {name} cannot be both `feedable` and `anon`."
388+ ) ;
374389 assert ! (
375390 modifiers. eval_always. is_none( ) ,
391+ feedable. span( ) ,
376392 "Query {name} cannot be both `feedable` and `eval_always`."
377393 ) ;
378394 feedable_queries. extend ( quote ! {
@@ -407,5 +423,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
407423 use super :: * ;
408424 #query_cached_stream
409425 }
426+ #errors
410427 } )
411428}
0 commit comments