Skip to content

Commit e3b005e

Browse files
jimblandyErichDonGubler
authored andcommitted
[naga wgsl-in] Avoid crashes when logging types.
In `naga::front::wgsl::lower`, change logging in `ExpressionContext::automatic_conversion_consensus` to use `TypeResolution`s instead of `TypeInner`s, so that structs don't cause a crash.
1 parent 59db4a6 commit e3b005e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

naga/src/front/wgsl/lower/conversion.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,19 @@ impl<'source> super::ExpressionContext<'source, '_, '_> {
311311
I::IntoIter: Clone, // for debugging
312312
{
313313
let types = &self.module.types;
314-
let mut inners = components
315-
.into_iter()
316-
.map(|&c| self.typifier()[c].inner_with(types));
314+
let components_iter = components.into_iter();
317315
log::debug!(
318316
"wgsl automatic_conversion_consensus: {}",
319-
inners
317+
components_iter
320318
.clone()
321-
.map(|inner| self.type_inner_to_string(inner))
319+
.map(|&expr| {
320+
let res = &self.typifier()[expr];
321+
self.type_resolution_to_string(res)
322+
})
322323
.collect::<Vec<String>>()
323324
.join(", ")
324325
);
326+
let mut inners = components_iter.map(|&c| self.typifier()[c].inner_with(types));
325327
let mut best = inners.next().unwrap().scalar().ok_or(0_usize)?;
326328
for (inner, i) in inners.zip(1..) {
327329
let scalar = inner.scalar().ok_or(i)?;

0 commit comments

Comments
 (0)