about summary refs log tree commit diff
path: root/library/core/src/array
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-03-10 12:20:52 +0100
committerGitHub <noreply@github.com>2022-03-10 12:20:52 +0100
commitfe034cb43baf6fe415ca0f530cd72614df447b70 (patch)
treeff5d54ec37074f528859f75490c0755aa617f5b8 /library/core/src/array
parent313a668234ad7b60fc5df280ba37cf9a39130bd6 (diff)
parent4654a910018cf0447db1edb2a46a0cae5f7dff8e (diff)
downloadrust-fe034cb43baf6fe415ca0f530cd72614df447b70.tar.gz
rust-fe034cb43baf6fe415ca0f530cd72614df447b70.zip
Rollup merge of #94657 - fee1-dead:const_slice_index, r=oli-obk
Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`

Several panic functions were rewired (via `const_eval_select`) to simpler implementations that do not require formatting for compile-time usage.

r? ```@oli-obk```
Diffstat (limited to 'library/core/src/array')
-rw-r--r--library/core/src/array/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs
index ee79021ed53..20dfbc6347c 100644
--- a/library/core/src/array/mod.rs
+++ b/library/core/src/array/mod.rs
@@ -276,9 +276,10 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] {
 }
 
 #[stable(feature = "index_trait_on_arrays", since = "1.50.0")]
-impl<T, I, const N: usize> Index<I> for [T; N]
+#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
+impl<T, I, const N: usize> const Index<I> for [T; N]
 where
-    [T]: Index<I>,
+    [T]: ~const Index<I>,
 {
     type Output = <[T] as Index<I>>::Output;
 
@@ -289,9 +290,10 @@ where
 }
 
 #[stable(feature = "index_trait_on_arrays", since = "1.50.0")]
-impl<T, I, const N: usize> IndexMut<I> for [T; N]
+#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
+impl<T, I, const N: usize> const IndexMut<I> for [T; N]
 where
-    [T]: IndexMut<I>,
+    [T]: ~const IndexMut<I>,
 {
     #[inline]
     fn index_mut(&mut self, index: I) -> &mut Self::Output {