about summary refs log tree commit diff
path: root/tests/ui/unsized-locals/by-value-trait-dyn-compatibility.rs
blob: d390f18c69f5b273b4b615d3edab9a0578c412fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pub trait Foo {
    fn foo(self) -> String
    where
        Self: Sized;
}

struct A;

impl Foo for A {
    fn foo(self) -> String {
        format!("hello")
    }
}

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 [E0277]
    x.foo();
    //~^ERROR the `foo` method cannot be invoked on a trait object
}