From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../unboxed-closures/unboxed-closures-wrong-abi.rs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/ui/unboxed-closures/unboxed-closures-wrong-abi.rs (limited to 'tests/ui/unboxed-closures/unboxed-closures-wrong-abi.rs') diff --git a/tests/ui/unboxed-closures/unboxed-closures-wrong-abi.rs b/tests/ui/unboxed-closures/unboxed-closures-wrong-abi.rs new file mode 100644 index 000000000..dd76c597d --- /dev/null +++ b/tests/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