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

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

24 lines
437 B
Rust
Raw Normal View History

//@ run-pass
#![allow(incomplete_features)]
2020-10-16 20:46:59 +00:00
#![feature(unsized_locals, unsized_fn_params)]
2018-09-11 15:19:09 +00:00
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>);
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"));
2018-09-11 15:19:09 +00:00
}