diff options
| author | Lukas Kalbertodt <lukas.kalbertodt@gmail.com> | 2019-10-21 13:47:02 +0200 |
|---|---|---|
| committer | Lukas Kalbertodt <lukas.kalbertodt@gmail.com> | 2019-10-24 15:46:44 +0200 |
| commit | c36b9ddcb40b81642cef2d1dd17bcd45f54c70da (patch) | |
| tree | ab722d8ac03058358448630831b3b7c1a39d542e | |
| parent | 5334a307d551e5affaef253f1c83141495db46f0 (diff) | |
| download | rust-c36b9ddcb40b81642cef2d1dd17bcd45f54c70da.tar.gz rust-c36b9ddcb40b81642cef2d1dd17bcd45f54c70da.zip | |
Add UI tests for `array::IntoIter` impls
This it to make sure traits are implemented for arrays with length 32 and below, while they are not implemented for >= 33.
3 files changed, 216 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/array-impls/into-iter-impls-length-32.rs b/src/test/ui/const-generics/array-impls/into-iter-impls-length-32.rs new file mode 100644 index 00000000000..0aeba8607e8 --- /dev/null +++ b/src/test/ui/const-generics/array-impls/into-iter-impls-length-32.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<Item = i32> { + 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 new file mode 100644 index 00000000000..a0bbd2ce64a --- /dev/null +++ b/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.rs @@ -0,0 +1,53 @@ +#![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() {} 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 new file mode 100644 index 00000000000..bfdff8e3bbe --- /dev/null +++ b/src/test/ui/const-generics/array-impls/into-iter-no-impls-length-33.stderr @@ -0,0 +1,122 @@ +error[E0277]: arrays only have std trait implementations for lengths 0..=32 + --> $DIR/into-iter-no-impls-length-33.rs:12:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::array::IntoIter<i32, 33usize>` + = 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:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::iter::DoubleEndedIterator` for `std::array::IntoIter<i32, 33usize>` + = 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:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::iter::ExactSizeIterator` for `std::array::IntoIter<i32, 33usize>` + = 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:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::iter::FusedIterator` for `std::array::IntoIter<i32, 33usize>` + = 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:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::iter::TrustedLen` for `std::array::IntoIter<i32, 33usize>` + = 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:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::clone::Clone` for `std::array::IntoIter<i32, 33usize>` + = 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:5 + | +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]` + | + = note: required because of the requirements on the impl of `std::fmt::Debug` for `std::array::IntoIter<i32, 33usize>` + = 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`. |
