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