]> git.lizzy.rs Git - rust.git/commitdiff
Make `Borrow` and `BorrowMut` impls `const`
authorwoppopo <woppopo@protonmail.com>
Sat, 4 Dec 2021 12:57:39 +0000 (21:57 +0900)
committerwoppopo <woppopo@protonmail.com>
Sat, 4 Dec 2021 12:57:39 +0000 (21:57 +0900)
library/core/src/array/mod.rs
library/core/src/borrow.rs

index b27c36baf37c5f44f5ee1a3034e65e0a7262b887..e89659c41eae80aa3aa48ec53ffeafdbf8ad9c0a 100644 (file)
@@ -149,14 +149,16 @@ fn as_mut(&mut self) -> &mut [T] {
 }
 
 #[stable(feature = "array_borrow", since = "1.4.0")]
-impl<T, const N: usize> Borrow<[T]> for [T; N] {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T, const N: usize> const Borrow<[T]> for [T; N] {
     fn borrow(&self) -> &[T] {
         self
     }
 }
 
 #[stable(feature = "array_borrow", since = "1.4.0")]
-impl<T, const N: usize> BorrowMut<[T]> for [T; N] {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T, const N: usize> const BorrowMut<[T]> for [T; N] {
     fn borrow_mut(&mut self) -> &mut [T] {
         self
     }
index f28be20aaa1e6309d72be3a403a055a546707c18..58eabecf3f091c4e3c3ddff9ae444e32dbcb734b 100644 (file)
@@ -205,7 +205,8 @@ pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> Borrow<T> for T {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T: ?Sized> const Borrow<T> for T {
     #[rustc_diagnostic_item = "noop_method_borrow"]
     fn borrow(&self) -> &T {
         self
@@ -213,28 +214,32 @@ fn borrow(&self) -> &T {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> BorrowMut<T> for T {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T: ?Sized> const BorrowMut<T> for T {
     fn borrow_mut(&mut self) -> &mut T {
         self
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> Borrow<T> for &T {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T: ?Sized> const Borrow<T> for &T {
     fn borrow(&self) -> &T {
         &**self
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> Borrow<T> for &mut T {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T: ?Sized> const Borrow<T> for &mut T {
     fn borrow(&self) -> &T {
         &**self
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized> BorrowMut<T> for &mut T {
+#[rustc_const_unstable(feature = "const_borrow", issue = "91522")]
+impl<T: ?Sized> const BorrowMut<T> for &mut T {
     fn borrow_mut(&mut self) -> &mut T {
         &mut **self
     }