[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.
This commit is contained in:
Jim Blandy authored and Erich Gubler committed 2025-04-09 16:48:49 -04:00
1 parent 59db4a6d62
commit e3b005ea82
1 file changed
+7 -5
+7 -5
View File
@@ -311,17 +311,19 @@ impl<'source> super::ExpressionContext<'source, '_, '_> {
I::IntoIter: Clone, // for debugging
{
let types = &self.module.types;
let mut inners = components
.into_iter()
.map(|&c| self.typifier()[c].inner_with(types));
let components_iter = components.into_iter();
log::debug!(
"wgsl automatic_conversion_consensus: {}",
inners
components_iter
.clone()
.map(|inner| self.type_inner_to_string(inner))
.map(|&expr| {
let res = &self.typifier()[expr];
self.type_resolution_to_string(res)
})
.collect::<Vec<String>>()
.join(", ")
);
let mut inners = components_iter.map(|&c| self.typifier()[c].inner_with(types));
let mut best = inners.next().unwrap().scalar().ok_or(0_usize)?;
for (inner, i) in inners.zip(1..) {
let scalar = inner.scalar().ok_or(i)?;