diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4265518..74336fe90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ SamplerDescriptor { - WebGPU device requests now support the required limits `maxColorAttachments` and `maxColorAttachmentBytesPerSample`. By @evilpie in [#8328](https://github.com/gfx-rs/wgpu/pull/8328) - Reject binding indices that exceed `wgpu_types::Limits::max_bindings_per_bind_group` when deriving a bind group layout for a pipeline. By @jimblandy in [#8325](https://github.com/gfx-rs/wgpu/pull/8325). - Removed three features from `wgpu-hal` which did nothing useful: `"cargo-clippy"`, `"gpu-allocator"`, and `"rustc-hash"`. By @kpreid in [#8357](https://github.com/gfx-rs/wgpu/pull/8357). +- `wgpu_types::PollError` now always implements the `Error` trait. By @kpreid in [#8384](https://github.com/gfx-rs/wgpu/pull/8384). #### DX12 diff --git a/Cargo.lock b/Cargo.lock index e0f65957f..361c31d38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5053,7 +5053,6 @@ dependencies = [ "log", "serde", "serde_json", - "thiserror 2.0.17", "web-sys", ] diff --git a/wgpu-types/Cargo.toml b/wgpu-types/Cargo.toml index 3aaadb9db..7bb971892 100644 --- a/wgpu-types/Cargo.toml +++ b/wgpu-types/Cargo.toml @@ -37,7 +37,7 @@ alloc_instead_of_core = "warn" [features] default = ["std"] -std = ["js-sys?/std", "web-sys?/std", "thiserror/std"] +std = ["js-sys?/std", "web-sys?/std"] strict_asserts = [] fragile-send-sync-non-atomic-wasm = [] serde = ["dep:serde", "bitflags/serde"] @@ -52,7 +52,6 @@ web = ["dep:js-sys", "dep:web-sys"] bitflags.workspace = true bytemuck = { workspace = true, features = ["derive"] } log.workspace = true -thiserror = { workspace = true, optional = true } serde = { workspace = true, default-features = false, features = [ "alloc", "derive", diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 234c907d9..1f00fc9cd 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -4564,24 +4564,35 @@ impl PollType { } } -/// Error states after a device poll +/// Error states after a device poll. #[derive(Debug)] -#[cfg_attr(feature = "std", derive(thiserror::Error))] pub enum PollError { /// The requested Wait timed out before the submission was completed. - #[cfg_attr( - feature = "std", - error("The requested Wait timed out before the submission was completed.") - )] Timeout, /// The requested Wait was given a wrong submission index. - #[cfg_attr( - feature = "std", - error("Tried to wait using a submission index ({0}) that has not been returned by a successful submission (last successful submission: {1})") - )] WrongSubmissionIndex(u64, u64), } +// This impl could be derived by `thiserror`, but by not doing so, we can reduce the number of +// dependencies this early in the dependency graph, which may improve build parallelism. +impl fmt::Display for PollError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + PollError::Timeout => { + f.write_str("The requested Wait timed out before the submission was completed.") + } + PollError::WrongSubmissionIndex(requested, successful) => write!( + f, + "Tried to wait using a submission index ({requested}) \ + that has not been returned by a successful submission \ + (last successful submission: {successful}" + ), + } + } +} + +impl core::error::Error for PollError {} + /// Status of device poll operation. #[derive(Debug, PartialEq, Eq)] pub enum PollStatus {