Skip to content

Commit 20c5424

Browse files
committed
add comments on allow_provisional and validate_provisional
1 parent 0543ba2 commit 20c5424

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/function/maybe_changed_after.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ where
165165

166166
/// True if the memo's value and `changed_at` time is still valid in this revision.
167167
/// Does only a shallow O(1) check, doesn't walk the dependencies.
168+
///
169+
/// In general, a provisional memo (from cycle iteration) does not verify. Since we don't
170+
/// eagerly finalize all provisional memos in cycle iteration, we have to lazily check here
171+
/// (via `validate_provisional`) whether a may-be-provisional memo should actually be verified
172+
/// final, because its cycle heads are all now final.
173+
///
174+
/// If `allow_provisional` is `true`, don't check provisionality and return whatever memo we
175+
/// find that can be verified in this revision, whether provisional or not. This only occurs at
176+
/// one call-site, in `fetch_cold` when we actually encounter a cycle, and want to check if
177+
/// there is an existing provisional memo we can reuse.
168178
#[inline]
169179
pub(super) fn shallow_verify_memo(
170180
&self,
@@ -213,6 +223,13 @@ where
213223

214224
/// Check if this memo's cycle heads have all been finalized. If so, mark it verified final and
215225
/// return true, if not return false.
226+
///
227+
/// This check is not recursive, so it is not guaranteed that we will validate a provisional
228+
/// memo that transitively should be validated. That is, if provisional memo A has cycle head
229+
/// B, which also has a provisional memo with cycle head C, and C is verified final, we will
230+
/// not validate A if we call `validate_provisional` on it, unless we first call
231+
/// `validate_provisional` on B. Thus, `deep_verify_memo` needs to call `validate_provisional`
232+
/// on maybe-provisional memos _after_ visiting all dependencies.
216233
fn validate_provisional(
217234
&self,
218235
db: &C::DbView,

0 commit comments

Comments
 (0)