@@ -719,7 +719,7 @@ impl<T, const N: usize> Cell<[T; N]> {
719719#[ rustc_diagnostic_item = "RefCell" ]
720720#[ stable( feature = "rust1" , since = "1.0.0" ) ]
721721pub struct RefCell < T : ?Sized > {
722- borrow : Cell < BorrowFlag > ,
722+ borrow : Cell < BorrowCounter > ,
723723 // Stores the location of the earliest currently active borrow.
724724 // This gets updated whenever we go from having zero borrows
725725 // to having a single borrow. When a borrow occurs, this gets included
@@ -804,22 +804,22 @@ fn panic_already_mutably_borrowed(err: BorrowError) -> ! {
804804//
805805// `Ref` and `RefMut` are both two words in size, and so there will likely never
806806// be enough `Ref`s or `RefMut`s in existence to overflow half of the `usize`
807- // range. Thus, a `BorrowFlag ` will probably never overflow or underflow.
807+ // range. Thus, a `BorrowCounter ` will probably never overflow or underflow.
808808// However, this is not a guarantee, as a pathological program could repeatedly
809809// create and then mem::forget `Ref`s or `RefMut`s. Thus, all code must
810810// explicitly check for overflow and underflow in order to avoid unsafety, or at
811811// least behave correctly in the event that overflow or underflow happens (e.g.,
812812// see BorrowRef::new).
813- type BorrowFlag = isize ;
814- const UNUSED : BorrowFlag = 0 ;
813+ type BorrowCounter = isize ;
814+ const UNUSED : BorrowCounter = 0 ;
815815
816816#[ inline( always) ]
817- fn is_writing ( x : BorrowFlag ) -> bool {
817+ fn is_writing ( x : BorrowCounter ) -> bool {
818818 x < UNUSED
819819}
820820
821821#[ inline( always) ]
822- fn is_reading ( x : BorrowFlag ) -> bool {
822+ fn is_reading ( x : BorrowCounter ) -> bool {
823823 x > UNUSED
824824}
825825
@@ -1399,12 +1399,12 @@ impl<T> From<T> for RefCell<T> {
13991399impl < T : CoerceUnsized < U > , U > CoerceUnsized < RefCell < U > > for RefCell < T > { }
14001400
14011401struct BorrowRef < ' b > {
1402- borrow : & ' b Cell < BorrowFlag > ,
1402+ borrow : & ' b Cell < BorrowCounter > ,
14031403}
14041404
14051405impl < ' b > BorrowRef < ' b > {
14061406 #[ inline]
1407- fn new ( borrow : & ' b Cell < BorrowFlag > ) -> Option < BorrowRef < ' b > > {
1407+ fn new ( borrow : & ' b Cell < BorrowCounter > ) -> Option < BorrowRef < ' b > > {
14081408 let b = borrow. get ( ) . wrapping_add ( 1 ) ;
14091409 if !is_reading ( b) {
14101410 // Incrementing borrow can result in a non-reading value (<= 0) in these cases:
@@ -1445,7 +1445,7 @@ impl Clone for BorrowRef<'_> {
14451445 debug_assert ! ( is_reading( borrow) ) ;
14461446 // Prevent the borrow counter from overflowing into
14471447 // a writing borrow.
1448- assert ! ( borrow != BorrowFlag :: MAX ) ;
1448+ assert ! ( borrow != BorrowCounter :: MAX ) ;
14491449 self . borrow . set ( borrow + 1 ) ;
14501450 BorrowRef { borrow : self . borrow }
14511451 }
@@ -1793,7 +1793,7 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
17931793}
17941794
17951795struct BorrowRefMut < ' b > {
1796- borrow : & ' b Cell < BorrowFlag > ,
1796+ borrow : & ' b Cell < BorrowCounter > ,
17971797}
17981798
17991799impl Drop for BorrowRefMut < ' _ > {
@@ -1807,7 +1807,7 @@ impl Drop for BorrowRefMut<'_> {
18071807
18081808impl < ' b > BorrowRefMut < ' b > {
18091809 #[ inline]
1810- fn new ( borrow : & ' b Cell < BorrowFlag > ) -> Option < BorrowRefMut < ' b > > {
1810+ fn new ( borrow : & ' b Cell < BorrowCounter > ) -> Option < BorrowRefMut < ' b > > {
18111811 // NOTE: Unlike BorrowRefMut::clone, new is called to create the initial
18121812 // mutable reference, and so there must currently be no existing
18131813 // references. Thus, while clone increments the mutable refcount, here
@@ -1831,7 +1831,7 @@ impl<'b> BorrowRefMut<'b> {
18311831 let borrow = self . borrow . get ( ) ;
18321832 debug_assert ! ( is_writing( borrow) ) ;
18331833 // Prevent the borrow counter from underflowing.
1834- assert ! ( borrow != BorrowFlag :: MIN ) ;
1834+ assert ! ( borrow != BorrowCounter :: MIN ) ;
18351835 self . borrow . set ( borrow - 1 ) ;
18361836 BorrowRefMut { borrow : self . borrow }
18371837 }
0 commit comments