2023-12-14 06:11:28 -06:00
|
|
|
// compile-flags: -Znext-solver
|
2023-01-18 19:20:34 -06:00
|
|
|
|
|
|
|
fn require_fn(_: impl Fn() -> i32) {}
|
|
|
|
|
|
|
|
fn f() -> i32 {
|
|
|
|
1i32
|
|
|
|
}
|
|
|
|
|
2023-03-21 06:11:32 -05:00
|
|
|
extern "C" fn g() -> i32 {
|
|
|
|
2i32
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe fn h() -> i32 {
|
|
|
|
2i32
|
|
|
|
}
|
|
|
|
|
2023-01-18 19:20:34 -06:00
|
|
|
fn main() {
|
|
|
|
require_fn(f);
|
|
|
|
require_fn(f as fn() -> i32);
|
2023-03-21 06:11:32 -05:00
|
|
|
require_fn(f as unsafe fn() -> i32);
|
2023-10-04 20:50:00 -05:00
|
|
|
//~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32`
|
2023-03-21 06:11:32 -05:00
|
|
|
//~| ERROR: type mismatch resolving `<unsafe fn() -> i32 as FnOnce<()>>::Output == i32`
|
|
|
|
require_fn(g);
|
2023-10-04 20:50:00 -05:00
|
|
|
//~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32 {g}`
|
2023-03-21 06:44:36 -05:00
|
|
|
//~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32`
|
2023-03-21 06:11:32 -05:00
|
|
|
require_fn(g as extern "C" fn() -> i32);
|
2023-10-04 20:50:00 -05:00
|
|
|
//~^ ERROR: expected a `Fn()` closure, found `extern "C" fn() -> i32`
|
2023-03-21 06:11:32 -05:00
|
|
|
//~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32`
|
|
|
|
require_fn(h);
|
2023-10-04 20:50:00 -05:00
|
|
|
//~^ ERROR: expected a `Fn()` closure, found `unsafe fn() -> i32 {h}`
|
2023-03-21 06:44:36 -05:00
|
|
|
//~| ERROR: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32`
|
2023-01-18 19:20:34 -06:00
|
|
|
}
|