From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../unboxed-closures/unboxed-closures-wrong-abi.rs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.rs (limited to 'src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.rs') diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.rs b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.rs new file mode 100644 index 000000000..dd76c597d --- /dev/null +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.rs @@ -0,0 +1,34 @@ +// Tests that unsafe extern fn pointers do not implement any Fn traits. + +use std::ops::{Fn, FnMut, FnOnce}; + +extern "C" fn square(x: &isize) -> isize { + (*x) * (*x) +} + +fn call_it isize>(_: &F, _: isize) -> isize { + 0 +} +fn call_it_mut isize>(_: &mut F, _: isize) -> isize { + 0 +} +fn call_it_once isize>(_: F, _: isize) -> isize { + 0 +} + +fn a() { + let x = call_it(&square, 22); + //~^ ERROR E0277 +} + +fn b() { + let y = call_it_mut(&mut square, 22); + //~^ ERROR E0277 +} + +fn c() { + let z = call_it_once(square, 22); + //~^ ERROR E0277 +} + +fn main() {} -- cgit v1.2.3