@@ -910,7 +910,7 @@ impl<T> RefCell<T> {
910
910
#[ rustc_confusables( "swap" ) ]
911
911
#[ rustc_const_unstable( feature = "const_ref_cell" , issue = "137844" ) ]
912
912
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)
914
914
}
915
915
916
916
/// Replaces the wrapped value with a new one computed from `f`, returning
@@ -962,7 +962,7 @@ impl<T> RefCell<T> {
962
962
#[ stable( feature = "refcell_swap" , since = "1.24.0" ) ]
963
963
#[ rustc_const_unstable( feature = "const_ref_cell" , issue = "137844" ) ]
964
964
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 ( ) )
966
966
}
967
967
}
968
968
@@ -1452,6 +1452,8 @@ impl<'b> BorrowRef<'b> {
1452
1452
Some ( BorrowRef { borrow } )
1453
1453
}
1454
1454
}
1455
+
1456
+ /// `Clone` is not a `const_trait`, so work around that by making our own method
1455
1457
#[ inline]
1456
1458
#[ rustc_const_unstable( feature = "const_ref_cell" , issue = "137844" ) ]
1457
1459
const fn clone ( & self ) -> Self {
@@ -1671,12 +1673,6 @@ impl<T: ?Sized + fmt::Display> fmt::Display for Ref<'_, T> {
1671
1673
}
1672
1674
1673
1675
impl < ' 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
-
1680
1676
/// Makes a new `RefMut` for a component of the borrowed data, e.g., an enum
1681
1677
/// variant.
1682
1678
///
@@ -1897,7 +1893,8 @@ pub struct RefMut<'b, T: ?Sized + 'b> {
1897
1893
}
1898
1894
1899
1895
#[ 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 > {
1901
1898
type Target = T ;
1902
1899
1903
1900
#[ inline]
@@ -1908,10 +1905,12 @@ impl<T: ?Sized> Deref for RefMut<'_, T> {
1908
1905
}
1909
1906
1910
1907
#[ 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 > {
1912
1910
#[ inline]
1913
1911
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 ( ) }
1915
1914
}
1916
1915
}
1917
1916
0 commit comments