about summary refs log tree commit diff
path: root/tests/ui/impl-trait/unsized_coercion5.rs
blob: 85d313caa13556d6b9b3d0e97bed4c3a0a4dc4ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! This test checks that opaque types get unsized instead of
//! constraining their hidden type to a trait object.

//@ revisions: next old
//@[next] compile-flags: -Znext-solver

#![feature(trait_upcasting)]

trait Trait {}

impl Trait for u32 {}

fn hello() -> Box<impl Trait + ?Sized> {
    if true {
        let x = hello();
        let y: Box<dyn Send> = x as Box<dyn Trait + Send>;
        //[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
        //~^^ ERROR: mismatched types
    }
    Box::new(1u32)
}

fn main() {}