Skip to content

Commit 6150576

Browse files
jimblandyErichDonGubler
authored andcommitted
[naga] Use TypeContext::write_type_resolution where appropriate.
Simplify the implementation of `Display` for `DiagnosticDisplay<(TypeResolution, GlobalCtx)>` by calling `GlobalCtx`'s implementation of `write_type_resolution` directly, rather than duplicating its code. Provide a fallback for non-wgsl builds.
1 parent 7f08498 commit 6150576

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

naga/src/common/diagnostic_display.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ impl fmt::Display for DiagnosticDisplay<(&TypeResolution, GlobalCtx<'_>)> {
5353
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5454
let (resolution, ctx) = self.0;
5555

56-
match *resolution {
57-
TypeResolution::Handle(handle) => DiagnosticDisplay((handle, ctx)).fmt(f),
58-
TypeResolution::Value(ref inner) => DiagnosticDisplay((inner, ctx)).fmt(f),
56+
#[cfg(any(feature = "wgsl-in", feature = "wgsl-out"))]
57+
ctx.write_type_resolution(resolution, f)?;
58+
59+
#[cfg(not(any(feature = "wgsl-in", feature = "wgsl-out")))]
60+
{
61+
let _ = ctx;
62+
write!(f, "{resolution:?}")?;
5963
}
64+
65+
Ok(())
6066
}
6167
}
6268

0 commit comments

Comments
 (0)