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
436 B
Rust
Raw Normal View History

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