@@ -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
@@ -784,22 +784,22 @@ fn panic_already_mutably_borrowed(err: BorrowError) -> ! {
784784//
785785// `Ref` and `RefMut` are both two words in size, and so there will likely never
786786// be enough `Ref`s or `RefMut`s in existence to overflow half of the `usize`
787- // range. Thus, a `BorrowFlag ` will probably never overflow or underflow.
787+ // range. Thus, a `BorrowCounter ` will probably never overflow or underflow.
788788// However, this is not a guarantee, as a pathological program could repeatedly
789789// create and then mem::forget `Ref`s or `RefMut`s. Thus, all code must
790790// explicitly check for overflow and underflow in order to avoid unsafety, or at
791791// least behave correctly in the event that overflow or underflow happens (e.g.,
792792// see BorrowRef::new).
793- type BorrowFlag = isize ;
794- const UNUSED : BorrowFlag = 0 ;
793+ type BorrowCounter = isize ;
794+ const UNUSED : BorrowCounter = 0 ;
795795
796796#[ inline( always) ]
797- fn is_writing ( x : BorrowFlag ) -> bool {
797+ fn is_writing ( x : BorrowCounter ) -> bool {
798798 x < UNUSED
799799}
800800
801801#[ inline( always) ]
802- fn is_reading ( x : BorrowFlag ) -> bool {
802+ fn is_reading ( x : BorrowCounter ) -> bool {
803803 x > UNUSED
804804}
805805
@@ -1379,12 +1379,12 @@ impl<T> From<T> for RefCell<T> {
13791379impl < T : CoerceUnsized < U > , U > CoerceUnsized < RefCell < U > > for RefCell < T > { }
13801380
13811381struct BorrowRef < ' b > {
1382- borrow : & ' b Cell < BorrowFlag > ,
1382+ borrow : & ' b Cell < BorrowCounter > ,
13831383}
13841384
13851385impl < ' b > BorrowRef < ' b > {
13861386 #[ inline]
1387- fn new ( borrow : & ' b Cell < BorrowFlag > ) -> Option < BorrowRef < ' b > > {
1387+ fn new ( borrow : & ' b Cell < BorrowCounter > ) -> Option < BorrowRef < ' b > > {
13881388 let b = borrow. get ( ) . wrapping_add ( 1 ) ;
13891389 if !is_reading ( b) {
13901390 // Incrementing borrow can result in a non-reading value (<= 0) in these cases:
@@ -1425,7 +1425,7 @@ impl Clone for BorrowRef<'_> {
14251425 debug_assert ! ( is_reading( borrow) ) ;
14261426 // Prevent the borrow counter from overflowing into
14271427 // a writing borrow.
1428- assert ! ( borrow != BorrowFlag :: MAX ) ;
1428+ assert ! ( borrow != BorrowCounter :: MAX ) ;
14291429 self . borrow . set ( borrow + 1 ) ;
14301430 BorrowRef { borrow : self . borrow }
14311431 }
@@ -1773,7 +1773,7 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
17731773}
17741774
17751775struct BorrowRefMut < ' b > {
1776- borrow : & ' b Cell < BorrowFlag > ,
1776+ borrow : & ' b Cell < BorrowCounter > ,
17771777}
17781778
17791779impl Drop for BorrowRefMut < ' _ > {
@@ -1787,7 +1787,7 @@ impl Drop for BorrowRefMut<'_> {
17871787
17881788impl < ' b > BorrowRefMut < ' b > {
17891789 #[ inline]
1790- fn new ( borrow : & ' b Cell < BorrowFlag > ) -> Option < BorrowRefMut < ' b > > {
1790+ fn new ( borrow : & ' b Cell < BorrowCounter > ) -> Option < BorrowRefMut < ' b > > {
17911791 // NOTE: Unlike BorrowRefMut::clone, new is called to create the initial
17921792 // mutable reference, and so there must currently be no existing
17931793 // references. Thus, while clone increments the mutable refcount, here
@@ -1811,7 +1811,7 @@ impl<'b> BorrowRefMut<'b> {
18111811 let borrow = self . borrow . get ( ) ;
18121812 debug_assert ! ( is_writing( borrow) ) ;
18131813 // Prevent the borrow counter from underflowing.
1814- assert ! ( borrow != BorrowFlag :: MIN ) ;
1814+ assert ! ( borrow != BorrowCounter :: MIN ) ;
18151815 self . borrow . set ( borrow - 1 ) ;
18161816 BorrowRefMut { borrow : self . borrow }
18171817 }
0 commit comments