about summary refs log tree commit diff
path: root/tests/ui/async-await/higher-ranked-auto-trait-10.rs
blob: 4bfa27961abd0139721015044a302bc9e6206e7f (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
31
32
33
34
35
// Repro for <https://github.com/rust-lang/rust/issues/92415#issue-1090723521>.
//@ edition: 2021
//@ revisions: assumptions no_assumptions
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
//@[assumptions] known-bug: unknown
//@[no_assumptions] known-bug: #110338

use std::any::Any;
use std::future::Future;

trait Foo<'a>: Sized {
    type Error;
    fn foo(x: &'a str) -> Result<Self, Self::Error>;
}

impl<'a> Foo<'a> for &'a str {
    type Error = ();

    fn foo(x: &'a str) -> Result<Self, Self::Error> {
        Ok(x)
    }
}

async fn get_foo<'a, T>(x: &'a str) -> Result<T, <T as Foo<'a>>::Error>
where
    T: Foo<'a>,
{
    Foo::foo(x)
}

fn bar<'a>(x: &'a str) -> Box<dyn Future<Output = Result<&'a str, ()>> + Send + 'a> {
    Box::new(async move { get_foo(x).await })
}

fn main() {}