about summary refs log tree commit diff
path: root/tests/ui/unsized-locals/by-value-trait-dyn-compatibility-with-default.rs
blob: 554c2706e1eb4dcfb792b9c4d0517a4de6ccb7b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#![allow(internal_features)]
#![feature(unsized_fn_params)]

pub trait Foo {
    fn foo(self) -> String {
        format!("hello")
    }
}

struct A;

impl Foo for A {}

fn main() {
    let x = *(Box::new(A) as Box<dyn Foo>); //~ERROR the size for values of type `dyn Foo` cannot be known at compilation time
    assert_eq!(x.foo(), format!("hello"));

    // I'm not sure whether we want this to work
    let x = Box::new(A) as Box<dyn Foo>;
    assert_eq!(x.foo(), format!("hello"));
}