Skip to content

Commit 7f08498

Browse files
jimblandyErichDonGubler
authored andcommitted
[naga wgsl-out] Stop using TypeContext::write_type_inner.
In `naga::back::wgsl`, prefer `TypeContext::write_type_resolution` over `write_type_inner`, since the former is actually what we need, and the latter can be troublesome if asked to write a `struct` type.
1 parent dd60ce3 commit 7f08498

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

naga/src/back/wgsl/writer.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,15 +481,19 @@ impl<W: Write> Writer<W> {
481481
Ok(())
482482
}
483483

484-
fn write_type_inner(&mut self, module: &Module, inner: &TypeInner) -> BackendResult {
484+
fn write_type_resolution(
485+
&mut self,
486+
module: &Module,
487+
resolution: &proc::TypeResolution,
488+
) -> BackendResult {
485489
// This actually can't be factored out into a nice constructor method,
486490
// because the borrow checker needs to be able to see that the borrows
487491
// of `self.names` and `self.out` are disjoint.
488492
let type_context = WriterTypeContext {
489493
module,
490494
names: &self.names,
491495
};
492-
type_context.write_type_inner(inner, &mut self.out)?;
496+
type_context.write_type_resolution(resolution, &mut self.out)?;
493497

494498
Ok(())
495499
}
@@ -1031,16 +1035,8 @@ impl<W: Write> Writer<W> {
10311035
write!(self.out, "let {name}")?;
10321036
if self.flags.contains(WriterFlags::EXPLICIT_TYPES) {
10331037
write!(self.out, ": ")?;
1034-
let ty = &func_ctx.info[handle].ty;
10351038
// Write variable type
1036-
match *ty {
1037-
proc::TypeResolution::Handle(handle) => {
1038-
self.write_type(module, handle)?;
1039-
}
1040-
proc::TypeResolution::Value(ref inner) => {
1041-
self.write_type_inner(module, inner)?;
1042-
}
1043-
}
1039+
self.write_type_resolution(module, &func_ctx.info[handle].ty)?;
10441040
}
10451041

10461042
write!(self.out, " = ")?;

0 commit comments

Comments
 (0)