From 65db613b6ef6ea81eb662820d815dfaa36d86187 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Fri, 22 Aug 2025 12:35:58 +0200 Subject: [PATCH] gccrs: Add fn pointer implementation test gcc/testsuite/ChangeLog: * rust/compile/impl_fnptr.rs: New test. Signed-off-by: Pierre-Emmanuel Patry --- gcc/testsuite/rust/compile/impl_fnptr.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 gcc/testsuite/rust/compile/impl_fnptr.rs diff --git a/gcc/testsuite/rust/compile/impl_fnptr.rs b/gcc/testsuite/rust/compile/impl_fnptr.rs new file mode 100644 index 00000000000..20c9d88dc1a --- /dev/null +++ b/gcc/testsuite/rust/compile/impl_fnptr.rs @@ -0,0 +1,18 @@ +#[lang = "sized"] +pub trait Sized {} + +#[lang = "eq"] +pub trait PartialEq { + fn eq(&self, other: &Rhs) -> bool; + + fn ne(&self, other: &Rhs) -> bool { + !self.eq(other) + } +} + +impl PartialEq for extern "C" fn() -> Ret { + #[inline] + fn eq(&self, other: &Self) -> bool { + *self as usize == *other as usize + } +} -- 2.47.3