]> git.proxmox.com Git - rustc.git/blob - src/test/ui/traits/object/exclusion.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / 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 }