about summary refs log tree commit diff
path: root/tests/ui/parallel-rustc/undefined-function-issue-120760.rs
blob: 2665c30945b96970cbb76f551169be9c27fba35a (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Test for #120760, which causes an ice bug: no index for a field
//
//@ compile-flags: -Z threads=45
//@ edition: 2021
//@ compare-output-by-lines

type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output = T>>>;

fn main() {
    let _ = f();
}

async fn f() {
    run("dependency").await; //~ ERROR cannot find function `run` in this scope
}

struct InMemoryStorage;

pub struct User<'dep> {
    pub name: &'a str, //~ ERROR use of undeclared lifetime name `'a`
}

impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> {
    fn execute(&self) -> BoxFuture<Result<(), String>> {
        todo!()
    }
}

trait Storage {
    type Error;
}

impl Storage for InMemoryStorage {
    type Error = String;
}

trait StorageRequestReturnType {
    type Output;
}

trait StorageRequest<S: Storage>: StorageRequestReturnType {
    fn execute(
        &self,
    ) -> BoxFuture<Result<<SaveUser as StorageRequestReturnType>::Output, <S as Storage>::Error>>;
}

pub struct SaveUser<'a> {
    pub name: &'a str,
}

impl<'a> StorageRequestReturnType for SaveUser<'a> {
    type Output = ();
}

impl<'dep> User<'dep> {
    async fn save<S>(self)
    where
        S: Storage,
        for<'a> SaveUser<'a>: StorageRequest<S>,
    {
        let _ = run("dependency").await; //~ ERROR cannot find function `run` in this scope
    }
}

async fn execute<S>(dep: &str)
where
    S: Storage,
    for<'a> SaveUser<'a>: StorageRequest<S>,
{
    User { dep }.save().await; //~ ERROR struct `User<'_>` has no field named `dep`
}