Skip to content

Commit 5231c10

Browse files
committed
Add cycle_delay_bug to proc macro
1 parent 2002b4b commit 5231c10

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/librustc_macros/src/query.rs

+20
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ enum QueryModifier {
4343
/// A cycle error for this query aborting the compilation with a fatal error.
4444
FatalCycle,
4545

46+
/// A cycle error results in a delay_bug call
47+
CycleDelayBug,
48+
4649
/// Don't hash the result, instead just mark a query red if it runs
4750
NoHash,
4851

@@ -101,6 +104,8 @@ impl Parse for QueryModifier {
101104
Ok(QueryModifier::LoadCached(tcx, id, block))
102105
} else if modifier == "fatal_cycle" {
103106
Ok(QueryModifier::FatalCycle)
107+
} else if modifier == "cycle_delay_bug" {
108+
Ok(QueryModifier::CycleDelayBug)
104109
} else if modifier == "no_hash" {
105110
Ok(QueryModifier::NoHash)
106111
} else if modifier == "no_force" {
@@ -207,6 +212,9 @@ struct QueryModifiers {
207212
/// A cycle error for this query aborting the compilation with a fatal error.
208213
fatal_cycle: bool,
209214

215+
/// A cycle error results in a delay_bug call
216+
cycle_delay_bug: bool,
217+
210218
/// Don't hash the result, instead just mark a query red if it runs
211219
no_hash: bool,
212220

@@ -226,6 +234,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
226234
let mut cache = None;
227235
let mut desc = None;
228236
let mut fatal_cycle = false;
237+
let mut cycle_delay_bug = false;
229238
let mut no_hash = false;
230239
let mut no_force = false;
231240
let mut anon = false;
@@ -256,6 +265,12 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
256265
}
257266
fatal_cycle = true;
258267
}
268+
QueryModifier::CycleDelayBug => {
269+
if cycle_delay_bug {
270+
panic!("duplicate modifier `cycle_delay_bug` for query `{}`", query.name);
271+
}
272+
cycle_delay_bug = true;
273+
}
259274
QueryModifier::NoHash => {
260275
if no_hash {
261276
panic!("duplicate modifier `no_hash` for query `{}`", query.name);
@@ -287,6 +302,7 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
287302
cache,
288303
desc,
289304
fatal_cycle,
305+
cycle_delay_bug,
290306
no_hash,
291307
no_force,
292308
anon,
@@ -397,6 +413,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
397413
if modifiers.fatal_cycle {
398414
attributes.push(quote! { fatal_cycle });
399415
};
416+
// Pass on the cycle_delay_bug modifier
417+
if modifiers.cycle_delay_bug {
418+
attributes.push(quote! { cycle_delay_bug });
419+
};
400420
// Pass on the no_hash modifier
401421
if modifiers.no_hash {
402422
attributes.push(quote! { no_hash });

0 commit comments

Comments
 (0)