]> git.lizzy.rs Git - rust.git/blob - tests/ui/traits/object/exclusion.rs
Auto merge of #105716 - chriswailes:ndk-update-redux, r=pietroalbini
[rust.git] / tests / ui / traits / object / exclusion.rs
1 // run-pass
2 trait Future: 'static {
3     // The requirement for Self: Sized must prevent instantiation of
4     // Future::forget in vtables, otherwise there's an infinite type
5     // recursion through <Map<...> as Future>::forget.
6     fn forget(self) where Self: Sized {
7         Box::new(Map(self)) as Box<dyn Future>;
8     }
9 }
10
11 struct Map<A>(#[allow(unused_tuple_struct_fields)] A);
12 impl<A: Future> Future for Map<A> {}
13
14 pub struct Promise;
15 impl Future for Promise {}
16
17 fn main() {
18     Promise.forget();
19 }