Add cycle_delay_bug to proc macro

This commit is contained in:
John Kåre Alsaker 2019-03-29 03:05:19 +01:00
parent fc8581d742
commit 0b170cd540

View file

@ -43,6 +43,9 @@ enum QueryModifier {
/// A cycle error for this query aborting the compilation with a fatal error.
FatalCycle,
/// A cycle error results in a delay_bug call
CycleDelayBug,
/// Don't hash the result, instead just mark a query red if it runs
NoHash,
@ -101,6 +104,8 @@ impl Parse for QueryModifier {
Ok(QueryModifier::LoadCached(tcx, id, block))
} else if modifier == "fatal_cycle" {
Ok(QueryModifier::FatalCycle)
} else if modifier == "cycle_delay_bug" {
Ok(QueryModifier::CycleDelayBug)
} else if modifier == "no_hash" {
Ok(QueryModifier::NoHash)
} else if modifier == "no_force" {
@ -207,6 +212,9 @@ struct QueryModifiers {
/// A cycle error for this query aborting the compilation with a fatal error.
fatal_cycle: bool,
/// A cycle error results in a delay_bug call
cycle_delay_bug: bool,
/// Don't hash the result, instead just mark a query red if it runs
no_hash: bool,
@ -226,6 +234,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
let mut cache = None;
let mut desc = None;
let mut fatal_cycle = false;
let mut cycle_delay_bug = false;
let mut no_hash = false;
let mut no_force = false;
let mut anon = false;
@ -256,6 +265,12 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
}
fatal_cycle = true;
}
QueryModifier::CycleDelayBug => {
if cycle_delay_bug {
panic!("duplicate modifier `cycle_delay_bug` for query `{}`", query.name);
}
cycle_delay_bug = true;
}
QueryModifier::NoHash => {
if no_hash {
panic!("duplicate modifier `no_hash` for query `{}`", query.name);
@ -287,6 +302,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
cache,
desc,
fatal_cycle,
cycle_delay_bug,
no_hash,
no_force,
anon,
@ -397,6 +413,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
if modifiers.fatal_cycle {
attributes.push(quote! { fatal_cycle });
};
// Pass on the cycle_delay_bug modifier
if modifiers.cycle_delay_bug {
attributes.push(quote! { cycle_delay_bug });
};
// Pass on the no_hash modifier
if modifiers.no_hash {
attributes.push(quote! { no_hash });