From 0b170cd5402069d886210a307adedd2444a0ec21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 29 Mar 2019 03:05:19 +0100 Subject: [PATCH] Add cycle_delay_bug to proc macro --- src/librustc_macros/src/query.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/librustc_macros/src/query.rs b/src/librustc_macros/src/query.rs index bd5be831ff68..194563454b85 100644 --- a/src/librustc_macros/src/query.rs +++ b/src/librustc_macros/src/query.rs @@ -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 });