diff options
Diffstat (limited to 'tests/ui/sized-hierarchy/pretty-print-opaque.rs')
| -rw-r--r-- | tests/ui/sized-hierarchy/pretty-print-opaque.rs | 45 | 
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/ui/sized-hierarchy/pretty-print-opaque.rs b/tests/ui/sized-hierarchy/pretty-print-opaque.rs new file mode 100644 index 00000000000..2aceee23a01 --- /dev/null +++ b/tests/ui/sized-hierarchy/pretty-print-opaque.rs @@ -0,0 +1,45 @@ +//@ compile-flags: --crate-type=lib +#![feature(sized_hierarchy)] + +use std::marker::{MetaSized, PointeeSized}; + +pub trait Tr: PointeeSized {} +impl Tr for u32 {} + +pub fn sized() -> Box<impl Tr + Sized> { + if true { + let x = sized(); + let y: Box<dyn Tr> = x; + } + Box::new(1u32) +} + +pub fn neg_sized() -> Box<impl Tr + ?Sized> { + if true { + let x = neg_sized(); + let y: Box<dyn Tr> = x; +//~^ ERROR: the size for values of type `impl Tr + MetaSized` cannot be known + } + Box::new(1u32) +} + +pub fn metasized() -> Box<impl Tr + MetaSized> { + if true { + let x = metasized(); + let y: Box<dyn Tr> = x; +//~^ ERROR: the size for values of type `impl Tr + MetaSized` cannot be known + } + Box::new(1u32) +} + +pub fn pointeesized() -> Box<impl Tr + PointeeSized> { +//~^ ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known + if true { + let x = pointeesized(); +//~^ ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known + let y: Box<dyn Tr> = x; +//~^ ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known +//~| ERROR: the size for values of type `impl Tr + PointeeSized` cannot be known + } + Box::new(1u32) +}  | 
