Skip to content

Commit

Permalink
Add tests for Vec(Deque) array PartialEq impls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Jul 28, 2019
1 parent 744ec88 commit bfdfa85
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// check-pass

pub fn yes_vec_partial_eq_array<A, B>() -> impl PartialEq<[B; 32]>
where
A: PartialEq<B>,
{
Vec::<A>::new()
}

pub fn yes_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
where
A: PartialEq<B>,
{
Vec::<A>::new()
}

use std::collections::VecDeque;

pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<[B; 32]>
where
A: PartialEq<B>,
{
VecDeque::<A>::new()
}

pub fn yes_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
where
A: PartialEq<B>,
{
VecDeque::<A>::new()
}

pub fn yes_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 32]>
where
A: PartialEq<B>,
{
VecDeque::<A>::new()
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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]`
|
= 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]`
|
= 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]`
|
= 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]`
|
= 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]`
|
= 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`.

0 comments on commit bfdfa85

Please sign in to comment.