about summary refs log tree commit diff
diff options
context:
space:
mode:
authorwoppopo <woppopo@protonmail.com>2021-12-04 21:57:39 +0900
committerwoppopo <woppopo@protonmail.com>2021-12-04 21:57:39 +0900
commit8f68bdc38024c471f925ce8b6572ec41546229e1 (patch)
treeceb4c5ba60722af49d848370bdbf557a8d892169
parent68a698baf6bfc61d85ce6e25122a092c60c7f21a (diff)
downloadrust-8f68bdc38024c471f925ce8b6572ec41546229e1.tar.gz
rust-8f68bdc38024c471f925ce8b6572ec41546229e1.zip
Make `Borrow` and `BorrowMut` impls `const`
-rw-r--r--library/core/src/array/mod.rs6
-rw-r--r--library/core/src/borrow.rs15
2 files changed, 14 insertions, 7 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs
index b27c36baf37..e89659c41ea 100644
--- a/library/core/src/array/mod.rs
+++ b/library/core/src/array/mod.rs
@@ -149,14 +149,16 @@ impl<T, const N: usize> AsMut<[T]> for [T; N] {
 }
 
 #[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
     }
diff --git a/library/core/src/borrow.rs b/library/core/src/borrow.rs
index f28be20aaa1..58eabecf3f0 100644
--- a/library/core/src/borrow.rs
+++ b/library/core/src/borrow.rs
@@ -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 @@ impl<T: ?Sized> Borrow<T> for 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
     }