From 449326aaad21ad6e0d104d506d6d1e197e6b9719 Mon Sep 17 00:00:00 2001 From: onestacked Date: Fri, 23 Sep 2022 17:53:59 +0200 Subject: [PATCH] Added const Default impls for Arrays and Tuples. --- library/core/src/array/mod.rs | 3 ++- library/core/src/tuple.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs index 165b9d24d93..36e89a95fd2 100644 --- a/library/core/src/array/mod.rs +++ b/library/core/src/array/mod.rs @@ -434,7 +434,8 @@ impl SpecArrayClone for T { macro_rules! array_impl_default { {$n:expr, $t:ident $($ts:ident)*} => { #[stable(since = "1.4.0", feature = "array_default")] - impl Default for [T; $n] where T: Default { + #[rustc_const_unstable(feature = "const_default_impls", issue = "87864")] + impl const Default for [T; $n] where T: ~const Default { fn default() -> [T; $n] { [$t::default(), $($ts::default()),*] } diff --git a/library/core/src/tuple.rs b/library/core/src/tuple.rs index aa8a2425bf4..fc91fe468cc 100644 --- a/library/core/src/tuple.rs +++ b/library/core/src/tuple.rs @@ -93,7 +93,8 @@ macro_rules! tuple_impls { maybe_tuple_doc! { $($T)+ @ #[stable(feature = "rust1", since = "1.0.0")] - impl<$($T:Default),+> Default for ($($T,)+) { + #[rustc_const_unstable(feature = "const_default_impls", issue = "87864")] + impl<$($T: ~const Default),+> const Default for ($($T,)+) { #[inline] fn default() -> ($($T,)+) { ($({ let x: $T = Default::default(); x},)+)