about summary refs log tree commit diff
path: root/tests/ui/impl-trait/non-defining-uses/function-call-on-infer.rs
blob: 9b9156ee4c7160e2ef0754b8de8ae1c896157b7f (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
72
73
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)
//@ check-pass

// Regression test for trait-system-refactor-initiative#181. Make sure calling
// opaque types works.

fn fn_trait() -> impl Fn() {
    if false {
        let f = fn_trait();
        f();
    }

    || ()
}

fn fn_trait_ref() -> impl Fn() {
    if false {
        let f = &fn_trait();
        f();
    }
    || ()
}

fn fn_mut() -> impl FnMut() -> usize {
    if false {
        let mut f = fn_mut();
        f();
    }

    let mut state = 0;
    move || {
        state += 1;
        state
    }
}

fn fn_mut_ref() -> impl FnMut() -> usize {
    if false {
        let mut f = &mut fn_mut();
        f();
    }

    let mut state = 0;
    move || {
        state += 1;
        state
    }
}


fn fn_once() -> impl FnOnce() {
    if false {
        let mut f = fn_once();
        f();
    }

    let string = String::new();
    move || drop(string)
}

fn fn_once_ref() -> impl FnOnce() {
    if false {
        let mut f = Box::new(fn_once_ref());
        f();
    }

    let string = String::new();
    move || drop(string)
}

fn main() {}