about summary refs log tree commit diff
path: root/tests/ui/sized-hierarchy/pretty-print-opaque.rs
blob: 2aceee23a017189f719729f216606ef02466cb0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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)
}