From 32324d22c33dda31eadf49c5f27d6e6ff38a3ef1 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Tue, 4 Jun 2019 08:15:47 -0400 Subject: Add implementations for converting boxed slices into boxed arrays This mirrors the implementations of reference slices into arrays. --- .../array-impls/alloc-types-no-impls-length-33.rs | 26 ++++++++ .../alloc-types-no-impls-length-33.stderr | 75 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.rs create mode 100644 src/test/ui/const-generics/array-impls/alloc-types-no-impls-length-33.stderr (limited to 'src/test/ui/const-generics/array-impls') 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 = >::try_from(boxed_slice); + //~^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::From>` is not satisfied + //~^^ ERROR the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom>` is not satisfied +} + +pub fn no_rc() { + let boxed_slice = Rc::new([0; 33]) as Rc<[i32]>; + let boxed_array = >::try_from(boxed_slice); + //~^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From>` is not satisfied + //~^^ ERROR the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom>` is not satisfied +} + +pub fn no_arc() { + let boxed_slice = Arc::new([0; 33]) as Arc<[i32]>; + let boxed_array = >::try_from(boxed_slice); + //~^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From>` is not satisfied + //~^^ ERROR the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom>` 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>` is not satisfied + --> $DIR/alloc-types-no-impls-length-33.rs:7:23 + | +LL | let boxed_array = >::try_from(boxed_slice); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From>` is not implemented for `std::boxed::Box<[i32; 33]>` + | + = help: the following implementations were found: + as std::convert::From> + as std::convert::From<&str>> + as std::convert::From>> + as std::convert::From> + and 16 others + = note: required because of the requirements on the impl of `std::convert::Into>` for `std::boxed::Box<[i32]>` + = note: required because of the requirements on the impl of `std::convert::TryFrom>` for `std::boxed::Box<[i32; 33]>` + +error[E0277]: the trait bound `std::boxed::Box<[i32; 33]>: std::convert::TryFrom>` is not satisfied + --> $DIR/alloc-types-no-impls-length-33.rs:7:23 + | +LL | let boxed_array = >::try_from(boxed_slice); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::boxed::Box<[i32; 33]>` + | + = help: the following implementations were found: + as std::convert::TryFrom>> + +error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::From>` is not satisfied + --> $DIR/alloc-types-no-impls-length-33.rs:14:23 + | +LL | let boxed_array = >::try_from(boxed_slice); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From>` is not implemented for `std::rc::Rc<[i32; 33]>` + | + = help: the following implementations were found: + as std::convert::From> + as std::convert::From>> + as std::convert::From<&[T]>> + as std::convert::From>> + and 8 others + = note: required because of the requirements on the impl of `std::convert::Into>` for `std::rc::Rc<[i32]>` + = note: required because of the requirements on the impl of `std::convert::TryFrom>` for `std::rc::Rc<[i32; 33]>` + +error[E0277]: the trait bound `std::rc::Rc<[i32; 33]>: std::convert::TryFrom>` is not satisfied + --> $DIR/alloc-types-no-impls-length-33.rs:14:23 + | +LL | let boxed_array = >::try_from(boxed_slice); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::rc::Rc<[i32; 33]>` + | + = help: the following implementations were found: + as std::convert::TryFrom>> + +error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::From>` is not satisfied + --> $DIR/alloc-types-no-impls-length-33.rs:21:23 + | +LL | let boxed_array = >::try_from(boxed_slice); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From>` is not implemented for `std::sync::Arc<[i32; 33]>` + | + = help: the following implementations were found: + as std::convert::From> + as std::convert::From>> + as std::convert::From<&[T]>> + as std::convert::From>> + and 8 others + = note: required because of the requirements on the impl of `std::convert::Into>` for `std::sync::Arc<[i32]>` + = note: required because of the requirements on the impl of `std::convert::TryFrom>` for `std::sync::Arc<[i32; 33]>` + +error[E0277]: the trait bound `std::sync::Arc<[i32; 33]>: std::convert::TryFrom>` is not satisfied + --> $DIR/alloc-types-no-impls-length-33.rs:21:23 + | +LL | let boxed_array = >::try_from(boxed_slice); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::TryFrom>` is not implemented for `std::sync::Arc<[i32; 33]>` + | + = help: the following implementations were found: + as std::convert::TryFrom>> + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5