From 1f10d0ce8a25e69d2c5f7c4b45bb47d5a744c291 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Wed, 24 Sep 2025 19:42:24 -0700 Subject: [PATCH] [naga] Don't report shader errors as their own source (#8258) --- CHANGELOG.md | 1 + naga/src/error.rs | 2 +- naga/src/front/glsl/error.rs | 6 +----- naga/src/front/wgsl/error.rs | 6 +----- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c22134b2b..a0f60c9ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -197,6 +197,7 @@ By @cwfitzgerald in [#8162](https://github.com/gfx-rs/wgpu/pull/8162). - Add f16 IO polyfill on Vulkan backend to enable SHADER_F16 use without requiring `storageInputOutput16`. By @cryvosh in [#7884](https://github.com/gfx-rs/wgpu/pull/7884). - For custom Naga backend authors: `naga::proc::Namer` now accepts reserved keywords using two new dedicated types, `proc::{KeywordSet, CaseInsensitiveKeywordSet}`. By @kpreid in [#8136](https://github.com/gfx-rs/wgpu/pull/8136). - **BREAKING**: Previously the WGSL storage-texture format `rg11b10float` was incorrectly accepted and generated by naga, but now only accepts the the correct name `rg11b10ufloat` instead. By @ErikWDev in [#8219](https://github.com/gfx-rs/wgpu/pull/8219). +- The [`source()`](https://doc.rust-lang.org/std/error/trait.Error.html#method.source) method of `ShaderError` no longer reports the error as its own source. By @andyleiserson in [#8258](https://github.com/gfx-rs/wgpu/pull/8258). #### DX12 diff --git a/naga/src/error.rs b/naga/src/error.rs index a48556067..282cb6c88 100644 --- a/naga/src/error.rs +++ b/naga/src/error.rs @@ -134,7 +134,7 @@ where E: Error + 'static, { fn source(&self) -> Option<&(dyn Error + 'static)> { - Some(&self.inner) + self.inner.source() } } diff --git a/naga/src/front/glsl/error.rs b/naga/src/front/glsl/error.rs index 1fb15ef03..9c9e58549 100644 --- a/naga/src/front/glsl/error.rs +++ b/naga/src/front/glsl/error.rs @@ -198,11 +198,7 @@ impl core::fmt::Display for ParseErrors { } } -impl core::error::Error for ParseErrors { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - None - } -} +impl core::error::Error for ParseErrors {} impl From> for ParseErrors { fn from(errors: Vec) -> Self { diff --git a/naga/src/front/wgsl/error.rs b/naga/src/front/wgsl/error.rs index 1cdf53f37..17dab5cb0 100644 --- a/naga/src/front/wgsl/error.rs +++ b/naga/src/front/wgsl/error.rs @@ -127,11 +127,7 @@ impl core::fmt::Display for ParseError { } } -impl core::error::Error for ParseError { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { - None - } -} +impl core::error::Error for ParseError {} #[derive(Copy, Clone, Debug, PartialEq)] pub enum ExpectedToken<'a> {