2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2016-06-22 19:30:01 -05:00
|
|
|
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>;
|
2016-06-22 19:30:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 15:36:03 -05:00
|
|
|
struct Map<A>(#[allow(unused_tuple_struct_fields)] A);
|
2016-06-22 19:30:01 -05:00
|
|
|
impl<A: Future> Future for Map<A> {}
|
|
|
|
|
|
|
|
pub struct Promise;
|
|
|
|
impl Future for Promise {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
Promise.forget();
|
|
|
|
}
|