File tree Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ fn def_cycle_recover(
8181 value : Type ,
8282 _def : Definition ,
8383) -> Type {
84- cycle_recover ( value, cycle. iteration )
84+ cycle_recover ( value, cycle. iteration ( ) )
8585}
8686
8787fn use_cycle_initial ( _db : & dyn Db , _id : salsa:: Id , _use : Use ) -> Type {
@@ -95,7 +95,7 @@ fn use_cycle_recover(
9595 value : Type ,
9696 _use : Use ,
9797) -> Type {
98- cycle_recover ( value, cycle. iteration )
98+ cycle_recover ( value, cycle. iteration ( ) )
9999}
100100
101101fn cycle_recover ( value : Type , count : u32 ) -> Type {
Original file line number Diff line number Diff line change @@ -469,16 +469,34 @@ impl Iterator for CycleHeadIdsIterator<'_> {
469469}
470470
471471/// The context that the cycle recovery function receives when a query cycle occurs.
472- #[ derive( Clone ) ]
473472pub struct Cycle < ' a > {
474473 /// An iterator that outputs the [`Id`]s of the current cycle heads.
475- /// This will always contain the [`Id`] of the query being processed by the current cycle recovery function,
476- /// but its position will depend on the query execution order .
477- pub head_ids : CycleHeadIdsIterator < ' a > ,
474+ /// This always contains the [`Id`] of the current query but it can contain additional cycle head [`Id`]s
475+ /// if this query is nested in an outer cycle or if it has nested cycles .
476+ pub ( crate ) head_ids : CycleHeadIdsIterator < ' a > ,
478477 /// The [`Id`] of the query that the current cycle recovery function is processing.
479- pub id : Id ,
478+ pub ( crate ) id : Id ,
480479 /// The counter of the current fixed point iteration.
481- pub iteration : u32 ,
480+ pub ( crate ) iteration : u32 ,
481+ }
482+
483+ impl Cycle < ' _ > {
484+ /// An iterator that outputs the [`Id`]s of the current cycle heads.
485+ /// This always contains the [`Id`] of the current query but it can contain additional cycle head [`Id`]s
486+ /// if this query is nested in an outer cycle or if it has nested cycles.
487+ pub fn head_ids ( & self ) -> CycleHeadIdsIterator < ' _ > {
488+ self . head_ids . clone ( )
489+ }
490+
491+ /// The [`Id`] of the query that the current cycle recovery function is processing.
492+ pub fn id ( & self ) -> Id {
493+ self . id
494+ }
495+
496+ /// The counter of the current fixed point iteration.
497+ pub fn iteration ( & self ) -> u32 {
498+ self . iteration
499+ }
482500}
483501
484502#[ derive( Debug ) ]
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ fn cycle_recover(
137137 . is_some_and ( |val| val <= MIN_VALUE || val >= MAX_VALUE )
138138 {
139139 Value :: OutOfBounds
140- } else if cycle. iteration > MAX_ITERATIONS {
140+ } else if cycle. iteration ( ) > MAX_ITERATIONS {
141141 Value :: TooManyIterations
142142 } else {
143143 value
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ fn def_cycle_recover(
8585 if & value == last_provisional_value {
8686 value
8787 } else {
88- cycle_recover ( value, cycle. iteration )
88+ cycle_recover ( value, cycle. iteration ( ) )
8989 }
9090}
9191
@@ -103,7 +103,7 @@ fn use_cycle_recover(
103103 if & value == last_provisional_value {
104104 value
105105 } else {
106- cycle_recover ( value, cycle. iteration )
106+ cycle_recover ( value, cycle. iteration ( ) )
107107 }
108108}
109109
You can’t perform that action at this time.
0 commit comments