about summary refs log tree commit diff
path: root/tests/ui/async-await/higher-ranked-auto-trait-17.rs
blob: 152432466c005120b9ed793d51ed07cd87546818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Repro for <https://github.com/rust-lang/rust/issues/114177#issue-1826550174>.
//@ edition: 2021
//@ revisions: assumptions no_assumptions
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
//@[assumptions] check-pass
//@[no_assumptions] known-bug: #110338

// Using `impl Future` instead of `async to ensure that the Future is Send.
//
// In the original code `a` would be `&[T]`. For more minimization I've removed the reference.
fn foo(a: [(); 0]) -> impl std::future::Future<Output = ()> + Send {
    async move {
        let iter = Adaptor::new(a.iter().map(|_: &()| {}));
        std::future::pending::<()>().await;
        drop(iter);
    }
}

struct Adaptor<T: Iterator> {
    iter: T,
    v: T::Item,
}

impl<T: Iterator> Adaptor<T> {
    pub fn new(_: T) -> Self {
        Self { iter: todo!(), v: todo!() }
    }
}

fn main() {}