about summary refs log tree commit diff
path: root/tests/ui/async-await/higher-ranked-normalize-assumptions.rs
blob: ec9cf3a152214a0c091b20c11f002fa82dc3ddeb (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//@ revisions: stock hr
//@[hr] compile-flags: -Zhigher-ranked-assumptions
//@ edition: 2024
//@ check-pass

// Test that we don't normalize the higher-ranked assumptions of an auto trait goal
// unless we have `-Zhigher-ranked-assumptions`, since obligations that result from
// this normalization may lead to higher-ranked lifetime errors when the flag is not
// enabled.

// Regression test for <https://github.com/rust-lang/rust/issues/147285>.

pub trait Service {
    type Response;
}

impl<T, R> Service for T
where
    T: FnMut() -> R,
    R: 'static,
{
    type Response = R;
}

async fn serve<C>(_: C)
where
    C: Service,
    C::Response: 'static,
{
    connect::<C>().await;
}

async fn connect<C>()
where
    C: Service,
    C::Response: 'static,
{
}

fn repro() -> impl Send {
    async {
        let server = || do_something();
        serve(server).await;
    }
}

fn do_something() -> Box<dyn std::error::Error> {
    unimplemented!()
}

fn main() {}