rust/tests/ui/impl-trait/in-trait/object-safety.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
527 B
Rust
Raw Normal View History

2022-09-11 04:13:55 -05:00
#![feature(return_position_impl_trait_in_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
trait Foo {
fn baz(&self) -> impl Debug;
}
impl Foo for u32 {
fn baz(&self) -> u32 {
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
2023-08-08 14:37:35 -05:00
//~| ERROR the trait bound `dyn Foo: Foo`
2022-09-11 04:13:55 -05:00
}