Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert 74989 ("Implement Index and IndexMut for arrays") #79416

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::convert::{Infallible, TryFrom};
use crate::fmt;
use crate::hash::{self, Hash};
use crate::marker::Unsize;
use crate::ops::{Index, IndexMut};
use crate::slice::{Iter, IterMut};

mod iter;
Expand Down Expand Up @@ -209,30 +208,6 @@ 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]
where
[T]: Index<I>,
{
type Output = <[T] as Index<I>>::Output;

#[inline]
fn index(&self, index: I) -> &Self::Output {
Index::index(self as &[T], index)
}
}

#[stable(feature = "index_trait_on_arrays", since = "1.50.0")]
impl<T, I, const N: usize> IndexMut<I> for [T; N]
where
[T]: IndexMut<I>,
{
#[inline]
fn index_mut(&mut self, index: I) -> &mut Self::Output {
IndexMut::index_mut(self as &mut [T], index)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, const N: usize> PartialEq<[B; N]> for [A; N]
where
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/const_fn_vec_mutation_79152.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// check-pass

// https://github.com/rust-lang/rust/issues/79152
const fn foo() {
let mut array = [[0; 1]; 1];
array[0][0] = 1;
}

pub fn main() {
foo()
}