Auto merge of #74060 - kpp:remove_length_at_most_32, r=dtolnay

Remove trait LengthAtMost32

This is a continuation of https://github.com/rust-lang/rust/pull/74026 preserving the original burrbull's commit.

I talked to @burrbull, he suggested me to finish his PR.
This commit is contained in:
bors 2020-07-26 05:50:51 +00:00
commit 461707c5a1
30 changed files with 259 additions and 732 deletions

View file

@ -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<Box<str>> for Box<[u8]> {
}
#[stable(feature = "box_from_array", since = "1.45.0")]
impl<T, const N: usize> From<[T; N]> for Box<[T]>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> 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<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> TryFrom<Box<[T]>> for Box<[T; N]> {
type Error = Box<[T]>;
fn try_from(boxed_slice: Box<[T]>) -> Result<Self, Self::Error> {

View file

@ -9,7 +9,6 @@
// ignore-tidy-filelength
use core::array::LengthAtMost32;
use core::cmp::{self, Ordering};
use core::fmt;
use core::hash::{Hash, Hasher};
@ -2889,9 +2888,9 @@ macro_rules! __impl_slice_eq1 {
__impl_slice_eq1! { [] VecDeque<A>, Vec<B>, }
__impl_slice_eq1! { [] VecDeque<A>, &[B], }
__impl_slice_eq1! { [] VecDeque<A>, &mut [B], }
__impl_slice_eq1! { [const N: usize] VecDeque<A>, [B; N], [B; N]: LengthAtMost32 }
__impl_slice_eq1! { [const N: usize] VecDeque<A>, &[B; N], [B; N]: LengthAtMost32 }
__impl_slice_eq1! { [const N: usize] VecDeque<A>, &mut [B; N], [B; N]: LengthAtMost32 }
__impl_slice_eq1! { [const N: usize] VecDeque<A>, [B; N], }
__impl_slice_eq1! { [const N: usize] VecDeque<A>, &[B; N], }
__impl_slice_eq1! { [const N: usize] VecDeque<A>, &mut [B; N], }
#[stable(feature = "rust1", since = "1.0.0")]
impl<A: PartialOrd> PartialOrd for VecDeque<A> {

View file

@ -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)]
#![feature(cow_is_borrowed)]

View file

@ -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;
@ -1516,10 +1515,7 @@ where
}
#[stable(feature = "boxed_slice_try_from", since = "1.43.0")]
impl<T, const N: usize> TryFrom<Rc<[T]>> for Rc<[T; N]>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> TryFrom<Rc<[T]>> for Rc<[T; N]> {
type Error = Rc<[T]>;
fn try_from(boxed_slice: Rc<[T]>) -> Result<Self, Self::Error> {

View file

@ -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};
@ -2162,10 +2161,7 @@ where
}
#[stable(feature = "boxed_slice_try_from", since = "1.43.0")]
impl<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> TryFrom<Arc<[T]>> for Arc<[T; N]> {
type Error = Arc<[T]>;
fn try_from(boxed_slice: Arc<[T]>) -> Result<Self, Self::Error> {

View file

@ -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};
@ -2378,18 +2377,18 @@ __impl_slice_eq1! { [] &mut [A], Vec<B>, #[stable(feature = "partialeq_vec_for_r
__impl_slice_eq1! { [] Cow<'_, [A]>, Vec<B> 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<A>, [B; N] where [B; N]: LengthAtMost32, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N] where [B; N]: LengthAtMost32, #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [const N: usize] Vec<A>, [B; N], #[stable(feature = "rust1", since = "1.0.0")] }
__impl_slice_eq1! { [const N: usize] Vec<A>, &[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<A>, &mut [B; N], [B; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] [A; N], Vec<B>, [A; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] &[A; N], Vec<B>, [A; N]: LengthAtMost32 }
//__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec<B>, [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<A>, &mut [B; N], }
//__impl_slice_eq1! { [const N: usize] [A; N], Vec<B>, }
//__impl_slice_eq1! { [const N: usize] &[A; N], Vec<B>, }
//__impl_slice_eq1! { [const N: usize] &mut [A; N], Vec<B>, }
//__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")]
@ -2493,10 +2492,7 @@ impl<T: Clone> From<&mut [T]> for Vec<T> {
}
#[stable(feature = "vec_from_array", since = "1.44.0")]
impl<T, const N: usize> From<[T; N]> for Vec<T>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> From<[T; N]> for Vec<T> {
#[cfg(not(test))]
fn from(s: [T; N]) -> Vec<T> {
<[T]>::into_vec(box s)

View file

@ -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<T, const N: usize>
where
[T; N]: LengthAtMost32,
{
pub struct IntoIter<T, const N: usize> {
/// 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<usize>,
}
impl<T, const N: usize> IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> IntoIter<T, N> {
/// 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<T, const N: usize> Iterator for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> Iterator for IntoIter<T, N> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
if self.alive.start == self.alive.end {
@ -146,10 +136,7 @@ where
}
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
fn next_back(&mut self) -> Option<Self::Item> {
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<T, const N: usize> Drop for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> Drop for IntoIter<T, N> {
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<T, const N: usize> ExactSizeIterator for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> ExactSizeIterator for IntoIter<T, N> {
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<T, const N: usize> FusedIterator for IntoIter<T, N> where [T; N]: LengthAtMost32 {}
impl<T, const N: usize> FusedIterator for IntoIter<T, N> {}
// 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<T, const N: usize> TrustedLen for IntoIter<T, N> where [T; N]: LengthAtMost32 {}
unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, N> {}
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T: Clone, const N: usize> Clone for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T: Clone, const N: usize> Clone for IntoIter<T, N> {
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<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, N> {
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.

View file

@ -92,10 +92,7 @@ impl From<Infallible> for TryFromSliceError {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T, const N: usize> AsRef<[T]> for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> 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<T, const N: usize> AsMut<[T]> for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> 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<T, const N: usize> Borrow<[T]> for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> Borrow<[T]> for [T; N] {
fn borrow(&self) -> &[T] {
self
}
}
#[stable(feature = "array_borrow", since = "1.4.0")]
impl<T, const N: usize> BorrowMut<[T]> for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T, const N: usize> BorrowMut<[T]> for [T; N] {
fn borrow_mut(&mut self) -> &mut [T] {
self
}
@ -137,7 +125,6 @@ where
impl<T, const N: usize> TryFrom<&[T]> for [T; N]
where
T: Copy,
[T; N]: LengthAtMost32,
{
type Error = TryFromSliceError;
@ -147,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> {
@ -165,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> {
@ -183,30 +164,21 @@ where
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Hash, const N: usize> Hash for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T: Hash, const N: usize> Hash for [T; N] {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
Hash::hash(&self[..], state)
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Debug, const N: usize> fmt::Debug for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T: fmt::Debug, const N: usize> 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>;
@ -216,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>;
@ -232,8 +201,6 @@ where
impl<A, B, const N: usize> PartialEq<[B; N]> for [A; N]
where
A: PartialEq<B>,
[A; N]: LengthAtMost32,
[B; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &[B; N]) -> bool {
@ -249,7 +216,6 @@ where
impl<A, B, const N: usize> PartialEq<[B]> for [A; N]
where
A: PartialEq<B>,
[A; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &[B]) -> bool {
@ -265,7 +231,6 @@ where
impl<A, B, const N: usize> PartialEq<[A; N]> for [B]
where
B: PartialEq<A>,
[A; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &[A; N]) -> bool {
@ -281,7 +246,6 @@ where
impl<'b, A, B, const N: usize> PartialEq<&'b [B]> for [A; N]
where
A: PartialEq<B>,
[A; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &&'b [B]) -> bool {
@ -297,7 +261,6 @@ where
impl<'b, A, B, const N: usize> PartialEq<[A; N]> for &'b [B]
where
B: PartialEq<A>,
[A; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &[A; N]) -> bool {
@ -313,7 +276,6 @@ where
impl<'b, A, B, const N: usize> PartialEq<&'b mut [B]> for [A; N]
where
A: PartialEq<B>,
[A; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &&'b mut [B]) -> bool {
@ -329,7 +291,6 @@ where
impl<'b, A, B, const N: usize> PartialEq<[A; N]> for &'b mut [B]
where
B: PartialEq<A>,
[A; N]: LengthAtMost32,
{
#[inline]
fn eq(&self, other: &[A; N]) -> bool {
@ -346,13 +307,10 @@ where
// __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq, const N: usize> Eq for [T; N] where [T; N]: LengthAtMost32 {}
impl<T: Eq, const N: usize> Eq for [T; N] {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd, const N: usize> PartialOrd for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T: PartialOrd, const N: usize> PartialOrd for [T; N] {
#[inline]
fn partial_cmp(&self, other: &[T; N]) -> Option<Ordering> {
PartialOrd::partial_cmp(&&self[..], &&other[..])
@ -377,41 +335,13 @@ where
/// Implements comparison of arrays lexicographically.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord, const N: usize> Ord for [T; N]
where
[T; N]: LengthAtMost32,
{
impl<T: Ord, const N: usize> Ord for [T; N] {
#[inline]
fn cmp(&self, other: &[T; N]) -> Ordering {
Ord::cmp(&&self[..], &&other[..])
}
}
/// 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<T> 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.

View file

@ -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];

View file

@ -0,0 +1,40 @@
// check-pass
pub fn yes_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
where
A: PartialEq<B>,
{
Vec::<A>::new()
}
pub fn yes_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
where
A: PartialEq<B>,
{
Vec::<A>::new()
}
use std::collections::VecDeque;
pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
where
A: PartialEq<B>,
{
VecDeque::<A>::new()
}
pub fn yes_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
where
A: PartialEq<B>,
{
VecDeque::<A>::new()
}
pub fn yes_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]>
where
A: PartialEq<B>,
{
VecDeque::<A>::new()
}
fn main() {}

View file

@ -1,43 +0,0 @@
pub fn no_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
where
A: PartialEq<B>,
{
Vec::<A>::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<B>,
{
Vec::<A>::new()
}
use std::collections::VecDeque;
pub fn no_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
where
A: PartialEq<B>,
{
VecDeque::<A>::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<B>,
{
VecDeque::<A>::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<B>,
{
VecDeque::<A>::new()
}
fn main() {}

View file

@ -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<A, B>() -> impl PartialEq<[B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | Vec::<A>::new()
| --------------- this returned value is of type `std::vec::Vec<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::vec::Vec<A>`
= 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::<A>::new()
| --------------- this returned value is of type `std::vec::Vec<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::vec::Vec<A>`
= 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<A, B>() -> impl PartialEq<[B; 33]>
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
...
LL | VecDeque::<A>::new()
| -------------------- this returned value is of type `std::collections::VecDeque<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::collections::VecDeque<A>`
= 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::<A>::new()
| -------------------- this returned value is of type `std::collections::VecDeque<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::collections::VecDeque<A>`
= 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::<A>::new()
| -------------------- this returned value is of type `std::collections::VecDeque<A>`
|
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a mut [B; 33]>` for `std::collections::VecDeque<A>`
= 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`.

View file

@ -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 = <Box<[i32; 33]>>::try_from(boxed_slice);
let boxed_slice = <Box<[i32]>>::from([0; 33]);
}
pub fn yes_rc() {
let boxed_slice = Rc::new([0; 33]) as Rc<[i32]>;
let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
}
pub fn yes_arc() {
let boxed_slice = Arc::new([0; 33]) as Arc<[i32]>;
let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
}
fn main() {}

View file

@ -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 = <Box<[i32; 33]>>::try_from(boxed_slice);
//~^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From<std::boxed::Box<[i32]>>` is not satisfied
//~^^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom<std::boxed::Box<[i32]>>` is not satisfied
let boxed_slice = <Box<[i32]>>::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 = <Rc<[i32; 33]>>::try_from(boxed_slice);
//~^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From<std::rc::Rc<[i32]>>` is not satisfied
//~^^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom<std::rc::Rc<[i32]>>` is not satisfied
}
pub fn no_arc() {
let boxed_slice = Arc::new([0; 33]) as Arc<[i32]>;
let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
//~^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From<std::sync::Arc<[i32]>>` is not satisfied
//~^^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom<std::sync::Arc<[i32]>>` is not satisfied
}
fn main() {}

View file

@ -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<std::vec::Vec<{integer}>>` for `[{integer}; 33]`
error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From<std::boxed::Box<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:12:23
|
LL | let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::boxed::Box<[i32]>>` is not implemented for `std::boxed::Box<[i32; 33]>`
|
= help: the following implementations were found:
<std::boxed::Box<(dyn std::error::Error + 'a)> as std::convert::From<E>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<&str>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::borrow::Cow<'a, str>>>
<std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::string::String>>
and 22 others
= note: required because of the requirements on the impl of `std::convert::Into<std::boxed::Box<[i32; 33]>>` for `std::boxed::Box<[i32]>`
= note: required because of the requirements on the impl of `std::convert::TryFrom<std::boxed::Box<[i32]>>` 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 = <Box<[i32]>>::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<std::boxed::Box<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:12:23
|
LL | let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::boxed::Box<[i32]>>` is not implemented for `std::boxed::Box<[i32; 33]>`
|
= help: the following implementations were found:
<std::boxed::Box<[T; N]> as std::convert::TryFrom<std::boxed::Box<[T]>>>
error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From<std::rc::Rc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:21:23
|
LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
|
= help: the following implementations were found:
<std::rc::Rc<B> as std::convert::From<std::borrow::Cow<'a, B>>>
<std::rc::Rc<T> as std::convert::From<T>>
<std::rc::Rc<T> as std::convert::From<std::boxed::Box<T>>>
<std::rc::Rc<[T]> as std::convert::From<&[T]>>
and 9 others
= note: required because of the requirements on the impl of `std::convert::Into<std::rc::Rc<[i32; 33]>>` for `std::rc::Rc<[i32]>`
= note: required because of the requirements on the impl of `std::convert::TryFrom<std::rc::Rc<[i32]>>` for `std::rc::Rc<[i32; 33]>`
error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom<std::rc::Rc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:21:23
|
LL | let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
|
= help: the following implementations were found:
<std::rc::Rc<[T; N]> as std::convert::TryFrom<std::rc::Rc<[T]>>>
error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From<std::sync::Arc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:28:23
|
LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
|
= help: the following implementations were found:
<std::sync::Arc<B> as std::convert::From<std::borrow::Cow<'a, B>>>
<std::sync::Arc<T> as std::convert::From<T>>
<std::sync::Arc<T> as std::convert::From<std::boxed::Box<T>>>
<std::sync::Arc<[T]> as std::convert::From<&[T]>>
and 9 others
= note: required because of the requirements on the impl of `std::convert::Into<std::sync::Arc<[i32; 33]>>` for `std::sync::Arc<[i32]>`
= note: required because of the requirements on the impl of `std::convert::TryFrom<std::sync::Arc<[i32]>>` for `std::sync::Arc<[i32; 33]>`
error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom<std::sync::Arc<[i32]>>` is not satisfied
--> $DIR/alloc-types-no-impls-length-33.rs:28:23
|
LL | let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
|
= help: the following implementations were found:
<std::sync::Arc<[T; N]> as std::convert::TryFrom<std::sync::Arc<[T]>>>
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -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<Item=&'static u8> {
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() {}

View file

@ -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() {}

View file

@ -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`.

View file

@ -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<Item = i32> {
IntoIter::new([0i32; 33])
}
pub fn yes_double_ended_iterator() -> impl DoubleEndedIterator {
IntoIter::new([0i32; 33])
}
pub fn yes_exact_size_iterator() -> impl ExactSizeIterator {
IntoIter::new([0i32; 33])
}
pub fn yes_fused_iterator() -> impl FusedIterator {
IntoIter::new([0i32; 33])
}
pub fn yes_trusted_len() -> impl TrustedLen {
IntoIter::new([0i32; 33])
}
pub fn yes_clone() -> impl Clone {
IntoIter::new([0i32; 33])
}
pub fn yes_debug() -> impl Debug {
IntoIter::new([0i32; 33])
}
fn main() {}

View file

@ -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<Item = i32> {
//~^ 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() {}

View file

@ -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::<T, N>::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<Item = i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ 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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::iter::Iterator` for `std::array::IntoIter<i32, 33_usize>`
= 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::<T, N>::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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::iter::DoubleEndedIterator` for `std::array::IntoIter<i32, 33_usize>`
= 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::<T, N>::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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::iter::ExactSizeIterator` for `std::array::IntoIter<i32, 33_usize>`
= 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::<T, N>::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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::iter::FusedIterator` for `std::array::IntoIter<i32, 33_usize>`
= 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::<T, N>::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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::iter::TrustedLen` for `std::array::IntoIter<i32, 33_usize>`
= 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::<T, N>::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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::array::IntoIter<i32, 33_usize>`
= 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::<T, N>::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<i32, 33_usize>`
|
= note: required because of the requirements on the impl of `std::fmt::Debug` for `std::array::IntoIter<i32, 33_usize>`
= 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`.

View file

@ -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: Debug, const N: usize>([T; N]);
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
fn main() {}

View file

@ -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 <https://github.com/rust-lang/rust/issues/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: Debug, const N: usize>([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)
warning: 1 warning emitted
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -1,9 +1,11 @@
// run-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
#[derive(Debug)]
struct X<const N: usize> {
a: [u32; N], //~ ERROR arrays only have std trait implementations for lengths 0..=32
a: [u32; N],
}
fn main() {}

View file

@ -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 <https://github.com/rust-lang/rust/issues/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)
warning: 1 warning emitted
error: aborting due to previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0277`.

View file

@ -6,7 +6,8 @@ impl<A, B> Foo<A, B> {
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]`
}
}

View file

@ -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]
| -------------------- ^^ ------ [{integer}; 0]
| |
| [{integer}; _]
| ^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to 2 previous errors
error[E0277]: can't compare `[{integer}; _]` with `[{integer}; 0]`
--> $DIR/too_generic_eval_ice.rs:7:30
|
LL | [5; Self::HOST_SIZE] == [6; 0]
| ^^ no implementation for `[{integer}; _] == [{integer}; 0]`
|
= help: the trait `std::cmp::PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]`
For more information about this error, try `rustc --explain E0369`.
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.

View file

@ -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

View file

@ -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

View file

@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/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();