]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/unsized-local.rs
add a weak form of protection that justifies Box noalias
[rust.git] / src / tools / miri / tests / fail / unsized-local.rs
1 #![feature(unsized_locals)]
2 #![allow(incomplete_features)]
3
4 fn main() {
5     pub trait Foo {
6         fn foo(self) -> String;
7     }
8
9     struct A;
10
11     impl Foo for A {
12         fn foo(self) -> String {
13             format!("hello")
14         }
15     }
16
17     let x = *(Box::new(A) as Box<dyn Foo>); //~ERROR: unsized locals are not supported
18     assert_eq!(x.foo(), format!("hello"));
19
20     // I'm not sure whether we want this to work
21     let x = Box::new(A) as Box<dyn Foo>;
22     assert_eq!(x.foo(), format!("hello"));
23 }