From 7e00abf651efb967c3eee5a94c0185f98aa8527c Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sat, 6 Nov 2021 17:17:08 -0400 Subject: [PATCH] Manually implement Error for ShaderError (#2160) --- wgpu-core/src/pipeline.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index 36b55dc20..2436f8cf2 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -5,7 +5,7 @@ use crate::{ id::{DeviceId, PipelineLayoutId, ShaderModuleId}, validation, Label, LifeGuard, Stored, }; -use std::{borrow::Cow, fmt}; +use std::{borrow::Cow, error::Error, fmt}; use thiserror::Error; #[allow(clippy::large_enum_variant)] @@ -46,11 +46,10 @@ impl Resource for ShaderModule { } } -#[derive(Clone, Debug, Error)] +#[derive(Clone, Debug)] pub struct ShaderError { pub source: String, pub label: Option, - #[source] pub inner: E, } impl fmt::Display for ShaderError { @@ -91,6 +90,15 @@ impl fmt::Display for ShaderError> ) } } +impl Error for ShaderError +where + ShaderError: fmt::Display, + E: Error + 'static, +{ + fn source(&self) -> Option<&(dyn Error + 'static)> { + Some(&self.inner) + } +} //Note: `Clone` would require `WithSpan: Clone`. #[derive(Debug, Error)]