@@ -910,7 +910,7 @@ impl<T> RefCell<T> {
910910 #[ rustc_confusables( "swap" ) ]
911911 #[ rustc_const_unstable( feature = "const_ref_cell" , issue = "137844" ) ]
912912 pub const fn replace ( & self , t : T ) -> T {
913- mem:: replace ( self . borrow_mut ( ) . as_mut ( ) , t)
913+ mem:: replace ( & mut self . borrow_mut ( ) , t)
914914 }
915915
916916 /// Replaces the wrapped value with a new one computed from `f`, returning
@@ -962,7 +962,7 @@ impl<T> RefCell<T> {
962962 #[ stable( feature = "refcell_swap" , since = "1.24.0" ) ]
963963 #[ rustc_const_unstable( feature = "const_ref_cell" , issue = "137844" ) ]
964964 pub const fn swap ( & self , other : & Self ) {
965- mem:: swap ( self . borrow_mut ( ) . as_mut ( ) , other. borrow_mut ( ) . as_mut ( ) )
965+ mem:: swap ( & mut * self . borrow_mut ( ) , & mut * other. borrow_mut ( ) )
966966 }
967967}
968968
@@ -1452,6 +1452,8 @@ impl<'b> BorrowRef<'b> {
14521452 Some ( BorrowRef { borrow } )
14531453 }
14541454 }
1455+
1456+ /// `Clone` is not a `const_trait`, so work around that by making our own method
14551457 #[ inline]
14561458 #[ rustc_const_unstable( feature = "const_ref_cell" , issue = "137844" ) ]
14571459 const fn clone ( & self ) -> Self {
@@ -1671,12 +1673,6 @@ impl<T: ?Sized + fmt::Display> fmt::Display for Ref<'_, T> {
16711673}
16721674
16731675impl < ' b , T : ?Sized > RefMut < ' b , T > {
1674- #[ inline]
1675- const fn as_mut ( & mut self ) -> & mut T {
1676- // SAFETY: the value is accessible as long as we hold our borrow.
1677- unsafe { self . value . as_mut ( ) }
1678- }
1679-
16801676 /// Makes a new `RefMut` for a component of the borrowed data, e.g., an enum
16811677 /// variant.
16821678 ///
@@ -1897,7 +1893,8 @@ pub struct RefMut<'b, T: ?Sized + 'b> {
18971893}
18981894
18991895#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1900- impl < T : ?Sized > Deref for RefMut < ' _ , T > {
1896+ #[ rustc_const_unstable( feature = "const_deref" , issue = "88955" ) ]
1897+ impl < T : ?Sized > const Deref for RefMut < ' _ , T > {
19011898 type Target = T ;
19021899
19031900 #[ inline]
@@ -1908,10 +1905,12 @@ impl<T: ?Sized> Deref for RefMut<'_, T> {
19081905}
19091906
19101907#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1911- impl < T : ?Sized > DerefMut for RefMut < ' _ , T > {
1908+ #[ rustc_const_unstable( feature = "const_deref" , issue = "88955" ) ]
1909+ impl < T : ?Sized > const DerefMut for RefMut < ' _ , T > {
19121910 #[ inline]
19131911 fn deref_mut ( & mut self ) -> & mut T {
1914- self . as_mut ( )
1912+ // SAFETY: the value is accessible as long as we hold our borrow.
1913+ unsafe { self . value . as_mut ( ) }
19151914 }
19161915}
19171916
0 commit comments