Skip to content

Commit c36b9dd

Browse files
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.
1 parent 5334a30 commit c36b9dd

File tree

3 files changed

+216
-0
lines changed

3 files changed

+216
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// check-pass
2+
3+
#![feature(array_value_iter)]
4+
#![feature(trusted_len)]
5+
6+
use std::{
7+
array::IntoIter,
8+
fmt::Debug,
9+
iter::{ExactSizeIterator, FusedIterator, TrustedLen},
10+
};
11+
12+
pub fn yes_iterator() -> impl Iterator<Item = i32> {
13+
IntoIter::new([0i32; 32])
14+
}
15+
16+
pub fn yes_double_ended_iterator() -> impl DoubleEndedIterator {
17+
IntoIter::new([0i32; 32])
18+
}
19+
20+
pub fn yes_exact_size_iterator() -> impl ExactSizeIterator {
21+
IntoIter::new([0i32; 32])
22+
}
23+
24+
pub fn yes_fused_iterator() -> impl FusedIterator {
25+
IntoIter::new([0i32; 32])
26+
}
27+
28+
pub fn yes_trusted_len() -> impl TrustedLen {
29+
IntoIter::new([0i32; 32])
30+
}
31+
32+
pub fn yes_clone() -> impl Clone {
33+
IntoIter::new([0i32; 32])
34+
}
35+
36+
pub fn yes_debug() -> impl Debug {
37+
IntoIter::new([0i32; 32])
38+
}
39+
40+
41+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#![feature(array_value_iter)]
2+
#![feature(trusted_len)]
3+
4+
use std::{
5+
array::IntoIter,
6+
fmt::Debug,
7+
iter::{ExactSizeIterator, FusedIterator, TrustedLen},
8+
};
9+
10+
pub fn no_iterator() -> impl Iterator<Item = i32> {
11+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
12+
IntoIter::new([0i32; 33])
13+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
14+
}
15+
16+
pub fn no_double_ended_iterator() -> impl DoubleEndedIterator {
17+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
18+
IntoIter::new([0i32; 33])
19+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
20+
}
21+
22+
pub fn no_exact_size_iterator() -> impl ExactSizeIterator {
23+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
24+
IntoIter::new([0i32; 33])
25+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
26+
}
27+
28+
pub fn no_fused_iterator() -> impl FusedIterator {
29+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
30+
IntoIter::new([0i32; 33])
31+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
32+
}
33+
34+
pub fn no_trusted_len() -> impl TrustedLen {
35+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
36+
IntoIter::new([0i32; 33])
37+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
38+
}
39+
40+
pub fn no_clone() -> impl Clone {
41+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
42+
IntoIter::new([0i32; 33])
43+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
44+
}
45+
46+
pub fn no_debug() -> impl Debug {
47+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
48+
IntoIter::new([0i32; 33])
49+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
50+
}
51+
52+
53+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
2+
--> $DIR/into-iter-no-impls-length-33.rs:12:5
3+
|
4+
LL | IntoIter::new([0i32; 33])
5+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
6+
|
7+
= note: required by `std::array::IntoIter::<T, N>::new`
8+
9+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
10+
--> $DIR/into-iter-no-impls-length-33.rs:10:25
11+
|
12+
LL | pub fn no_iterator() -> impl Iterator<Item = i32> {
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
14+
|
15+
= note: required because of the requirements on the impl of `std::iter::Iterator` for `std::array::IntoIter<i32, 33usize>`
16+
= note: the return type of a function must have a statically known size
17+
18+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
19+
--> $DIR/into-iter-no-impls-length-33.rs:18:5
20+
|
21+
LL | IntoIter::new([0i32; 33])
22+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
23+
|
24+
= note: required by `std::array::IntoIter::<T, N>::new`
25+
26+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
27+
--> $DIR/into-iter-no-impls-length-33.rs:16:38
28+
|
29+
LL | pub fn no_double_ended_iterator() -> impl DoubleEndedIterator {
30+
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
31+
|
32+
= note: required because of the requirements on the impl of `std::iter::DoubleEndedIterator` for `std::array::IntoIter<i32, 33usize>`
33+
= note: the return type of a function must have a statically known size
34+
35+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
36+
--> $DIR/into-iter-no-impls-length-33.rs:24:5
37+
|
38+
LL | IntoIter::new([0i32; 33])
39+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
40+
|
41+
= note: required by `std::array::IntoIter::<T, N>::new`
42+
43+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
44+
--> $DIR/into-iter-no-impls-length-33.rs:22:36
45+
|
46+
LL | pub fn no_exact_size_iterator() -> impl ExactSizeIterator {
47+
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
48+
|
49+
= note: required because of the requirements on the impl of `std::iter::ExactSizeIterator` for `std::array::IntoIter<i32, 33usize>`
50+
= note: the return type of a function must have a statically known size
51+
52+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
53+
--> $DIR/into-iter-no-impls-length-33.rs:30:5
54+
|
55+
LL | IntoIter::new([0i32; 33])
56+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
57+
|
58+
= note: required by `std::array::IntoIter::<T, N>::new`
59+
60+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
61+
--> $DIR/into-iter-no-impls-length-33.rs:28:31
62+
|
63+
LL | pub fn no_fused_iterator() -> impl FusedIterator {
64+
| ^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
65+
|
66+
= note: required because of the requirements on the impl of `std::iter::FusedIterator` for `std::array::IntoIter<i32, 33usize>`
67+
= note: the return type of a function must have a statically known size
68+
69+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
70+
--> $DIR/into-iter-no-impls-length-33.rs:36:5
71+
|
72+
LL | IntoIter::new([0i32; 33])
73+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
74+
|
75+
= note: required by `std::array::IntoIter::<T, N>::new`
76+
77+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
78+
--> $DIR/into-iter-no-impls-length-33.rs:34:28
79+
|
80+
LL | pub fn no_trusted_len() -> impl TrustedLen {
81+
| ^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
82+
|
83+
= note: required because of the requirements on the impl of `std::iter::TrustedLen` for `std::array::IntoIter<i32, 33usize>`
84+
= note: the return type of a function must have a statically known size
85+
86+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
87+
--> $DIR/into-iter-no-impls-length-33.rs:42:5
88+
|
89+
LL | IntoIter::new([0i32; 33])
90+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
91+
|
92+
= note: required by `std::array::IntoIter::<T, N>::new`
93+
94+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
95+
--> $DIR/into-iter-no-impls-length-33.rs:40:22
96+
|
97+
LL | pub fn no_clone() -> impl Clone {
98+
| ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
99+
|
100+
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::array::IntoIter<i32, 33usize>`
101+
= note: the return type of a function must have a statically known size
102+
103+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
104+
--> $DIR/into-iter-no-impls-length-33.rs:48:5
105+
|
106+
LL | IntoIter::new([0i32; 33])
107+
| ^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
108+
|
109+
= note: required by `std::array::IntoIter::<T, N>::new`
110+
111+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
112+
--> $DIR/into-iter-no-impls-length-33.rs:46:22
113+
|
114+
LL | pub fn no_debug() -> impl Debug {
115+
| ^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i32; 33]`
116+
|
117+
= note: required because of the requirements on the impl of `std::fmt::Debug` for `std::array::IntoIter<i32, 33usize>`
118+
= note: the return type of a function must have a statically known size
119+
120+
error: aborting due to 14 previous errors
121+
122+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)