summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver/fn-trait.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/ui/traits/new-solver/fn-trait.rs
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/ui/traits/new-solver/fn-trait.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/ui/traits/new-solver/fn-trait.rs b/tests/ui/traits/new-solver/fn-trait.rs
index d566ead10..0599e51d7 100644
--- a/tests/ui/traits/new-solver/fn-trait.rs
+++ b/tests/ui/traits/new-solver/fn-trait.rs
@@ -1,5 +1,4 @@
// compile-flags: -Ztrait-solver=next
-// check-pass
fn require_fn(_: impl Fn() -> i32) {}
@@ -7,7 +6,27 @@ 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`
}