rust/tests/ui/impl-trait/in-trait/object-safety.rs
2023-10-13 21:01:36 +00:00

23 lines
500 B
Rust

#![allow(incomplete_features)]
use std::fmt::Debug;
trait Foo {
fn baz(&self) -> impl Debug;
}
impl Foo for u32 {
fn baz(&self) -> impl Debug {
32
}
}
fn main() {
let i = Box::new(42_u32) as Box<dyn Foo>;
//~^ ERROR the trait `Foo` cannot be made into an object
//~| ERROR the trait `Foo` cannot be made into an object
let s = i.baz();
//~^ ERROR the trait `Foo` cannot be made into an object
//~| ERROR the trait `Foo` cannot be made into an object
}