diff options
| author | Michael Goulet <michael@errs.io> | 2025-07-13 19:20:05 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-07-13 19:22:17 +0000 |
| commit | c2c9aad3f69515019a849e3c5451e7a1482febb0 (patch) | |
| tree | b05852851710b5a25638104d33559816f25f7a79 /compiler/rustc_infer | |
| parent | 56835d7ac14da9f966e1ff39fd9ffd2e29b764d1 (diff) | |
| download | rust-c2c9aad3f69515019a849e3c5451e7a1482febb0.tar.gz rust-c2c9aad3f69515019a849e3c5451e7a1482febb0.zip | |
Make sure that users don't take region obligations in a snapshot
Diffstat (limited to 'compiler/rustc_infer')
| -rw-r--r-- | compiler/rustc_infer/src/infer/outlives/obligations.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_infer/src/infer/snapshot/undo_log.rs | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index f272052aaa5..43504bd77c1 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -166,6 +166,7 @@ impl<'tcx> InferCtxt<'tcx> { /// Trait queries just want to pass back type obligations "as is" pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> { + assert!(!self.in_snapshot(), "cannot take registered region obligations in a snapshot"); std::mem::take(&mut self.inner.borrow_mut().region_obligations) } diff --git a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs index 6193f35f3eb..34e649afedc 100644 --- a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs +++ b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs @@ -1,3 +1,4 @@ +use std::assert_matches::assert_matches; use std::marker::PhantomData; use rustc_data_structures::undo_log::{Rollback, UndoLogs}; @@ -73,7 +74,8 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for InferCtxtInner<'tcx> { } UndoLog::ProjectionCache(undo) => self.projection_cache.reverse(undo), UndoLog::PushTypeOutlivesConstraint => { - self.region_obligations.pop(); + let popped = self.region_obligations.pop(); + assert_matches!(popped, Some(_), "pushed region constraint but could not pop it"); } } } |
