Skip to content

Commit ed0efe2

Browse files
committed
Remove an optimistic integrity check we can no longer do
1 parent 7e3241b commit ed0efe2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/stacked_borrows/stack.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ impl Stack {
7575

7676
#[cfg(feature = "stack-cache")]
7777
if let Some(first_removed) = first_removed {
78-
// Base tags are Unique or SharedReadOnly.
79-
// When the base tag is SharedReadOnly, we do nothing. When the base tag is Unique,
80-
// the start of this range is still precise.
78+
// Either end of unique_range may have shifted, all we really know is that we can't
79+
// have introduced a new Unique.
8180
if !self.unique_range.is_empty() {
8281
self.unique_range = 0..self.len();
8382
}
@@ -159,14 +158,11 @@ impl<'tcx> Stack {
159158

160159
// Check that the unique_range is a valid index into the borrow stack.
161160
// This asserts that the unique_range's start <= end.
162-
let uniques = &self.borrows[self.unique_range.clone()];
161+
let _uniques = &self.borrows[self.unique_range.clone()];
163162

164-
// Check that the start of the unique_range is precise.
165-
if let Some(first_unique) = uniques.first() {
166-
assert_eq!(first_unique.perm(), Permission::Unique);
167-
}
168-
// We cannot assert that the unique range is exact on the upper end.
169-
// When we pop items within the unique range, setting the end of the range precisely
163+
// We cannot assert that the unique range is precise.
164+
// Both ends may shift around when `Stack::retain` is called. Additionally,
165+
// when we pop items within the unique range, setting the end of the range precisely
170166
// requires doing a linear search of the borrow stack, which is exactly the kind of
171167
// operation that all this caching exists to avoid.
172168
}

0 commit comments

Comments
 (0)