about summary refs log tree commit diff
path: root/src/test/ui/const-generics/array-impls
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-07-28 09:12:04 +0000
committerbors <bors@rust-lang.org>2019-07-28 09:12:04 +0000
commit0cfb2f7fbda1d27e12913d21d1c8e56a4133dbe1 (patch)
tree5f511147f1c0f419f26fb362c24710e1cd459ec6 /src/test/ui/const-generics/array-impls
parent9a239ef4ded03d155c72b68b5a2dd7aff013e141 (diff)
parent370aa19f28ea6d42f1aaf6de39a294e5e4e9aab7 (diff)
Auto merge of #63074 - Centril:rollup-k1a8z0n, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #62550 (Implement RFC 2707 + Parser recovery for range patterns)
 - #62759 (Actually add rustc-guide to toolstate, don't fail builds for the guide)
 - #62806 (Fix few Clippy warnings)
 - #62974 (bump crossbeam-epoch dependency)
 - #63051 (Avoid ICE when referencing desugared local binding in borrow error)
 - #63061 (In which we constantly improve the Vec(Deque) array PartialEq impls)
 - #63067 (Add test for issue-50900)
 - #63071 (Allow rustbot to add `F-*` + `requires-nightly`.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/test/ui/const-generics/array-impls')
-rw-r--r--src/test/ui/const-generics/array-impls/alloc-traits-impls-length-32.rs40
-rw-r--r--src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs43
-rw-r--r--src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr48
3 files changed, 131 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/array-impls/alloc-traits-impls-length-32.rs b/src/test/ui/const-generics/array-impls/alloc-traits-impls-length-32.rs
new file mode 100644
index 00000000000..db941a440e1
--- /dev/null
+++ b/src/test/ui/const-generics/array-impls/alloc-traits-impls-length-32.rs
@@ -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() {}
diff --git a/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs b/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs
new file mode 100644
index 00000000000..19107e6bf16
--- /dev/null
+++ b/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.rs
@@ -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() {}
diff --git a/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr
new file mode 100644
index 00000000000..5c37468130c
--- /dev/null
+++ b/src/test/ui/const-generics/array-impls/alloc-traits-no-impls-length-33.stderr
@@ -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`.