diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index d2002d086..a764191e0 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -2693,11 +2693,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { conv::PredeclaredType::TypeGenerator(type_generator) => { let ty_inner = match type_generator { conv::TypeGenerator::Vector { size } => { - let (scalar, _) = tl.scalar(self, ctx)?; + let (scalar, _) = tl.scalar_ty(self, ctx)?; ir::TypeInner::Vector { size, scalar } } conv::TypeGenerator::Matrix { columns, rows } => { - let (scalar, span) = tl.scalar(self, ctx)?; + let (scalar, span) = tl.scalar_ty(self, ctx)?; if scalar.kind != ir::ScalarKind::Float { return Err(Box::new(Error::BadMatrixScalarKind(span, scalar))); } @@ -2727,7 +2727,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ir::TypeInner::Array { base, size, stride } } conv::TypeGenerator::Atomic => { - let (scalar, _) = tl.scalar(self, ctx)?; + let (scalar, _) = tl.scalar_ty(self, ctx)?; ir::TypeInner::Atomic(scalar) } conv::TypeGenerator::Pointer => { @@ -2741,7 +2741,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { arrayed, multi, } => { - let (scalar, span) = tl.scalar(self, ctx)?; + let (scalar, span) = tl.scalar_ty(self, ctx)?; let ir::Scalar { kind, width } = scalar; if width != 4 { return Err(Box::new(Error::BadTextureSampleType { span, scalar })); diff --git a/naga/src/front/wgsl/lower/template_list.rs b/naga/src/front/wgsl/lower/template_list.rs index ba0085b63..579660ace 100644 --- a/naga/src/front/wgsl/lower/template_list.rs +++ b/naga/src/front/wgsl/lower/template_list.rs @@ -63,6 +63,11 @@ impl<'iter, 'source> TemplateListIter<'iter, 'source> { lowerer.type_expression(expr, ctx) } + /// Lower the next template list element as a type, and return its span. + /// + /// This returns the span of the template list element. This is generally + /// different from the span of the returned `Handle`, as the + /// latter may refer to the type's definition, not its use in the template list. pub fn ty_with_span( &mut self, lowerer: &mut Lowerer<'source, '_>, @@ -74,7 +79,7 @@ impl<'iter, 'source> TemplateListIter<'iter, 'source> { Ok((ty, span)) } - pub fn scalar( + pub fn scalar_ty( &mut self, lowerer: &mut Lowerer<'source, '_>, ctx: &mut ExpressionContext<'source, '_, '_>,