From 35b750ab9a9c4e70e80c4a795e9f51d9f83ee6fc Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 21 Jul 2022 16:16:23 -0700 Subject: [PATCH] Implement `std::fmt::Pointer` for `ExternRef` (#4504) --- crates/runtime/src/externref.rs | 6 ++++++ crates/wasmtime/src/ref.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/crates/runtime/src/externref.rs b/crates/runtime/src/externref.rs index 9477acd4fd65..4da7cc55d105 100644 --- a/crates/runtime/src/externref.rs +++ b/crates/runtime/src/externref.rs @@ -165,6 +165,12 @@ use wasmtime_environ::StackMap; #[repr(transparent)] pub struct VMExternRef(NonNull); +impl std::fmt::Pointer for VMExternRef { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Pointer::fmt(&self.0, f) + } +} + // Data contained is always Send+Sync so these should be safe. unsafe impl Send for VMExternRef {} unsafe impl Sync for VMExternRef {} diff --git a/crates/wasmtime/src/ref.rs b/crates/wasmtime/src/ref.rs index f999b96d80a2..7845a4f7ea7d 100644 --- a/crates/wasmtime/src/ref.rs +++ b/crates/wasmtime/src/ref.rs @@ -100,3 +100,9 @@ impl ExternRef { externref_ptr as usize } } + +impl std::fmt::Pointer for ExternRef { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Pointer::fmt(&self.inner, f) + } +}