diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/cell.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index beafddc5a10..ea803bd3a1f 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -1101,13 +1101,13 @@ struct BorrowRef<'b> { impl<'b> BorrowRef<'b> { #[inline] fn new(borrow: &'b Cell<BorrowFlag>) -> Option<BorrowRef<'b>> { - let b = borrow.get(); - if is_writing(b) || b == isize::max_value() { + let b = borrow.get().wrapping_add(1); + if !is_reading(b) { // If there's currently a writing borrow, or if incrementing the // refcount would overflow into a writing borrow. None } else { - borrow.set(b + 1); + borrow.set(b); Some(BorrowRef { borrow }) } } |
