From 8e210a888dc95537b5284989d8400193be0f1e3b Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Tue, 18 Jul 2023 10:14:31 -0700 Subject: [PATCH] Derive Debug for ProxyVTable This is now possible since we use the latest Rust toolchain. PiperOrigin-RevId: 549038928 --- rust/optional.rs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/rust/optional.rs b/rust/optional.rs index c2d2b5dad7..bdbc5ec4d2 100644 --- a/rust/optional.rs +++ b/rust/optional.rs @@ -505,6 +505,7 @@ mod tests { msg.presence & (1 << B_BIT) != 0 } + #[derive(Debug)] struct ProxyVtable { get: fn(&MyMessage) -> i32, set: fn(&mut MyMessage, val: i32), @@ -512,21 +513,6 @@ mod tests { has: fn(&MyMessage) -> bool, } - impl Debug for ProxyVtable { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // Manual `Debug` impl to work around `fmt::Debug` not being implemented for - // functions pointers with higher-ranked lifetimes, which was fixed - // in Rust 1.70. - // TODO(hlopko): replace with `#[derive(Debug)]` when rustc is updated. - f.debug_struct("ProxyVtable") - .field("get", &(self.get as *const ())) - .field("set", &(self.set as *const ())) - .field("clear", &(self.clear as *const ())) - .field("has", &(self.has as *const ())) - .finish() - } - } - /// A proxy for a `i32` that is accessed through methods on a vtable. struct VtableProxied;