[types] Replace conditional derive(thiserror::Error) with unconditional impl. (#8384)

This commit is contained in:
Kevin Reid 2025-10-20 13:27:57 -07:00 committed by GitHub
parent 4ea04a69c9
commit f366e9615f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 13 deletions

View File

@ -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) - 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). - 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). - 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 #### DX12

1
Cargo.lock generated
View File

@ -5053,7 +5053,6 @@ dependencies = [
"log", "log",
"serde", "serde",
"serde_json", "serde_json",
"thiserror 2.0.17",
"web-sys", "web-sys",
] ]

View File

@ -37,7 +37,7 @@ alloc_instead_of_core = "warn"
[features] [features]
default = ["std"] default = ["std"]
std = ["js-sys?/std", "web-sys?/std", "thiserror/std"] std = ["js-sys?/std", "web-sys?/std"]
strict_asserts = [] strict_asserts = []
fragile-send-sync-non-atomic-wasm = [] fragile-send-sync-non-atomic-wasm = []
serde = ["dep:serde", "bitflags/serde"] serde = ["dep:serde", "bitflags/serde"]
@ -52,7 +52,6 @@ web = ["dep:js-sys", "dep:web-sys"]
bitflags.workspace = true bitflags.workspace = true
bytemuck = { workspace = true, features = ["derive"] } bytemuck = { workspace = true, features = ["derive"] }
log.workspace = true log.workspace = true
thiserror = { workspace = true, optional = true }
serde = { workspace = true, default-features = false, features = [ serde = { workspace = true, default-features = false, features = [
"alloc", "alloc",
"derive", "derive",

View File

@ -4564,24 +4564,35 @@ impl<T> PollType<T> {
} }
} }
/// Error states after a device poll /// Error states after a device poll.
#[derive(Debug)] #[derive(Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
pub enum PollError { pub enum PollError {
/// The requested Wait timed out before the submission was completed. /// 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, Timeout,
/// The requested Wait was given a wrong submission index. /// 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), 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. /// Status of device poll operation.
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
pub enum PollStatus { pub enum PollStatus {