From 7d4a92d4f8dc03409984695d78893fffdd3ff1f9 Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Sat, 4 Jul 2020 13:30:09 +0300 Subject: [PATCH 1/5] remove LengthAtMost32 on AsRef/Borrow impl for array --- src/libcore/array/mod.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/libcore/array/mod.rs b/src/libcore/array/mod.rs index 549228ffffaa4..bf4c3d8a0570f 100644 --- a/src/libcore/array/mod.rs +++ b/src/libcore/array/mod.rs @@ -92,10 +92,7 @@ impl From for TryFromSliceError { } #[stable(feature = "rust1", since = "1.0.0")] -impl AsRef<[T]> for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl AsRef<[T]> for [T; N] { #[inline] fn as_ref(&self) -> &[T] { &self[..] @@ -103,10 +100,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl AsMut<[T]> for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl AsMut<[T]> for [T; N] { #[inline] fn as_mut(&mut self) -> &mut [T] { &mut self[..] @@ -114,20 +108,14 @@ where } #[stable(feature = "array_borrow", since = "1.4.0")] -impl Borrow<[T]> for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl Borrow<[T]> for [T; N] { fn borrow(&self) -> &[T] { self } } #[stable(feature = "array_borrow", since = "1.4.0")] -impl BorrowMut<[T]> for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl BorrowMut<[T]> for [T; N] { fn borrow_mut(&mut self) -> &mut [T] { self } From eff62069ad602090e8d27b83cffd9e77479ed4be Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Sun, 5 Jul 2020 15:02:01 +0300 Subject: [PATCH 2/5] Remove the usage of the LengthAtMost32 trait --- src/liballoc/boxed.rs | 11 +- src/liballoc/collections/vec_deque.rs | 7 +- src/liballoc/rc.rs | 6 +- src/liballoc/sync.rs | 6 +- src/liballoc/vec.rs | 24 ++- src/libcore/array/iter.rs | 45 ++---- src/libcore/array/mod.rs | 51 ++----- .../alloc-traits-impls-length-33.rs | 40 +++++ .../alloc-traits-no-impls-length-33.rs | 43 ------ .../alloc-traits-no-impls-length-33.stderr | 63 -------- .../alloc-types-impls-length-33.rs | 25 +++ .../alloc-types-no-impls-length-33.rs | 33 ---- .../alloc-types-no-impls-length-33.stderr | 97 ------------ .../core-traits-impls-length-33.rs | 66 ++++++++ .../core-traits-no-impls-length-33.rs | 29 ---- .../core-traits-no-impls-length-33.stderr | 51 ------- .../array-impls/into-iter-impls-length-33.rs | 41 +++++ .../into-iter-no-impls-length-33.rs | 53 ------- .../into-iter-no-impls-length-33.stderr | 143 ------------------ src/test/ui/const-generics/broken-mir-2.rs | 3 +- .../ui/const-generics/broken-mir-2.stderr | 16 +- .../derive-debug-array-wrapper.rs | 4 +- .../derive-debug-array-wrapper.stderr | 16 +- src/test/ui/consts/too_generic_eval_ice.rs | 3 +- .../ui/consts/too_generic_eval_ice.stderr | 20 ++- .../iterators/into-iter-on-arrays-lint.fixed | 12 +- .../ui/iterators/into-iter-on-arrays-lint.rs | 12 +- .../iterators/into-iter-on-arrays-lint.stderr | 12 +- 28 files changed, 251 insertions(+), 681 deletions(-) create mode 100644 src/test/ui/const-generics/array-impls/alloc-traits-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr create mode 100644 src/test/ui/const-generics/array-impls/alloc-types-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr create mode 100644 src/test/ui/const-generics/array-impls/core-traits-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr create mode 100644 src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.rs delete mode 100644 src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.stderr diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 3320ebdf821d0..f225aa18853c7 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -130,7 +130,6 @@ #![stable(feature = "rust1", since = "1.0.0")] use core::any::Any; -use core::array::LengthAtMost32; use core::borrow; use core::cmp::Ordering; use core::convert::{From, TryFrom}; @@ -871,10 +870,7 @@ impl From> for Box<[u8]> { } #[stable(feature = "box_from_array", since = "1.45.0")] -impl From<[T; N]> for Box<[T]> -where - [T; N]: LengthAtMost32, -{ +impl From<[T; N]> for Box<[T]> { /// Converts a `[T; N]` into a `Box<[T]>` /// /// This conversion moves the array to newly heap-allocated memory. @@ -890,10 +886,7 @@ where } #[stable(feature = "boxed_slice_try_from", since = "1.43.0")] -impl TryFrom> for Box<[T; N]> -where - [T; N]: LengthAtMost32, -{ +impl TryFrom> for Box<[T; N]> { type Error = Box<[T]>; fn try_from(boxed_slice: Box<[T]>) -> Result { diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 15f3a94ca2d6a..ba455b1e5b7a7 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -9,7 +9,6 @@ // ignore-tidy-filelength -use core::array::LengthAtMost32; use core::cmp::{self, Ordering}; use core::fmt; use core::hash::{Hash, Hasher}; @@ -2799,9 +2798,9 @@ macro_rules! __impl_slice_eq1 { __impl_slice_eq1! { [] VecDeque, Vec, } __impl_slice_eq1! { [] VecDeque, &[B], } __impl_slice_eq1! { [] VecDeque, &mut [B], } -__impl_slice_eq1! { [const N: usize] VecDeque, [B; N], [B; N]: LengthAtMost32 } -__impl_slice_eq1! { [const N: usize] VecDeque, &[B; N], [B; N]: LengthAtMost32 } -__impl_slice_eq1! { [const N: usize] VecDeque, &mut [B; N], [B; N]: LengthAtMost32 } +__impl_slice_eq1! { [const N: usize] VecDeque, [B; N], } +__impl_slice_eq1! { [const N: usize] VecDeque, &[B; N], } +__impl_slice_eq1! { [const N: usize] VecDeque, &mut [B; N], } #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for VecDeque { diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 4d50ae9efca95..fd25e6935af6f 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -235,7 +235,6 @@ use crate::boxed::Box; use std::boxed::Box; use core::any::Any; -use core::array::LengthAtMost32; use core::borrow; use core::cell::Cell; use core::cmp::Ordering; @@ -1522,10 +1521,7 @@ where } #[stable(feature = "boxed_slice_try_from", since = "1.43.0")] -impl TryFrom> for Rc<[T; N]> -where - [T; N]: LengthAtMost32, -{ +impl TryFrom> for Rc<[T; N]> { type Error = Rc<[T]>; fn try_from(boxed_slice: Rc<[T]>) -> Result { diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 826f0c8fa833f..9a0daa2016073 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -7,7 +7,6 @@ //! [arc]: struct.Arc.html use core::any::Any; -use core::array::LengthAtMost32; use core::borrow; use core::cmp::Ordering; use core::convert::{From, TryFrom}; @@ -2159,10 +2158,7 @@ where } #[stable(feature = "boxed_slice_try_from", since = "1.43.0")] -impl TryFrom> for Arc<[T; N]> -where - [T; N]: LengthAtMost32, -{ +impl TryFrom> for Arc<[T; N]> { type Error = Arc<[T]>; fn try_from(boxed_slice: Arc<[T]>) -> Result { diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 5db96a504a6a6..3f05719ba9adb 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -59,7 +59,6 @@ #![stable(feature = "rust1", since = "1.0.0")] -use core::array::LengthAtMost32; use core::cmp::{self, Ordering}; use core::fmt; use core::hash::{Hash, Hasher}; @@ -2379,18 +2378,18 @@ __impl_slice_eq1! { [] &mut [A], Vec, #[stable(feature = "partialeq_vec_for_r __impl_slice_eq1! { [] Cow<'_, [A]>, Vec where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] } __impl_slice_eq1! { [] Cow<'_, [A]>, &[B] where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] } __impl_slice_eq1! { [] Cow<'_, [A]>, &mut [B] where A: Clone, #[stable(feature = "rust1", since = "1.0.0")] } -__impl_slice_eq1! { [const N: usize] Vec, [B; N] where [B; N]: LengthAtMost32, #[stable(feature = "rust1", since = "1.0.0")] } -__impl_slice_eq1! { [const N: usize] Vec, &[B; N] where [B; N]: LengthAtMost32, #[stable(feature = "rust1", since = "1.0.0")] } +__impl_slice_eq1! { [const N: usize] Vec, [B; N], #[stable(feature = "rust1", since = "1.0.0")] } +__impl_slice_eq1! { [const N: usize] Vec, &[B; N], #[stable(feature = "rust1", since = "1.0.0")] } // NOTE: some less important impls are omitted to reduce code bloat // FIXME(Centril): Reconsider this? -//__impl_slice_eq1! { [const N: usize] Vec, &mut [B; N], [B; N]: LengthAtMost32 } -//__impl_slice_eq1! { [const N: usize] [A; N], Vec, [A; N]: LengthAtMost32 } -//__impl_slice_eq1! { [const N: usize] &[A; N], Vec, [A; N]: LengthAtMost32 } -//__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec, [A; N]: LengthAtMost32 } -//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], [B; N]: LengthAtMost32 } -//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], [B; N]: LengthAtMost32 } -//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], [B; N]: LengthAtMost32 } +//__impl_slice_eq1! { [const N: usize] Vec, &mut [B; N], } +//__impl_slice_eq1! { [const N: usize] [A; N], Vec, } +//__impl_slice_eq1! { [const N: usize] &[A; N], Vec, } +//__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec, } +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, [B; N], } +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], } +//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], } /// Implements comparison of vectors, lexicographically. #[stable(feature = "rust1", since = "1.0.0")] @@ -2494,10 +2493,7 @@ impl From<&mut [T]> for Vec { } #[stable(feature = "vec_from_array", since = "1.44.0")] -impl From<[T; N]> for Vec -where - [T; N]: LengthAtMost32, -{ +impl From<[T; N]> for Vec { #[cfg(not(test))] fn from(s: [T; N]) -> Vec { <[T]>::into_vec(box s) diff --git a/src/libcore/array/iter.rs b/src/libcore/array/iter.rs index f6b8d4ba08146..174f7e26efbac 100644 --- a/src/libcore/array/iter.rs +++ b/src/libcore/array/iter.rs @@ -1,6 +1,5 @@ //! Defines the `IntoIter` owned iterator for arrays. -use super::LengthAtMost32; use crate::{ fmt, iter::{ExactSizeIterator, FusedIterator, TrustedLen}, @@ -13,10 +12,7 @@ use crate::{ /// /// [array]: ../../std/primitive.array.html #[unstable(feature = "array_value_iter", issue = "65798")] -pub struct IntoIter -where - [T; N]: LengthAtMost32, -{ +pub struct IntoIter { /// This is the array we are iterating over. /// /// Elements with index `i` where `alive.start <= i < alive.end` have not @@ -39,10 +35,7 @@ where alive: Range, } -impl IntoIter -where - [T; N]: LengthAtMost32, -{ +impl IntoIter { /// Creates a new iterator over the given `array`. /// /// *Note*: this method might never get stabilized and/or removed in the @@ -99,10 +92,7 @@ where } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl Iterator for IntoIter -where - [T; N]: LengthAtMost32, -{ +impl Iterator for IntoIter { type Item = T; fn next(&mut self) -> Option { if self.alive.start == self.alive.end { @@ -146,10 +136,7 @@ where } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl DoubleEndedIterator for IntoIter -where - [T; N]: LengthAtMost32, -{ +impl DoubleEndedIterator for IntoIter { fn next_back(&mut self) -> Option { if self.alive.start == self.alive.end { return None; @@ -182,10 +169,7 @@ where } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl Drop for IntoIter -where - [T; N]: LengthAtMost32, -{ +impl Drop for IntoIter { fn drop(&mut self) { // SAFETY: This is safe: `as_mut_slice` returns exactly the sub-slice // of elements that have not been moved out yet and that remain @@ -195,10 +179,7 @@ where } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl ExactSizeIterator for IntoIter -where - [T; N]: LengthAtMost32, -{ +impl ExactSizeIterator for IntoIter { fn len(&self) -> usize { // Will never underflow due to the invariant `alive.start <= // alive.end`. @@ -210,20 +191,17 @@ where } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl FusedIterator for IntoIter where [T; N]: LengthAtMost32 {} +impl FusedIterator for IntoIter {} // The iterator indeed reports the correct length. The number of "alive" // elements (that will still be yielded) is the length of the range `alive`. // This range is decremented in length in either `next` or `next_back`. It is // always decremented by 1 in those methods, but only if `Some(_)` is returned. #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -unsafe impl TrustedLen for IntoIter where [T; N]: LengthAtMost32 {} +unsafe impl TrustedLen for IntoIter {} #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl Clone for IntoIter -where - [T; N]: LengthAtMost32, -{ +impl Clone for IntoIter { fn clone(&self) -> Self { // SAFETY: each point of unsafety is documented inside the unsafe block unsafe { @@ -249,10 +227,7 @@ where } #[stable(feature = "array_value_iter_impls", since = "1.40.0")] -impl fmt::Debug for IntoIter -where - [T; N]: LengthAtMost32, -{ +impl fmt::Debug for IntoIter { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Only print the elements that were not yielded yet: we cannot // access the yielded elements anymore. diff --git a/src/libcore/array/mod.rs b/src/libcore/array/mod.rs index bf4c3d8a0570f..c5e7f65948564 100644 --- a/src/libcore/array/mod.rs +++ b/src/libcore/array/mod.rs @@ -125,7 +125,6 @@ impl BorrowMut<[T]> for [T; N] { impl TryFrom<&[T]> for [T; N] where T: Copy, - [T; N]: LengthAtMost32, { type Error = TryFromSliceError; @@ -135,10 +134,7 @@ where } #[stable(feature = "try_from", since = "1.34.0")] -impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] -where - [T; N]: LengthAtMost32, -{ +impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] { type Error = TryFromSliceError; fn try_from(slice: &[T]) -> Result<&[T; N], TryFromSliceError> { @@ -153,10 +149,7 @@ where } #[stable(feature = "try_from", since = "1.34.0")] -impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] -where - [T; N]: LengthAtMost32, -{ +impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] { type Error = TryFromSliceError; fn try_from(slice: &mut [T]) -> Result<&mut [T; N], TryFromSliceError> { @@ -171,30 +164,21 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl Hash for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl Hash for [T; N] { fn hash(&self, state: &mut H) { Hash::hash(&self[..], state) } } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Debug for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl fmt::Debug for [T; N] { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&&self[..], f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, const N: usize> IntoIterator for &'a [T; N] -where - [T; N]: LengthAtMost32, -{ +impl<'a, T, const N: usize> IntoIterator for &'a [T; N] { type Item = &'a T; type IntoIter = Iter<'a, T>; @@ -204,10 +188,7 @@ where } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] -where - [T; N]: LengthAtMost32, -{ +impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] { type Item = &'a mut T; type IntoIter = IterMut<'a, T>; @@ -220,8 +201,6 @@ where impl PartialEq<[B; N]> for [A; N] where A: PartialEq, - [A; N]: LengthAtMost32, - [B; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &[B; N]) -> bool { @@ -237,7 +216,6 @@ where impl PartialEq<[B]> for [A; N] where A: PartialEq, - [A; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &[B]) -> bool { @@ -253,7 +231,6 @@ where impl PartialEq<[A; N]> for [B] where B: PartialEq, - [A; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &[A; N]) -> bool { @@ -269,7 +246,6 @@ where impl<'b, A, B, const N: usize> PartialEq<&'b [B]> for [A; N] where A: PartialEq, - [A; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &&'b [B]) -> bool { @@ -285,7 +261,6 @@ where impl<'b, A, B, const N: usize> PartialEq<[A; N]> for &'b [B] where B: PartialEq, - [A; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &[A; N]) -> bool { @@ -301,7 +276,6 @@ where impl<'b, A, B, const N: usize> PartialEq<&'b mut [B]> for [A; N] where A: PartialEq, - [A; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &&'b mut [B]) -> bool { @@ -317,7 +291,6 @@ where impl<'b, A, B, const N: usize> PartialEq<[A; N]> for &'b mut [B] where B: PartialEq, - [A; N]: LengthAtMost32, { #[inline] fn eq(&self, other: &[A; N]) -> bool { @@ -334,13 +307,10 @@ where // __impl_slice_eq2! { [A; $N], &'b mut [B; $N] } #[stable(feature = "rust1", since = "1.0.0")] -impl Eq for [T; N] where [T; N]: LengthAtMost32 {} +impl Eq for [T; N] {} #[stable(feature = "rust1", since = "1.0.0")] -impl PartialOrd for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl PartialOrd for [T; N] { #[inline] fn partial_cmp(&self, other: &[T; N]) -> Option { PartialOrd::partial_cmp(&&self[..], &&other[..]) @@ -365,10 +335,7 @@ where /// Implements comparison of arrays lexicographically. #[stable(feature = "rust1", since = "1.0.0")] -impl Ord for [T; N] -where - [T; N]: LengthAtMost32, -{ +impl Ord for [T; N] { #[inline] fn cmp(&self, other: &[T; N]) -> Ordering { Ord::cmp(&&self[..], &&other[..]) diff --git a/src/test/ui/const-generics/array-impls/alloc-traits-impls-length-33.rs b/src/test/ui/const-generics/array-impls/alloc-traits-impls-length-33.rs new file mode 100644 index 0000000000000..35df3278a6e31 --- /dev/null +++ b/src/test/ui/const-generics/array-impls/alloc-traits-impls-length-33.rs @@ -0,0 +1,40 @@ +// check-pass + +pub fn yes_vec_partial_eq_array() -> impl PartialEq<[B; 33]> +where + A: PartialEq, +{ + Vec::::new() +} + +pub fn yes_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]> +where + A: PartialEq, +{ + Vec::::new() +} + +use std::collections::VecDeque; + +pub fn yes_vecdeque_partial_eq_array() -> impl PartialEq<[B; 33]> +where + A: PartialEq, +{ + VecDeque::::new() +} + +pub fn yes_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]> +where + A: PartialEq, +{ + VecDeque::::new() +} + +pub fn yes_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]> +where + A: PartialEq, +{ + VecDeque::::new() +} + +fn main() {} diff --git a/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs b/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs deleted file mode 100644 index 19107e6bf16d5..0000000000000 --- a/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs +++ /dev/null @@ -1,43 +0,0 @@ -pub fn no_vec_partial_eq_array() -> impl PartialEq<[B; 33]> -//~^ ERROR arrays only have std trait implementations for lengths 0..=32 -where - A: PartialEq, -{ - Vec::::new() -} - -pub fn no_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]> -//~^ ERROR arrays only have std trait implementations for lengths 0..=32 -where - A: PartialEq, -{ - Vec::::new() -} - -use std::collections::VecDeque; - -pub fn no_vecdeque_partial_eq_array() -> impl PartialEq<[B; 33]> -//~^ ERROR arrays only have std trait implementations for lengths 0..=32 -where - A: PartialEq, -{ - VecDeque::::new() -} - -pub fn no_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]> -//~^ ERROR arrays only have std trait implementations for lengths 0..=32 -where - A: PartialEq, -{ - VecDeque::::new() -} - -pub fn no_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]> -//~^ ERROR arrays only have std trait implementations for lengths 0..=32 -where - A: PartialEq, -{ - VecDeque::::new() -} - -fn main() {} diff --git a/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr deleted file mode 100644 index 6e5afcdb8bb68..0000000000000 --- a/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr +++ /dev/null @@ -1,63 +0,0 @@ -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-traits-no-impls-length-33.rs:1:43 - | -LL | pub fn no_vec_partial_eq_array() -> impl PartialEq<[B; 33]> - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]` -... -LL | Vec::::new() - | --------------- this returned value is of type `std::vec::Vec` - | - = note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::vec::Vec` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-traits-no-impls-length-33.rs:9:51 - | -LL | pub fn no_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]` -... -LL | Vec::::new() - | --------------- this returned value is of type `std::vec::Vec` - | - = note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::vec::Vec` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-traits-no-impls-length-33.rs:19:48 - | -LL | pub fn no_vecdeque_partial_eq_array() -> impl PartialEq<[B; 33]> - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]` -... -LL | VecDeque::::new() - | -------------------- this returned value is of type `std::collections::VecDeque` - | - = note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::collections::VecDeque` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-traits-no-impls-length-33.rs:27:56 - | -LL | pub fn no_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]` -... -LL | VecDeque::::new() - | -------------------- this returned value is of type `std::collections::VecDeque` - | - = note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::collections::VecDeque` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-traits-no-impls-length-33.rs:35:60 - | -LL | pub fn no_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]> - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]` -... -LL | VecDeque::::new() - | -------------------- this returned value is of type `std::collections::VecDeque` - | - = note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a mut [B; 33]>` for `std::collections::VecDeque` - = note: the return type of a function must have a statically known size - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/array-impls/alloc-types-impls-length-33.rs b/src/test/ui/const-generics/array-impls/alloc-types-impls-length-33.rs new file mode 100644 index 0000000000000..294b405e0edfc --- /dev/null +++ b/src/test/ui/const-generics/array-impls/alloc-types-impls-length-33.rs @@ -0,0 +1,25 @@ +// check-pass + +use std::{convert::TryFrom, rc::Rc, sync::Arc}; + +pub fn yes_vec() { + let v: Vec<_> = [0; 33].into(); +} + +pub fn yes_box() { + let boxed_slice = Box::new([0; 33]) as Box<[i32]>; + let boxed_array = >::try_from(boxed_slice); + let boxed_slice = >::from([0; 33]); +} + +pub fn yes_rc() { + let boxed_slice = Rc::new([0; 33]) as Rc<[i32]>; + let boxed_array = >::try_from(boxed_slice); +} + +pub fn yes_arc() { + let boxed_slice = Arc::new([0; 33]) as Arc<[i32]>; + let boxed_array = >::try_from(boxed_slice); +} + +fn main() {} diff --git a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs deleted file mode 100644 index 48cf21d489ada..0000000000000 --- a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs +++ /dev/null @@ -1,33 +0,0 @@ -// ignore-tidy-linelength - -use std::{convert::TryFrom, rc::Rc, sync::Arc}; - -pub fn no_vec() { - let v: Vec<_> = [0; 33].into(); - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_box() { - let boxed_slice = Box::new([0; 33]) as Box<[i32]>; - let boxed_array = >::try_from(boxed_slice); - //~^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From>` is not satisfied - //~^^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom>` is not satisfied - let boxed_slice = >::from([0; 33]); - //~^ 15:42: 15:49: arrays only have std trait implementations for lengths 0..=32 [E0277] -} - -pub fn no_rc() { - let boxed_slice = Rc::new([0; 33]) as Rc<[i32]>; - let boxed_array = >::try_from(boxed_slice); - //~^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From>` is not satisfied - //~^^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom>` is not satisfied -} - -pub fn no_arc() { - let boxed_slice = Arc::new([0; 33]) as Arc<[i32]>; - let boxed_array = >::try_from(boxed_slice); - //~^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From>` is not satisfied - //~^^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom>` is not satisfied -} - -fn main() {} diff --git a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr deleted file mode 100644 index 5c01603ab881c..0000000000000 --- a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr +++ /dev/null @@ -1,97 +0,0 @@ -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-types-no-impls-length-33.rs:6:29 - | -LL | let v: Vec<_> = [0; 33].into(); - | ^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[{integer}; 33]` - | - = note: required because of the requirements on the impl of `std::convert::From<[{integer}; 33]>` for `std::vec::Vec<{integer}>` - = note: required because of the requirements on the impl of `std::convert::Into>` for `[{integer}; 33]` - -error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From>` is not satisfied - --> $DIR/alloc-types-no-impls-length-33.rs:12:23 - | -LL | let boxed_array = >::try_from(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From>` is not implemented for `std::boxed::Box<[i32; 33]>` - | - = help: the following implementations were found: - as std::convert::From> - as std::convert::From<&str>> - as std::convert::From>> - as std::convert::From> - and 22 others - = note: required because of the requirements on the impl of `std::convert::Into>` for `std::boxed::Box<[i32]>` - = note: required because of the requirements on the impl of `std::convert::TryFrom>` for `std::boxed::Box<[i32; 33]>` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/alloc-types-no-impls-length-33.rs:15:42 - | -LL | let boxed_slice = >::from([0; 33]); - | ^^^^^^^ - | | - | expected an implementor of trait `std::convert::From<[{integer}; 33]>` - | help: consider borrowing here: `&[0; 33]` - | - = note: the trait bound `[i32; 33]: std::convert::From<[{integer}; 33]>` is not satisfied - = note: required because of the requirements on the impl of `std::convert::From<[i32; 33]>` for `std::boxed::Box<[i32]>` - = note: required by `std::convert::From::from` - -error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom>` is not satisfied - --> $DIR/alloc-types-no-impls-length-33.rs:12:23 - | -LL | let boxed_array = >::try_from(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::boxed::Box<[i32; 33]>` - | - = help: the following implementations were found: - as std::convert::TryFrom>> - -error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From>` is not satisfied - --> $DIR/alloc-types-no-impls-length-33.rs:21:23 - | -LL | let boxed_array = >::try_from(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From>` is not implemented for `std::rc::Rc<[i32; 33]>` - | - = help: the following implementations were found: - as std::convert::From>> - as std::convert::From> - as std::convert::From>> - as std::convert::From<&[T]>> - and 9 others - = note: required because of the requirements on the impl of `std::convert::Into>` for `std::rc::Rc<[i32]>` - = note: required because of the requirements on the impl of `std::convert::TryFrom>` for `std::rc::Rc<[i32; 33]>` - -error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom>` is not satisfied - --> $DIR/alloc-types-no-impls-length-33.rs:21:23 - | -LL | let boxed_array = >::try_from(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::rc::Rc<[i32; 33]>` - | - = help: the following implementations were found: - as std::convert::TryFrom>> - -error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From>` is not satisfied - --> $DIR/alloc-types-no-impls-length-33.rs:28:23 - | -LL | let boxed_array = >::try_from(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From>` is not implemented for `std::sync::Arc<[i32; 33]>` - | - = help: the following implementations were found: - as std::convert::From>> - as std::convert::From> - as std::convert::From>> - as std::convert::From<&[T]>> - and 9 others - = note: required because of the requirements on the impl of `std::convert::Into>` for `std::sync::Arc<[i32]>` - = note: required because of the requirements on the impl of `std::convert::TryFrom>` for `std::sync::Arc<[i32; 33]>` - -error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom>` is not satisfied - --> $DIR/alloc-types-no-impls-length-33.rs:28:23 - | -LL | let boxed_array = >::try_from(boxed_slice); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::sync::Arc<[i32; 33]>` - | - = help: the following implementations were found: - as std::convert::TryFrom>> - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/array-impls/core-traits-impls-length-33.rs b/src/test/ui/const-generics/array-impls/core-traits-impls-length-33.rs new file mode 100644 index 0000000000000..c609a7c6f9239 --- /dev/null +++ b/src/test/ui/const-generics/array-impls/core-traits-impls-length-33.rs @@ -0,0 +1,66 @@ +// check-pass + +pub fn yes_as_ref() -> impl AsRef<[u8]> { + [0; 33] +} + +pub fn yes_as_mut() -> impl AsMut<[u8]> { + [0; 33] +} + +pub fn yes_borrow() -> impl std::borrow::Borrow<[u8]> { + [0; 33] +} + +pub fn yes_borrow_mut() -> impl std::borrow::BorrowMut<[u8]> { + [0; 33] +} + +pub fn yes_try_from_slice() -> impl std::convert::TryFrom<&'static [u8]> { + [0; 33] +} + +pub fn yes_ref_try_from_slice() -> impl std::convert::TryFrom<&'static [u8]> { + let a: &'static _ = &[0; 33]; + a +} + +pub fn yes_hash() -> impl std::hash::Hash { + [0; 33] +} + +pub fn yes_debug() -> impl std::fmt::Debug { + [0; 33] +} + +pub fn yes_ref_into_iterator() -> impl IntoIterator { + let a: &'static _ = &[0; 33]; + a +} + +pub fn yes_partial_eq() -> impl PartialEq<[u8; 33]> { + [0; 33] +} + +pub fn yes_partial_eq_slice() -> impl PartialEq<[u8]> { + [0; 33] +} + +pub fn yes_slice_partial_eq() -> impl PartialEq<[u8; 33]> { + let a: &'static _ = &[0; 33]; + &a[..] +} + +pub fn yes_eq() -> impl Eq { + [0; 33] +} + +pub fn yes_partial_ord() -> impl PartialOrd<[u8; 33]> { + [0; 33] +} + +pub fn yes_ord() -> impl Ord { + [0; 33] +} + +fn main() {} diff --git a/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs b/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs deleted file mode 100644 index 8397d204f35cf..0000000000000 --- a/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.rs +++ /dev/null @@ -1,29 +0,0 @@ -pub fn no_debug() { - println!("{:?}", [0_usize; 33]); - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_hash() { - use std::collections::HashSet; - let mut set = HashSet::new(); - set.insert([0_usize; 33]); - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_partial_eq() -> bool { - [0_usize; 33] == [1_usize; 33] - //~^ ERROR binary operation `==` cannot be applied to type `[usize; 33]` -} - -pub fn no_partial_ord() -> bool { - [0_usize; 33] < [1_usize; 33] - //~^ ERROR binary operation `<` cannot be applied to type `[usize; 33]` -} - -pub fn no_into_iterator() { - for _ in &[0_usize; 33] { - //~^ ERROR the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied - } -} - -fn main() {} diff --git a/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr deleted file mode 100644 index 76ccc48c32ac1..0000000000000 --- a/src/test/ui/const-generics/array-impls/core-traits-no-impls-length-33.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/core-traits-no-impls-length-33.rs:2:22 - | -LL | println!("{:?}", [0_usize; 33]); - | ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]` - | - = note: required because of the requirements on the impl of `std::fmt::Debug` for `[usize; 33]` - = note: required by `std::fmt::Debug::fmt` - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/core-traits-no-impls-length-33.rs:9:16 - | -LL | set.insert([0_usize; 33]); - | ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[usize; 33]` - | - = note: required because of the requirements on the impl of `std::cmp::Eq` for `[usize; 33]` - -error[E0369]: binary operation `==` cannot be applied to type `[usize; 33]` - --> $DIR/core-traits-no-impls-length-33.rs:14:19 - | -LL | [0_usize; 33] == [1_usize; 33] - | ------------- ^^ ------------- [usize; 33] - | | - | [usize; 33] - -error[E0369]: binary operation `<` cannot be applied to type `[usize; 33]` - --> $DIR/core-traits-no-impls-length-33.rs:19:19 - | -LL | [0_usize; 33] < [1_usize; 33] - | ------------- ^ ------------- [usize; 33] - | | - | [usize; 33] - -error[E0277]: the trait bound `&[usize; 33]: std::iter::IntoIterator` is not satisfied - --> $DIR/core-traits-no-impls-length-33.rs:24:14 - | -LL | for _ in &[0_usize; 33] { - | ^^^^^^^^^^^^^^ the trait `std::iter::IntoIterator` is not implemented for `&[usize; 33]` - | - = help: the following implementations were found: - <&'a [T; N] as std::iter::IntoIterator> - <&'a [T] as std::iter::IntoIterator> - <&'a mut [T; N] as std::iter::IntoIterator> - <&'a mut [T] as std::iter::IntoIterator> - = note: required by `std::iter::IntoIterator::into_iter` - -error: aborting due to 5 previous errors - -Some errors have detailed explanations: E0277, E0369. -For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs b/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs new file mode 100644 index 0000000000000..0aeba8607e818 --- /dev/null +++ b/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs @@ -0,0 +1,41 @@ +// check-pass + +#![feature(array_value_iter)] +#![feature(trusted_len)] + +use std::{ + array::IntoIter, + fmt::Debug, + iter::{ExactSizeIterator, FusedIterator, TrustedLen}, +}; + +pub fn yes_iterator() -> impl Iterator { + IntoIter::new([0i32; 32]) +} + +pub fn yes_double_ended_iterator() -> impl DoubleEndedIterator { + IntoIter::new([0i32; 32]) +} + +pub fn yes_exact_size_iterator() -> impl ExactSizeIterator { + IntoIter::new([0i32; 32]) +} + +pub fn yes_fused_iterator() -> impl FusedIterator { + IntoIter::new([0i32; 32]) +} + +pub fn yes_trusted_len() -> impl TrustedLen { + IntoIter::new([0i32; 32]) +} + +pub fn yes_clone() -> impl Clone { + IntoIter::new([0i32; 32]) +} + +pub fn yes_debug() -> impl Debug { + IntoIter::new([0i32; 32]) +} + + +fn main() {} diff --git a/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.rs b/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.rs deleted file mode 100644 index a0bbd2ce64add..0000000000000 --- a/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![feature(array_value_iter)] -#![feature(trusted_len)] - -use std::{ - array::IntoIter, - fmt::Debug, - iter::{ExactSizeIterator, FusedIterator, TrustedLen}, -}; - -pub fn no_iterator() -> impl Iterator { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_double_ended_iterator() -> impl DoubleEndedIterator { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_exact_size_iterator() -> impl ExactSizeIterator { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_fused_iterator() -> impl FusedIterator { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_trusted_len() -> impl TrustedLen { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_clone() -> impl Clone { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - -pub fn no_debug() -> impl Debug { - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 - IntoIter::new([0i32; 33]) - //~^ ERROR arrays only have std trait implementations for lengths 0..=32 -} - - -fn main() {} diff --git a/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.stderr deleted file mode 100644 index ceda31550ff44..0000000000000 --- a/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.stderr +++ /dev/null @@ -1,143 +0,0 @@ -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:12:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:10:25 - | -LL | pub fn no_iterator() -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:18:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:16:38 - | -LL | pub fn no_double_ended_iterator() -> impl DoubleEndedIterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::iter::DoubleEndedIterator` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:24:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:22:36 - | -LL | pub fn no_exact_size_iterator() -> impl ExactSizeIterator { - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::iter::ExactSizeIterator` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:30:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:28:31 - | -LL | pub fn no_fused_iterator() -> impl FusedIterator { - | ^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::iter::FusedIterator` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:36:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:34:28 - | -LL | pub fn no_trusted_len() -> impl TrustedLen { - | ^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::iter::TrustedLen` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:42:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:40:22 - | -LL | pub fn no_clone() -> impl Clone { - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::clone::Clone` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:48:19 - | -LL | IntoIter::new([0i32; 33]) - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` - | - = note: required by `std::array::IntoIter::::new` - -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/into-iter-no-impls-length-33.rs:46:22 - | -LL | pub fn no_debug() -> impl Debug { - | ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]` -LL | -LL | IntoIter::new([0i32; 33]) - | ------------------------- this returned value is of type `std::array::IntoIter` - | - = note: required because of the requirements on the impl of `std::fmt::Debug` for `std::array::IntoIter` - = note: the return type of a function must have a statically known size - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/broken-mir-2.rs b/src/test/ui/const-generics/broken-mir-2.rs index c2f9b786f8f89..2cd035639ee5c 100644 --- a/src/test/ui/const-generics/broken-mir-2.rs +++ b/src/test/ui/const-generics/broken-mir-2.rs @@ -1,3 +1,5 @@ +// run-pass + #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete @@ -5,6 +7,5 @@ use std::fmt::Debug; #[derive(Debug)] struct S([T; N]); -//~^ ERROR arrays only have std trait implementations for lengths 0..=32 fn main() {} diff --git a/src/test/ui/const-generics/broken-mir-2.stderr b/src/test/ui/const-generics/broken-mir-2.stderr index 05552027f13d0..c36ef8450976c 100644 --- a/src/test/ui/const-generics/broken-mir-2.stderr +++ b/src/test/ui/const-generics/broken-mir-2.stderr @@ -1,5 +1,5 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/broken-mir-2.rs:1:12 + --> $DIR/broken-mir-2.rs:3:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ @@ -7,17 +7,5 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 for more information -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/broken-mir-2.rs:7:36 - | -LL | struct S([T; N]); - | ^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[T; N]` - | - = note: required because of the requirements on the impl of `std::fmt::Debug` for `[T; N]` - = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[T; N]` - = note: required for the cast to the object type `dyn std::fmt::Debug` - = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error; 1 warning emitted +warning: 1 warning emitted -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/const-generics/derive-debug-array-wrapper.rs b/src/test/ui/const-generics/derive-debug-array-wrapper.rs index c6d8b32f276f3..36272ae86199d 100644 --- a/src/test/ui/const-generics/derive-debug-array-wrapper.rs +++ b/src/test/ui/const-generics/derive-debug-array-wrapper.rs @@ -1,9 +1,11 @@ +// run-pass + #![feature(const_generics)] //~^ WARN the feature `const_generics` is incomplete #[derive(Debug)] struct X { - a: [u32; N], //~ ERROR arrays only have std trait implementations for lengths 0..=32 + a: [u32; N], } fn main() {} diff --git a/src/test/ui/const-generics/derive-debug-array-wrapper.stderr b/src/test/ui/const-generics/derive-debug-array-wrapper.stderr index a0abbd168946a..8f7ab822554a2 100644 --- a/src/test/ui/const-generics/derive-debug-array-wrapper.stderr +++ b/src/test/ui/const-generics/derive-debug-array-wrapper.stderr @@ -1,5 +1,5 @@ warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/derive-debug-array-wrapper.rs:1:12 + --> $DIR/derive-debug-array-wrapper.rs:3:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ @@ -7,17 +7,5 @@ LL | #![feature(const_generics)] = note: `#[warn(incomplete_features)]` on by default = note: see issue #44580 for more information -error[E0277]: arrays only have std trait implementations for lengths 0..=32 - --> $DIR/derive-debug-array-wrapper.rs:6:5 - | -LL | a: [u32; N], - | ^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[u32; N]` - | - = note: required because of the requirements on the impl of `std::fmt::Debug` for `[u32; N]` - = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u32; N]` - = note: required for the cast to the object type `dyn std::fmt::Debug` - = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to previous error; 1 warning emitted +warning: 1 warning emitted -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/consts/too_generic_eval_ice.rs b/src/test/ui/consts/too_generic_eval_ice.rs index 3ea5f88f07d1e..af494e3734914 100644 --- a/src/test/ui/consts/too_generic_eval_ice.rs +++ b/src/test/ui/consts/too_generic_eval_ice.rs @@ -6,7 +6,8 @@ impl Foo { pub fn crash() -> bool { [5; Self::HOST_SIZE] == [6; 0] //~^ ERROR constant expression depends on a generic parameter - //~| ERROR binary operation `==` cannot be applied to type `[{integer}; _]` + //~| ERROR constant expression depends on a generic parameter + //~| ERROR can't compare `[{integer}; _]` with `[{integer}; 0]` } } diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index 8b29c533bcc93..d5816fbb8e4fb 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -6,14 +6,22 @@ LL | [5; Self::HOST_SIZE] == [6; 0] | = note: this may fail depending on what value the parameter takes -error[E0369]: binary operation `==` cannot be applied to type `[{integer}; _]` +error: constant expression depends on a generic parameter + --> $DIR/too_generic_eval_ice.rs:7:30 + | +LL | [5; Self::HOST_SIZE] == [6; 0] + | ^^ + | + = note: this may fail depending on what value the parameter takes + +error[E0277]: can't compare `[{integer}; _]` with `[{integer}; 0]` --> $DIR/too_generic_eval_ice.rs:7:30 | LL | [5; Self::HOST_SIZE] == [6; 0] - | -------------------- ^^ ------ [{integer}; 0] - | | - | [{integer}; _] + | ^^ no implementation for `[{integer}; _] == [{integer}; 0]` + | + = help: the trait `std::cmp::PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0369`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index c1aa3d70f77cc..561376c8f059d 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -13,10 +13,10 @@ fn main() { //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out big.iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out [0u8; 33].iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(small).iter(); @@ -26,10 +26,10 @@ fn main() { //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(big).iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new([0u8; 33]).iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(Box::new(small)).iter(); @@ -39,10 +39,10 @@ fn main() { //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(Box::new(big)).iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(Box::new([0u8; 33])).iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out // Expressions that should not diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index afdf6cb7f4420..cc310191f0caf 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -13,10 +13,10 @@ fn main() { //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out big.into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out [0u8; 33].into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(small).into_iter(); @@ -26,10 +26,10 @@ fn main() { //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(big).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new([0u8; 33]).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(Box::new(small)).into_iter(); @@ -39,10 +39,10 @@ fn main() { //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(Box::new(big)).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out Box::new(Box::new([0u8; 33])).into_iter(); - //~^ WARNING this method call currently resolves to `<&[T] as IntoIterator>::into_iter` + //~^ WARNING this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` //~| WARNING this was previously accepted by the compiler but is being phased out // Expressions that should not diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index bbec9147f574b..b31f444b36e99 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -17,7 +17,7 @@ LL | [1, 2].into_iter(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #66145 -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. --> $DIR/into-iter-on-arrays-lint.rs:15:9 | LL | big.into_iter(); @@ -26,7 +26,7 @@ LL | big.into_iter(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #66145 -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. --> $DIR/into-iter-on-arrays-lint.rs:18:15 | LL | [0u8; 33].into_iter(); @@ -53,7 +53,7 @@ LL | Box::new([1, 2]).into_iter(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #66145 -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. --> $DIR/into-iter-on-arrays-lint.rs:28:19 | LL | Box::new(big).into_iter(); @@ -62,7 +62,7 @@ LL | Box::new(big).into_iter(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #66145 -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. --> $DIR/into-iter-on-arrays-lint.rs:31:25 | LL | Box::new([0u8; 33]).into_iter(); @@ -89,7 +89,7 @@ LL | Box::new(Box::new([1, 2])).into_iter(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #66145 -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. --> $DIR/into-iter-on-arrays-lint.rs:41:29 | LL | Box::new(Box::new(big)).into_iter(); @@ -98,7 +98,7 @@ LL | Box::new(Box::new(big)).into_iter(); = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #66145 -warning: this method call currently resolves to `<&[T] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. --> $DIR/into-iter-on-arrays-lint.rs:44:35 | LL | Box::new(Box::new([0u8; 33])).into_iter(); From 4ad40a8737ab4ffaf6352ec4560fd86cb0b4ade8 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Sun, 5 Jul 2020 16:07:09 +0300 Subject: [PATCH 3/5] Remove LengthAtMost32 --- src/liballoc/lib.rs | 1 - src/libcore/array/mod.rs | 25 ------------------------- 2 files changed, 26 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5f18fe8bfab84..1d3e255eaae6a 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -84,7 +84,6 @@ #![feature(cfg_target_has_atomic)] #![feature(coerce_unsized)] #![feature(const_btree_new)] -#![feature(const_generic_impls_guard)] #![feature(const_generics)] #![feature(const_in_array_repeat_expressions)] #![cfg_attr(bootstrap, feature(const_if_match))] diff --git a/src/libcore/array/mod.rs b/src/libcore/array/mod.rs index c5e7f65948564..c0bf3833b9c33 100644 --- a/src/libcore/array/mod.rs +++ b/src/libcore/array/mod.rs @@ -342,31 +342,6 @@ impl Ord for [T; N] { } } -/// Implemented for lengths where trait impls are allowed on arrays in core/std -#[rustc_on_unimplemented(message = "arrays only have std trait implementations for lengths 0..=32")] -#[unstable( - feature = "const_generic_impls_guard", - issue = "none", - reason = "will never be stable, just a temporary step until const generics are stable" -)] -pub trait LengthAtMost32 {} - -macro_rules! array_impls { - ($($N:literal)+) => { - $( - #[unstable(feature = "const_generic_impls_guard", issue = "none")] - impl LengthAtMost32 for [T; $N] {} - )+ - } -} - -array_impls! { - 0 1 2 3 4 5 6 7 8 9 - 10 11 12 13 14 15 16 17 18 19 - 20 21 22 23 24 25 26 27 28 29 - 30 31 32 -} - // The Default impls cannot be generated using the array_impls! macro because // they require array literals. From 44dd95e4d008e9edc112dc1a599eac028889e015 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Sun, 5 Jul 2020 19:06:02 +0300 Subject: [PATCH 4/5] Fix copypaste in test into-iter-impls-length-33 (const generic 32 -> 33) --- .../array-impls/into-iter-impls-length-33.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs b/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs index 0aeba8607e818..5503813c7aa3e 100644 --- a/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs +++ b/src/test/ui/const-generics/array-impls/into-iter-impls-length-33.rs @@ -10,31 +10,31 @@ use std::{ }; pub fn yes_iterator() -> impl Iterator { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } pub fn yes_double_ended_iterator() -> impl DoubleEndedIterator { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } pub fn yes_exact_size_iterator() -> impl ExactSizeIterator { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } pub fn yes_fused_iterator() -> impl FusedIterator { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } pub fn yes_trusted_len() -> impl TrustedLen { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } pub fn yes_clone() -> impl Clone { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } pub fn yes_debug() -> impl Debug { - IntoIter::new([0i32; 32]) + IntoIter::new([0i32; 33]) } From 8fc7d47c8c43dab634aff15908ab42ca056dda07 Mon Sep 17 00:00:00 2001 From: Roman Proskuryakov Date: Sun, 5 Jul 2020 19:56:41 +0300 Subject: [PATCH 5/5] Fix array docs (remove mentions about 0 to 32 where possible) --- src/libstd/primitive_docs.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index e0ceb9f3f3810..86de509e80a10 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -460,8 +460,7 @@ mod prim_pointer {} /// * A repeat expression `[x; N]`, which produces an array with `N` copies of `x`. /// The type of `x` must be [`Copy`][copy]. /// -/// Arrays of sizes from 0 to 32 (inclusive) implement the following traits if -/// the element type allows it: +/// Arrays of *any* size implement the following traits if the element type allows it: /// /// - [`Debug`][debug] /// - [`IntoIterator`][intoiterator] (implemented for `&[T; N]` and `&mut [T; N]`) @@ -469,12 +468,9 @@ mod prim_pointer {} /// - [`Hash`][hash] /// - [`AsRef`][asref], [`AsMut`][asmut] /// - [`Borrow`][borrow], [`BorrowMut`][borrowmut] -/// - [`Default`][default] /// -/// This limitation on the size `N` exists because Rust does not yet support -/// code that is generic over the size of an array type. `[Foo; 3]` and `[Bar; 3]` -/// are instances of same generic type `[T; 3]`, but `[Foo; 3]` and `[Foo; 5]` are -/// entirely different types. As a stopgap, trait implementations are +/// Arrays of sizes from 0 to 32 (inclusive) implement [`Default`][default] trait +/// if the element type allows it. As a stopgap, trait implementations are /// statically generated up to size 32. /// /// Arrays of *any* size are [`Copy`][copy] if the element type is [`Copy`][copy] @@ -521,8 +517,7 @@ mod prim_pointer {} /// for x in array.iter() { } /// ``` /// -/// If the array has 32 or fewer elements (see above), you can also use the -/// array reference's [`IntoIterator`] implementation: +/// You can also use the array reference's [`IntoIterator`] implementation: /// /// ``` /// # let array: [i32; 3] = [0; 3];