diff --git a/src/front/wgsl/lower/construction.rs b/src/front/wgsl/lower/construction.rs index d02826834c..9ce29aa351 100644 --- a/src/front/wgsl/lower/construction.rs +++ b/src/front/wgsl/lower/construction.rs @@ -5,7 +5,6 @@ use crate::{Handle, Span}; use crate::front::wgsl::error::Error; use crate::front::wgsl::lower::{ExpressionContext, Lowerer}; -use crate::proc::TypeResolution; enum ConcreteConstructorHandle { PartialVector { @@ -59,46 +58,6 @@ impl ConcreteConstructorHandle { } } -enum ComponentsHandle<'a> { - None, - One { - component: Handle, - span: Span, - ty: &'a TypeResolution, - }, - Many { - components: Vec>, - spans: Vec, - first_component_ty: &'a TypeResolution, - }, -} - -impl<'a> ComponentsHandle<'a> { - fn borrow(self, module: &'a crate::Module) -> Components<'a> { - match self { - Self::None => Components::None, - Self::One { - component, - span, - ty, - } => Components::One { - component, - span, - ty_inner: ty.inner_with(&module.types), - }, - Self::Many { - components, - spans, - first_component_ty, - } => Components::Many { - components, - spans, - first_component_ty_inner: first_component_ty.inner_with(&module.types), - }, - } - } -} - enum Components<'a> { None, One { @@ -147,17 +106,17 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ) -> Result, Error<'source>> { let constructor_h = self.constructor(constructor, ctx)?; - let components_h = match *components { - [] => ComponentsHandle::None, + let components = match *components { + [] => Components::None, [component] => { let span = ctx.ast_expressions.get_span(component); let component = self.expression(component, ctx)?; - let ty = super::resolve!(ctx, component); + let ty_inner = super::resolve_inner!(ctx, component); - ComponentsHandle::One { + Components::One { component, span, - ty, + ty_inner, } } [component, ref rest @ ..] => { @@ -177,20 +136,18 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ) .collect(); - let ty = super::resolve!(ctx, component); + let first_component_ty_inner = super::resolve_inner!(ctx, component); - ComponentsHandle::Many { + Components::Many { components, spans, - first_component_ty: ty, + first_component_ty_inner, } } }; - let (components, constructor) = ( - components_h.borrow(ctx.module), - constructor_h.borrow(ctx.module), - ); + let constructor = constructor_h.borrow(ctx.module); + let expr = match (components, constructor) { // Empty constructor (Components::None, dst_ty) => match dst_ty { diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 631db7d26b..5f5f89f806 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -32,6 +32,7 @@ macro_rules! resolve_inner { $ctx.typifier()[$expr].inner_with(&$ctx.module.types) }}; } +pub(super) use resolve_inner; /// Resolves the inner types of two given expressions. ///