Auto merge of #33960 - tbu-:pr_ref_clone_overflow, r=Aatch
Prevent the borrow counter from overflowing in `Ref::clone` Fixes #33880.
This commit is contained in:
commit
298730e703
@ -618,7 +618,9 @@ impl<'b> Clone for BorrowRef<'b> {
|
||||
// Since this Ref exists, we know the borrow flag
|
||||
// is not set to WRITING.
|
||||
let borrow = self.borrow.get();
|
||||
debug_assert!(borrow != WRITING && borrow != UNUSED);
|
||||
debug_assert!(borrow != UNUSED);
|
||||
// Prevent the borrow counter from overflowing.
|
||||
assert!(borrow != WRITING);
|
||||
self.borrow.set(borrow + 1);
|
||||
BorrowRef { borrow: self.borrow }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user