Skip to content

Commit

Permalink
Fix Send/Sync of RequestDeviceErrorKind (#7122)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald authored Feb 13, 2025
1 parent c4b25b8 commit c39d37f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 3 additions & 10 deletions wgpu/src/api/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,9 @@ pub(crate) enum RequestDeviceErrorKind {
///
/// (This is currently never used by the webgl backend, but it could be.)
#[cfg(webgpu)]
WebGpu(wasm_bindgen::JsValue),
WebGpu(String),
}

#[cfg(send_sync)]
unsafe impl Send for RequestDeviceErrorKind {}
#[cfg(send_sync)]
unsafe impl Sync for RequestDeviceErrorKind {}

#[cfg(send_sync)]
static_assertions::assert_impl_all!(RequestDeviceError: Send, Sync);

impl fmt::Display for RequestDeviceError {
Expand All @@ -547,9 +541,8 @@ impl fmt::Display for RequestDeviceError {
#[cfg(wgpu_core)]
RequestDeviceErrorKind::Core(error) => error.fmt(_f),
#[cfg(webgpu)]
RequestDeviceErrorKind::WebGpu(error_js_value) => {
// wasm-bindgen provides a reasonable error stringification via `Debug` impl
write!(_f, "{error_js_value:?}")
RequestDeviceErrorKind::WebGpu(error) => {
write!(_f, "{error}")
}
#[cfg(not(any(webgpu, wgpu_core)))]
_ => unimplemented!("unknown `RequestDeviceErrorKind`"),
Expand Down
3 changes: 2 additions & 1 deletion wgpu/src/backend/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,8 @@ fn future_request_device(
)
})
.map_err(|error_value| crate::RequestDeviceError {
inner: crate::RequestDeviceErrorKind::WebGpu(error_value),
// wasm-bindgen provides a reasonable error stringification via `Debug` impl
inner: crate::RequestDeviceErrorKind::WebGpu(format!("{error_value:?}")),
})
}

Expand Down

0 comments on commit c39d37f

Please sign in to comment.