Skip to content

Commit bfdfa85

Browse files
committed
Add tests for Vec(Deque) array PartialEq impls.
1 parent 744ec88 commit bfdfa85

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// check-pass
2+
3+
pub fn yes_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 32]>
4+
where
5+
A: PartialEq<B>,
6+
{
7+
Vec::<A>::new()
8+
}
9+
10+
pub fn yes_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
11+
where
12+
A: PartialEq<B>,
13+
{
14+
Vec::<A>::new()
15+
}
16+
17+
use std::collections::VecDeque;
18+
19+
pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 32]>
20+
where
21+
A: PartialEq<B>,
22+
{
23+
VecDeque::<A>::new()
24+
}
25+
26+
pub fn yes_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
27+
where
28+
A: PartialEq<B>,
29+
{
30+
VecDeque::<A>::new()
31+
}
32+
33+
pub fn yes_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 32]>
34+
where
35+
A: PartialEq<B>,
36+
{
37+
VecDeque::<A>::new()
38+
}
39+
40+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
pub fn no_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
2+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
3+
where
4+
A: PartialEq<B>,
5+
{
6+
Vec::<A>::new()
7+
}
8+
9+
pub fn no_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
10+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
11+
where
12+
A: PartialEq<B>,
13+
{
14+
Vec::<A>::new()
15+
}
16+
17+
use std::collections::VecDeque;
18+
19+
pub fn no_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
20+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
21+
where
22+
A: PartialEq<B>,
23+
{
24+
VecDeque::<A>::new()
25+
}
26+
27+
pub fn no_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
28+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
29+
where
30+
A: PartialEq<B>,
31+
{
32+
VecDeque::<A>::new()
33+
}
34+
35+
pub fn no_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]>
36+
//~^ ERROR arrays only have std trait implementations for lengths 0..=32
37+
where
38+
A: PartialEq<B>,
39+
{
40+
VecDeque::<A>::new()
41+
}
42+
43+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
2+
--> $DIR/alloc-traits-no-impls-length-33.rs:1:43
3+
|
4+
LL | pub fn no_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
6+
|
7+
= note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::vec::Vec<A>`
8+
= note: the return type of a function must have a statically known size
9+
10+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
11+
--> $DIR/alloc-traits-no-impls-length-33.rs:9:51
12+
|
13+
LL | pub fn no_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
15+
|
16+
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::vec::Vec<A>`
17+
= note: the return type of a function must have a statically known size
18+
19+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
20+
--> $DIR/alloc-traits-no-impls-length-33.rs:19:48
21+
|
22+
LL | pub fn no_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 33]>
23+
| ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
24+
|
25+
= note: required because of the requirements on the impl of `std::cmp::PartialEq<[B; 33]>` for `std::collections::VecDeque<A>`
26+
= note: the return type of a function must have a statically known size
27+
28+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
29+
--> $DIR/alloc-traits-no-impls-length-33.rs:27:56
30+
|
31+
LL | pub fn no_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 33]>
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
33+
|
34+
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a [B; 33]>` for `std::collections::VecDeque<A>`
35+
= note: the return type of a function must have a statically known size
36+
37+
error[E0277]: arrays only have std trait implementations for lengths 0..=32
38+
--> $DIR/alloc-traits-no-impls-length-33.rs:35:60
39+
|
40+
LL | pub fn no_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 33]>
41+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[B; 33]`
42+
|
43+
= note: required because of the requirements on the impl of `std::cmp::PartialEq<&'a mut [B; 33]>` for `std::collections::VecDeque<A>`
44+
= note: the return type of a function must have a statically known size
45+
46+
error: aborting due to 5 previous errors
47+
48+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)