@@ -314,6 +314,17 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
314
314
let mut query_description_stream = quote ! { } ;
315
315
let mut query_cached_stream = quote ! { } ;
316
316
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
+ }
317
328
318
329
for query in queries. 0 {
319
330
let Query { name, arg, modifiers, .. } = & query;
@@ -369,10 +380,15 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
369
380
[ #attribute_stream] fn #name( #arg) #result,
370
381
} ) ;
371
382
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
+ ) ;
374
389
assert ! (
375
390
modifiers. eval_always. is_none( ) ,
391
+ feedable. span( ) ,
376
392
"Query {name} cannot be both `feedable` and `eval_always`."
377
393
) ;
378
394
feedable_queries. extend ( quote ! {
@@ -407,5 +423,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
407
423
use super :: * ;
408
424
#query_cached_stream
409
425
}
426
+ #errors
410
427
} )
411
428
}
0 commit comments