Skip to content

Commit 8a2c165

Browse files
authored
Rollup merge of #84094 - tmiasko:remove-fixed-size-array, r=m-ou-se
Remove FixedSizeArray Remove `FixedSizeArray` trait, it has been superseded by const generics. Closes #27778.
2 parents e26c936 + 60780e4 commit 8a2c165

File tree

4 files changed

+1
-57
lines changed

4 files changed

+1
-57
lines changed

library/core/src/array/mod.rs

-36
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::convert::{Infallible, TryFrom};
1212
use crate::fmt;
1313
use crate::hash::{self, Hash};
1414
use crate::iter::TrustedLen;
15-
use crate::marker::Unsize;
1615
use crate::mem::{self, MaybeUninit};
1716
use crate::ops::{Index, IndexMut};
1817
use crate::slice::{Iter, IterMut};
@@ -36,41 +35,6 @@ pub fn from_mut<T>(s: &mut T) -> &mut [T; 1] {
3635
unsafe { &mut *(s as *mut T).cast::<[T; 1]>() }
3736
}
3837

39-
/// Utility trait implemented only on arrays of fixed size
40-
///
41-
/// This trait can be used to implement other traits on fixed-size arrays
42-
/// without causing much metadata bloat.
43-
///
44-
/// The trait is marked unsafe in order to restrict implementors to fixed-size
45-
/// arrays. A user of this trait can assume that implementors have the exact
46-
/// layout in memory of a fixed size array (for example, for unsafe
47-
/// initialization).
48-
///
49-
/// Note that the traits [`AsRef`] and [`AsMut`] provide similar methods for types that
50-
/// may not be fixed-size arrays. Implementors should prefer those traits
51-
/// instead.
52-
#[unstable(feature = "fixed_size_array", issue = "27778")]
53-
pub unsafe trait FixedSizeArray<T> {
54-
/// Converts the array to immutable slice
55-
#[unstable(feature = "fixed_size_array", issue = "27778")]
56-
fn as_slice(&self) -> &[T];
57-
/// Converts the array to mutable slice
58-
#[unstable(feature = "fixed_size_array", issue = "27778")]
59-
fn as_mut_slice(&mut self) -> &mut [T];
60-
}
61-
62-
#[unstable(feature = "fixed_size_array", issue = "27778")]
63-
unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
64-
#[inline]
65-
fn as_slice(&self) -> &[T] {
66-
self
67-
}
68-
#[inline]
69-
fn as_mut_slice(&mut self) -> &mut [T] {
70-
self
71-
}
72-
}
73-
7438
/// The error type returned when a conversion from a slice to an array fails.
7539
#[stable(feature = "try_from", since = "1.34.0")]
7640
#[derive(Debug, Copy, Clone)]

library/core/tests/array.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
use core::array::{self, FixedSizeArray, IntoIter};
1+
use core::array::{self, IntoIter};
22
use core::convert::TryFrom;
33

4-
#[test]
5-
fn fixed_size_array() {
6-
let mut array = [0; 64];
7-
let mut zero_sized = [(); 64];
8-
let mut empty_array = [0; 0];
9-
let mut empty_zero_sized = [(); 0];
10-
11-
assert_eq!(FixedSizeArray::as_slice(&array).len(), 64);
12-
assert_eq!(FixedSizeArray::as_slice(&zero_sized).len(), 64);
13-
assert_eq!(FixedSizeArray::as_slice(&empty_array).len(), 0);
14-
assert_eq!(FixedSizeArray::as_slice(&empty_zero_sized).len(), 0);
15-
16-
assert_eq!(FixedSizeArray::as_mut_slice(&mut array).len(), 64);
17-
assert_eq!(FixedSizeArray::as_mut_slice(&mut zero_sized).len(), 64);
18-
assert_eq!(FixedSizeArray::as_mut_slice(&mut empty_array).len(), 0);
19-
assert_eq!(FixedSizeArray::as_mut_slice(&mut empty_zero_sized).len(), 0);
20-
}
21-
224
#[test]
235
fn array_from_ref() {
246
let value: String = "Hello World!".into();

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![feature(duration_zero)]
2828
#![feature(exact_size_is_empty)]
2929
#![feature(extern_types)]
30-
#![feature(fixed_size_array)]
3130
#![feature(flt2dec)]
3231
#![feature(fmt_internals)]
3332
#![feature(hashmap_internals)]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@
214214
feature(slice_index_methods, coerce_unsized, sgx_platform)
215215
)]
216216
#![deny(rustc::existing_doc_keyword)]
217-
#![cfg_attr(all(test, target_vendor = "fortanix", target_env = "sgx"), feature(fixed_size_array))]
218217
// std is implemented with unstable features, many of which are internal
219218
// compiler details that will never be stable
220219
// NB: the following list is sorted to minimize merge conflicts.

0 commit comments

Comments
 (0)