summary refs log tree commit diff
path: root/src/test/ui/const-generics/array-impls
diff options
context:
space:
mode:
authorJake Goulding <jake.goulding@gmail.com>2019-06-04 08:15:47 -0400
committerJake Goulding <jake.goulding@gmail.com>2019-08-05 10:26:53 -0400
commit32324d22c33dda31eadf49c5f27d6e6ff38a3ef1 (patch)
tree4ceca954cd7f02dfd8000317f3021fb8e4e3dd35 /src/test/ui/const-generics/array-impls
parent4be067558962c004b638e4c6f162d50f7c0c98b6 (diff)
downloadrust-32324d22c33dda31eadf49c5f27d6e6ff38a3ef1.tar.gz
rust-32324d22c33dda31eadf49c5f27d6e6ff38a3ef1.zip
Add implementations for converting boxed slices into boxed arrays
This mirrors the implementations of reference slices into arrays.
Diffstat (limited to 'src/test/ui/const-generics/array-impls')
-rw-r--r--src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs26
-rw-r--r--src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr75
2 files changed, 101 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs
new file mode 100644
index 00000000000..3a23b9b5832
--- /dev/null
+++ b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs
@@ -0,0 +1,26 @@
+// ignore-tidy-linelength
+
+use std::{convert::TryFrom, rc::Rc, sync::Arc};
+
+pub fn no_box() {
+    let boxed_slice = Box::new([0; 33]) as Box<[i32]>;
+    let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
+    //~^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From<std::boxed::Box<[i32]>>` is not satisfied
+    //~^^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom<std::boxed::Box<[i32]>>` is not satisfied
+}
+
+pub fn no_rc() {
+    let boxed_slice = Rc::new([0; 33]) as Rc<[i32]>;
+    let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
+    //~^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From<std::rc::Rc<[i32]>>` is not satisfied
+    //~^^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom<std::rc::Rc<[i32]>>` is not satisfied
+}
+
+pub fn no_arc() {
+    let boxed_slice = Arc::new([0; 33]) as Arc<[i32]>;
+    let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
+    //~^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From<std::sync::Arc<[i32]>>` is not satisfied
+    //~^^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom<std::sync::Arc<[i32]>>` is not satisfied
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr
new file mode 100644
index 00000000000..193fb4c4374
--- /dev/null
+++ b/src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr
@@ -0,0 +1,75 @@
+error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From<std::boxed::Box<[i32]>>` is not satisfied
+  --> $DIR/alloc-types-no-impls-length-33.rs:7:23
+   |
+LL |     let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::boxed::Box<[i32]>>` is not implemented for `std::boxed::Box<[i32; 33]>`
+   |
+   = help: the following implementations were found:
+             <std::boxed::Box<(dyn std::error::Error + 'a)> as std::convert::From<E>>
+             <std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<&str>>
+             <std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::borrow::Cow<'a, str>>>
+             <std::boxed::Box<(dyn std::error::Error + 'static)> as std::convert::From<std::string::String>>
+           and 16 others
+   = note: required because of the requirements on the impl of `std::convert::Into<std::boxed::Box<[i32; 33]>>` for `std::boxed::Box<[i32]>`
+   = note: required because of the requirements on the impl of `std::convert::TryFrom<std::boxed::Box<[i32]>>` for `std::boxed::Box<[i32; 33]>`
+
+error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom<std::boxed::Box<[i32]>>` is not satisfied
+  --> $DIR/alloc-types-no-impls-length-33.rs:7:23
+   |
+LL |     let boxed_array = <Box<[i32; 33]>>::try_from(boxed_slice);
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::boxed::Box<[i32]>>` is not implemented for `std::boxed::Box<[i32; 33]>`
+   |
+   = help: the following implementations were found:
+             <std::boxed::Box<[T; _]> as std::convert::TryFrom<std::boxed::Box<[T]>>>
+
+error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From<std::rc::Rc<[i32]>>` is not satisfied
+  --> $DIR/alloc-types-no-impls-length-33.rs:14:23
+   |
+LL |     let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
+   |
+   = help: the following implementations were found:
+             <std::rc::Rc<T> as std::convert::From<T>>
+             <std::rc::Rc<T> as std::convert::From<std::boxed::Box<T>>>
+             <std::rc::Rc<[T]> as std::convert::From<&[T]>>
+             <std::rc::Rc<[T]> as std::convert::From<std::vec::Vec<T>>>
+           and 8 others
+   = note: required because of the requirements on the impl of `std::convert::Into<std::rc::Rc<[i32; 33]>>` for `std::rc::Rc<[i32]>`
+   = note: required because of the requirements on the impl of `std::convert::TryFrom<std::rc::Rc<[i32]>>` for `std::rc::Rc<[i32; 33]>`
+
+error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom<std::rc::Rc<[i32]>>` is not satisfied
+  --> $DIR/alloc-types-no-impls-length-33.rs:14:23
+   |
+LL |     let boxed_array = <Rc<[i32; 33]>>::try_from(boxed_slice);
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::rc::Rc<[i32]>>` is not implemented for `std::rc::Rc<[i32; 33]>`
+   |
+   = help: the following implementations were found:
+             <std::rc::Rc<[T; _]> as std::convert::TryFrom<std::rc::Rc<[T]>>>
+
+error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From<std::sync::Arc<[i32]>>` is not satisfied
+  --> $DIR/alloc-types-no-impls-length-33.rs:21:23
+   |
+LL |     let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
+   |
+   = help: the following implementations were found:
+             <std::sync::Arc<T> as std::convert::From<T>>
+             <std::sync::Arc<T> as std::convert::From<std::boxed::Box<T>>>
+             <std::sync::Arc<[T]> as std::convert::From<&[T]>>
+             <std::sync::Arc<[T]> as std::convert::From<std::vec::Vec<T>>>
+           and 8 others
+   = note: required because of the requirements on the impl of `std::convert::Into<std::sync::Arc<[i32; 33]>>` for `std::sync::Arc<[i32]>`
+   = note: required because of the requirements on the impl of `std::convert::TryFrom<std::sync::Arc<[i32]>>` for `std::sync::Arc<[i32; 33]>`
+
+error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom<std::sync::Arc<[i32]>>` is not satisfied
+  --> $DIR/alloc-types-no-impls-length-33.rs:21:23
+   |
+LL |     let boxed_array = <Arc<[i32; 33]>>::try_from(boxed_slice);
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom<std::sync::Arc<[i32]>>` is not implemented for `std::sync::Arc<[i32; 33]>`
+   |
+   = help: the following implementations were found:
+             <std::sync::Arc<[T; _]> as std::convert::TryFrom<std::sync::Arc<[T]>>>
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0277`.