mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-24 15:54:00 +00:00
fix(naga): use Diagnostic
from inner
in valid. err. presentation
For some reason, the implementation of `Display` for `ShaderError<WithSpan<ValidationError>>>` is building its own `Diagnostic` with _only_ the labels populated: no messages or notes. I don't know why this is, but it seems to have a strict subset of the information already present in the private implementation of `WithSpan::diagnostic`. Fix this by exposing `WithSpan::diagnostic` as `pub(crate)`, and re-using its output in `impl Display for ShaderError<WithSpan<ValidationError>>>`.
This commit is contained in:
parent
36fab5ce3d
commit
6f43ee9f17
@ -86,6 +86,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).
|
||||
- Implemented `const_assert` in WGSL. By @sagudev in [#6198](https://github.com/gfx-rs/wgpu/pull/6198).
|
||||
- Support polyfilling `inverse` in WGSL. By @chyyran in [#6385](https://github.com/gfx-rs/wgpu/pull/6385).
|
||||
- Add an internal skeleton for parsing `requires`, `enable`, and `diagnostic` directives that don't yet do anything besides emit nicer errors. By @ErichDonGubler in [#6352](https://github.com/gfx-rs/wgpu/pull/6352).
|
||||
- Include error chain information as a message and notes in shader compilation messages. By @ErichDonGubler in [#6436](https://github.com/gfx-rs/wgpu/pull/6436).
|
||||
|
||||
#### General
|
||||
|
||||
|
@ -34,28 +34,14 @@ impl fmt::Display for ShaderError<crate::front::spv::Error> {
|
||||
}
|
||||
impl fmt::Display for ShaderError<crate::WithSpan<crate::valid::ValidationError>> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use codespan_reporting::{
|
||||
diagnostic::{Diagnostic, Label},
|
||||
files::SimpleFile,
|
||||
term,
|
||||
};
|
||||
use codespan_reporting::{files::SimpleFile, term};
|
||||
|
||||
let label = self.label.as_deref().unwrap_or_default();
|
||||
let files = SimpleFile::new(label, &self.source);
|
||||
let config = term::Config::default();
|
||||
let mut writer = termcolor::NoColor::new(Vec::new());
|
||||
|
||||
let diagnostic = Diagnostic::error().with_labels(
|
||||
self.inner
|
||||
.spans()
|
||||
.map(|&(span, ref desc)| {
|
||||
Label::primary((), span.to_range().unwrap()).with_message(desc.to_owned())
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
|
||||
term::emit(&mut writer, &config, &files, &diagnostic).expect("cannot write error");
|
||||
|
||||
term::emit(&mut writer, &config, &files, &self.inner.diagnostic())
|
||||
.expect("cannot write error");
|
||||
write!(
|
||||
f,
|
||||
"\nShader validation {}",
|
||||
|
@ -239,7 +239,7 @@ impl<E> WithSpan<E> {
|
||||
Some(self.spans[0].0.location(source))
|
||||
}
|
||||
|
||||
fn diagnostic(&self) -> codespan_reporting::diagnostic::Diagnostic<()>
|
||||
pub(crate) fn diagnostic(&self) -> codespan_reporting::diagnostic::Diagnostic<()>
|
||||
where
|
||||
E: Error,
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user