From 2e8a600e353cde43ec3c68fa75680ca80d4f7434 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 26 Jul 2025 08:50:58 -0700 Subject: [PATCH] Add `Sync` bound to uncaptured error handler. It makes sense for a function to be `FnMut + Send`, or `Fn + Send + Sync`, but not `Fn + Send` because that is overly restrictive for the caller and the callee. --- CHANGELOG.md | 2 ++ wgpu/src/api/device.rs | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64973330b..1c0a30a74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,8 @@ By @Vecvec in [#7913](https://github.com/gfx-rs/wgpu/pull/7913). - Copies of depth/stencil formats must be 4B aligned. - The offset for `set_vertex_buffer` and `set_index_buffer` must be 4B aligned. By @andyleiserson in [#7929](https://github.com/gfx-rs/wgpu/pull/7929). - The offset and size of bindings are validated as fitting within the underlying buffer in more cases. By @andyleiserson in [#7911](https://github.com/gfx-rs/wgpu/pull/7911). +- The function you pass to `Device::on_uncaptured_error()` must now implement `Sync` in addition to `Send`. + By @kpreid in [#8011](https://github.com/gfx-rs/wgpu/pull/8011). #### Naga diff --git a/wgpu/src/api/device.rs b/wgpu/src/api/device.rs index 401431bcb..8e0e372dd 100644 --- a/wgpu/src/api/device.rs +++ b/wgpu/src/api/device.rs @@ -714,9 +714,11 @@ impl From for RequestDeviceError { } } -/// Type for the callback of uncaptured error handler -pub trait UncapturedErrorHandler: Fn(Error) + Send + 'static {} -impl UncapturedErrorHandler for T where T: Fn(Error) + Send + 'static {} +/// The callback of [`Device::on_uncaptured_error()`]. +/// +/// It must be a function with this signature. +pub trait UncapturedErrorHandler: Fn(Error) + Send + Sync + 'static {} +impl UncapturedErrorHandler for T where T: Fn(Error) + Send + Sync + 'static {} /// Kinds of [`Error`]s a [`Device::push_error_scope()`] may be configured to catch. #[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd)]