about summary refs log tree commit diff
path: root/tests/ui/impl-trait/non-defining-uses/call-expr-incorrect-choice-diagnostics.rs
blob: 1d73985f78a12ff7a53f9d0958a125bd681ba7a0 (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
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)

// Testing the errors in case we've made a wrong choice when
// calling an opaque.

use std::ops::Deref;

fn item_bound_is_too_weak() -> impl FnOnce() {
    if false {
        let mut var = item_bound_is_too_weak();
        var();
        var();
        //~^ ERROR use of moved value: `var`
    }

    let mut state = String::new();
    move || state.push('a')
}

fn opaque_type_no_impl_fn() -> impl Sized {
    if false {
        opaque_type_no_impl_fn()();
        //[current]~^ ERROR expected function, found `impl Sized`
        //[next]~^^ ERROR expected function, found `_`
    }

    1
}

fn opaque_type_no_impl_fn_incorrect() -> impl Sized {
    if false {
        opaque_type_no_impl_fn_incorrect()();
        //[current]~^ ERROR expected function, found `impl Sized`
        //[next]~^^ ERROR expected function, found `_`
    }

    || ()
}

fn opaque_type_deref_no_impl_fn() -> impl Deref<Target = impl Sized> {
    if false {
        opaque_type_deref_no_impl_fn()();
        //[current]~^ ERROR expected function, found `impl Deref<Target = impl Sized>`
        //[next]~^^ ERROR expected function, found `_`
    }

    &1
}

fn main() {}