rust/tests/ui/traits/object/exclusion.rs

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

20 lines
503 B
Rust
Raw Normal View History

// run-pass
trait Future: 'static {
// The requirement for Self: Sized must prevent instantiation of
// Future::forget in vtables, otherwise there's an infinite type
// recursion through <Map<...> as Future>::forget.
fn forget(self) where Self: Sized {
2019-05-28 13:47:21 -05:00
Box::new(Map(self)) as Box<dyn Future>;
}
}
2022-07-25 15:36:03 -05:00
struct Map<A>(#[allow(unused_tuple_struct_fields)] A);
impl<A: Future> Future for Map<A> {}
pub struct Promise;
impl Future for Promise {}
fn main() {
Promise.forget();
}