rust/tests/ui/unsized-locals/by-value-trait-object-safety.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
388 B
Rust
Raw Normal View History

2018-09-11 10:19:09 -05:00
#![feature(unsized_locals)]
2020-05-23 07:35:22 -05:00
//~^ WARN the feature `unsized_locals` is incomplete
2018-09-11 10:19:09 -05:00
pub trait Foo {
fn foo(self) -> String
where
Self: Sized;
2018-09-11 10:19:09 -05:00
}
struct A;
impl Foo for A {
fn foo(self) -> String {
format!("hello")
}
}
fn main() {
let x = *(Box::new(A) as Box<dyn Foo>);
x.foo();
//~^ERROR the `foo` method cannot be invoked on a trait object
}