summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver/fn-trait.rs
blob: 0a19e626553485edc1796b99b25a24338e0e23e9 (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
// compile-flags: -Ztrait-solver=next

fn require_fn(_: impl Fn() -> i32) {}

fn f() -> i32 {
    1i32
}

extern "C" fn g() -> i32 {
    2i32
}

unsafe fn h() -> i32 {
    2i32
}

fn main() {
    require_fn(f);
    require_fn(f as fn() -> i32);
    require_fn(f as unsafe fn() -> i32);
    //~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32`
    //~| ERROR: type mismatch resolving `<unsafe fn() -> i32 as FnOnce<()>>::Output == i32`
    require_fn(g);
    //~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32 {g}`
    //~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32`
    require_fn(g as extern "C" fn() -> i32);
    //~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32`
    //~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32`
    require_fn(h);
    //~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32 {h}`
    //~| ERROR: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32`
}