about summary refs log tree commit diff
path: root/library/alloc/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/alloc/src')
-rw-r--r--library/alloc/src/borrow.rs15
-rw-r--r--library/alloc/src/collections/mod.rs6
-rw-r--r--library/alloc/src/lib.rs3
3 files changed, 17 insertions, 7 deletions
diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs
index 07f51b7614f..cb32896161e 100644
--- a/library/alloc/src/borrow.rs
+++ b/library/alloc/src/borrow.rs
@@ -17,9 +17,11 @@ use crate::fmt;
 use crate::string::String;
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
+#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
+impl<'a, B: ?Sized> const Borrow<B> for Cow<'a, B>
 where
     B: ToOwned,
+    B::Owned: [const] Borrow<B>,
 {
     fn borrow(&self) -> &B {
         &**self
@@ -326,9 +328,10 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<B: ?Sized + ToOwned> Deref for Cow<'_, B>
+#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
+impl<B: ?Sized + ToOwned> const Deref for Cow<'_, B>
 where
-    B::Owned: Borrow<B>,
+    B::Owned: [const] Borrow<B>,
 {
     type Target = B;
 
@@ -439,7 +442,11 @@ where
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T: ?Sized + ToOwned> AsRef<T> for Cow<'_, T> {
+#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
+impl<T: ?Sized + ToOwned> const AsRef<T> for Cow<'_, T>
+where
+    T::Owned: [const] Borrow<T>,
+{
     fn as_ref(&self) -> &T {
         self
     }
diff --git a/library/alloc/src/collections/mod.rs b/library/alloc/src/collections/mod.rs
index fac4d1a65ab..212d7c8465b 100644
--- a/library/alloc/src/collections/mod.rs
+++ b/library/alloc/src/collections/mod.rs
@@ -128,8 +128,9 @@ pub use realalloc::collections::TryReserveErrorKind;
     reason = "Uncertain how much info should be exposed",
     issue = "48043"
 )]
+#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
 #[cfg(not(test))]
-impl From<TryReserveErrorKind> for TryReserveError {
+impl const From<TryReserveErrorKind> for TryReserveError {
     #[inline]
     fn from(kind: TryReserveErrorKind) -> Self {
         Self { kind }
@@ -137,8 +138,9 @@ impl From<TryReserveErrorKind> for TryReserveError {
 }
 
 #[unstable(feature = "try_reserve_kind", reason = "new API", issue = "48043")]
+#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
 #[cfg(not(test))]
-impl From<LayoutError> for TryReserveErrorKind {
+impl const From<LayoutError> for TryReserveErrorKind {
     /// Always evaluates to [`TryReserveErrorKind::CapacityOverflow`].
     #[inline]
     fn from(_: LayoutError) -> Self {
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index 711092ae8eb..cba1ce40f75 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -107,10 +107,10 @@
 #![feature(char_max_len)]
 #![feature(clone_to_uninit)]
 #![feature(coerce_unsized)]
+#![feature(const_convert)]
 #![feature(const_default)]
 #![feature(const_eval_select)]
 #![feature(const_heap)]
-#![feature(const_trait_impl)]
 #![feature(core_intrinsics)]
 #![feature(deprecated_suggestion)]
 #![feature(deref_pure_trait)]
@@ -168,6 +168,7 @@
 #![feature(allow_internal_unstable)]
 #![feature(cfg_sanitize)]
 #![feature(const_precise_live_drops)]
+#![feature(const_trait_impl)]
 #![feature(coroutine_trait)]
 #![feature(decl_macro)]
 #![feature(dropck_eyepatch)]