From 2d699295ce735499b64e9e80f62e80afcd6dc7f9 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Thu, 2 Oct 2025 17:06:37 -0700 Subject: [PATCH] Restore `PointerId(...)` serialized representation --- wgpu-core/src/id.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/wgpu-core/src/id.rs b/wgpu-core/src/id.rs index a18510ef2..76b83e5fa 100644 --- a/wgpu-core/src/id.rs +++ b/wgpu-core/src/id.rs @@ -129,7 +129,10 @@ impl TryFrom for RawId { #[allow(dead_code)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug)] -pub struct PointerId(usize, #[serde(skip)] PhantomData); +pub enum PointerId { + // The only variant forces RON to not ignore "Id" + PointerId(usize, #[serde(skip)] PhantomData), +} impl Copy for PointerId {} @@ -141,7 +144,9 @@ impl Clone for PointerId { impl PartialEq for PointerId { fn eq(&self, other: &Self) -> bool { - self.0 == other.0 + let PointerId::PointerId(this, _) = self; + let PointerId::PointerId(other, _) = other; + this == other } } @@ -149,7 +154,8 @@ impl Eq for PointerId {} impl Hash for PointerId { fn hash(&self, state: &mut H) { - self.0.hash(state); + let PointerId::PointerId(this, _) = self; + this.hash(state); } } @@ -161,7 +167,7 @@ impl From<&Arc> for PointerId { // Unfortunately, because `Arc::as_ptr` returns a pointer to the // contained data, and `Arc` stores reference counts before the data, // we are adding an offset to the pointer here. - Self(Arc::as_ptr(arc) as usize, PhantomData) + PointerId::PointerId(Arc::as_ptr(arc) as usize, PhantomData) } }