From c4c428b6da234aea4aa639fac73828792d064a07 Mon Sep 17 00:00:00 2001 From: David Weikersdorfer <517608+Danvil@users.noreply.github.com> Date: Sun, 18 Jun 2023 00:46:51 -0700 Subject: [PATCH 1/2] Use BorrowFlag instead of explicit isize The integer type tracking borrow count has a typedef called `BorrowFlag`. This type should be used instead of explicit `isize`. --- library/core/src/cell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index c1cc892eb8607..b1b15e84dbf18 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1756,7 +1756,7 @@ impl<'b> BorrowRefMut<'b> { let borrow = self.borrow.get(); debug_assert!(is_writing(borrow)); // Prevent the borrow counter from underflowing. - assert!(borrow != isize::MIN); + assert!(borrow != BorrowFlag::MIN); self.borrow.set(borrow - 1); BorrowRefMut { borrow: self.borrow } } From 09707ee12a29856453782f7dc41cfef49749e9de Mon Sep 17 00:00:00 2001 From: David Weikersdorfer <517608+Danvil@users.noreply.github.com> Date: Sun, 18 Jun 2023 01:14:45 -0700 Subject: [PATCH 2/2] Same for BorrowRef --- library/core/src/cell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index b1b15e84dbf18..909b32547e74c 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1374,7 +1374,7 @@ impl Clone for BorrowRef<'_> { debug_assert!(is_reading(borrow)); // Prevent the borrow counter from overflowing into // a writing borrow. - assert!(borrow != isize::MAX); + assert!(borrow != BorrowFlag::MAX); self.borrow.set(borrow + 1); BorrowRef { borrow: self.borrow } }