mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
19 lines
397 B
Rust
19 lines
397 B
Rust
// Check that we do not allow casts or coercions
|
|
// to object unsafe trait objects inside a Box
|
|
|
|
#![feature(object_safe_for_dispatch)]
|
|
|
|
trait Trait: Sized {}
|
|
|
|
struct S;
|
|
|
|
impl Trait for S {}
|
|
|
|
fn takes_box(t: Box<dyn Trait>) {}
|
|
|
|
fn main() {
|
|
Box::new(S) as Box<dyn Trait>; //~ ERROR E0038
|
|
let t_box: Box<dyn Trait> = Box::new(S); //~ ERROR E0038
|
|
takes_box(Box::new(S)); //~ ERROR E0038
|
|
}
|