Skip to content

Commit 4268918

Browse files
committed
Clarify implementation a bit
1 parent 3e93045 commit 4268918

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/stacked_borrows/stack.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ impl<'tcx> Stack {
105105
}
106106

107107
// Check that the unique_range is a valid index into the borrow stack.
108+
// This asserts that the unique_range's start <= end.
108109
let uniques = &self.borrows[self.unique_range.clone()];
109110

110111
// Check that the start of the unique_range is precise.
@@ -113,7 +114,7 @@ impl<'tcx> Stack {
113114
}
114115
// We cannot assert that the unique range is exact on the upper end.
115116
// When we pop items within the unique range, setting the end of the range precisely
116-
// require doing a linear search of the borrow stack, which is exactly the kind of
117+
// requires doing a linear search of the borrow stack, which is exactly the kind of
117118
// operation that all this caching exists to avoid.
118119
}
119120

@@ -240,8 +241,8 @@ impl<'tcx> Stack {
240241
self.unique_range.end += 1;
241242
}
242243
if new.perm() == Permission::Unique {
243-
// If this is the first Unique, set the range to contain just the new item.
244-
if self.unique_range == (0..0) {
244+
// If this is the only Unique, set the range to contain just the new item.
245+
if self.unique_range.is_empty() {
245246
self.unique_range = new_idx..new_idx + 1;
246247
} else {
247248
// We already have other Unique items, expand the range to include the new item

0 commit comments

Comments
 (0)