rust/tests/ui/impl-trait/in-trait/dyn-compatibility.rs

21 lines
436 B
Rust
Raw Normal View History

2022-09-11 09:13:55 +00:00
use std::fmt::Debug;
trait Foo {
fn baz(&self) -> impl Debug;
}
impl Foo for u32 {
2023-09-02 04:02:11 +00:00
fn baz(&self) -> impl Debug {
2022-09-11 09:13:55 +00:00
32
}
}
fn main() {
let i = Box::new(42_u32) as Box<dyn Foo>;
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
2022-09-11 09:13:55 +00:00
let s = i.baz();
//~^ ERROR the trait `Foo` is not dyn compatible
//~| ERROR the trait `Foo` is not dyn compatible
2022-09-11 09:13:55 +00:00
}