about summary refs log tree commit diff
path: root/tests/ui/async-await/higher-ranked-auto-trait-4.rs
blob: 0586af41e9e25f2060729dd9d5b0eeae4140eba8 (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
// Repro for <https://github.com/rust-lang/rust/issues/102211#issuecomment-2891975128>.
//@ edition: 2021
//@ revisions: assumptions no_assumptions
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
//@[assumptions] check-pass
//@[no_assumptions] known-bug: #110338

use std::future::Future;

trait BoringTrait {}

trait TraitWithAssocType<I> {
    type Assoc;
}

impl<T> TraitWithAssocType<()> for T
where
    T: ?Sized + 'static,
{
    type Assoc = ();
}

fn evil_function<T: TraitWithAssocType<I> + ?Sized, I>()
-> impl Future<Output = Result<(), T::Assoc>> {
    async { Ok(()) }
}

fn fails_to_compile() -> impl std::future::Future<Output = ()> + Send {
    async {
        let _ = evil_function::<dyn BoringTrait, _>().await;
    }
}

fn main() {}