Skip to content

Commit c2c9aad

Browse files
Make sure that users don't take region obligations in a snapshot
1 parent 56835d7 commit c2c9aad

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/rustc_infer/src/infer/outlives/obligations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ impl<'tcx> InferCtxt<'tcx> {
166166

167167
/// Trait queries just want to pass back type obligations "as is"
168168
pub fn take_registered_region_obligations(&self) -> Vec<TypeOutlivesConstraint<'tcx>> {
169+
assert!(!self.in_snapshot(), "cannot take registered region obligations in a snapshot");
169170
std::mem::take(&mut self.inner.borrow_mut().region_obligations)
170171
}
171172

compiler/rustc_infer/src/infer/snapshot/undo_log.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::assert_matches::assert_matches;
12
use std::marker::PhantomData;
23

34
use rustc_data_structures::undo_log::{Rollback, UndoLogs};
@@ -73,7 +74,8 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for InferCtxtInner<'tcx> {
7374
}
7475
UndoLog::ProjectionCache(undo) => self.projection_cache.reverse(undo),
7576
UndoLog::PushTypeOutlivesConstraint => {
76-
self.region_obligations.pop();
77+
let popped = self.region_obligations.pop();
78+
assert_matches!(popped, Some(_), "pushed region constraint but could not pop it");
7779
}
7880
}
7981
}

0 commit comments

Comments
 (0)