From 41afbe0111d72db1748fd2aea34f6ccdc15befbe Mon Sep 17 00:00:00 2001 From: kyren Date: Wed, 19 Jul 2023 16:21:32 -0400 Subject: [PATCH] Backport #3801 to v0.16 (Implement Send and Sync for `Id` again) (#3933) --- CHANGELOG.md | 8 ++++++++ wgpu/src/lib.rs | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccb3d40c4..ffea17bef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,14 @@ Bottom level categories: ## Unreleased +## v0.16.3 (2023-07-17) + +### Changes + +#### General + +- Make the `Id` type that is exposed when using the `expose-ids` feature implement `Send` and `Sync` again. This was unintentionally changed by the v0.16.0 release and is now fixed. + ## v0.16.2 (2023-07-09) ### Changes diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index ea2609891..2f100b722 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -4251,6 +4251,15 @@ impl Surface { #[repr(transparent)] pub struct Id(core::num::NonZeroU64, std::marker::PhantomData<*mut T>); +// SAFETY: `Id` is a bare `NonZeroU64`, the type parameter is a marker purely to avoid confusing Ids +// returned for different types , so `Id` can safely implement Send and Sync. +#[cfg(feature = "expose-ids")] +unsafe impl Send for Id {} + +// SAFETY: See the implementation for `Send`. +#[cfg(feature = "expose-ids")] +unsafe impl Sync for Id {} + #[cfg(feature = "expose-ids")] impl Clone for Id { fn clone(&self) -> Self {