]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add fn pointer implementation test
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fri, 22 Aug 2025 10:35:58 +0000 (12:35 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:43 +0000 (20:58 +0100)
gcc/testsuite/ChangeLog:

* rust/compile/impl_fnptr.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/testsuite/rust/compile/impl_fnptr.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/impl_fnptr.rs b/gcc/testsuite/rust/compile/impl_fnptr.rs
new file mode 100644 (file)
index 0000000..20c9d88
--- /dev/null
@@ -0,0 +1,18 @@
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "eq"]
+pub trait PartialEq<Rhs: ?Sized = Self> {
+    fn eq(&self, other: &Rhs) -> bool;
+
+    fn ne(&self, other: &Rhs) -> bool {
+        !self.eq(other)
+    }
+}
+
+impl<Ret> PartialEq for extern "C" fn() -> Ret {
+    #[inline]
+    fn eq(&self, other: &Self) -> bool {
+        *self as usize == *other as usize
+    }
+}