refactor(naga): use named fields for ExpressionError::InvalidBinaryOperandTypes

This commit is contained in:
Erich Gubler 2024-10-22 10:01:29 -04:00
parent ea75a8ced4
commit 2a2655def8

View File

@ -39,12 +39,12 @@ pub enum ExpressionError {
IndexableLength(#[from] IndexableLengthError), IndexableLength(#[from] IndexableLengthError),
#[error("Operation {0:?} can't work with {1:?}")] #[error("Operation {0:?} can't work with {1:?}")]
InvalidUnaryOperandType(crate::UnaryOperator, Handle<crate::Expression>), InvalidUnaryOperandType(crate::UnaryOperator, Handle<crate::Expression>),
#[error("Operation {0:?} can't work with {1:?} and {2:?}")] #[error("Operation {op:?} can't work with {lhs:?} and {rhs:?}")]
InvalidBinaryOperandTypes( InvalidBinaryOperandTypes {
crate::BinaryOperator, op: crate::BinaryOperator,
Handle<crate::Expression>, lhs: Handle<crate::Expression>,
Handle<crate::Expression>, rhs: Handle<crate::Expression>,
), },
#[error("Selecting is not possible")] #[error("Selecting is not possible")]
InvalidSelectTypes, InvalidSelectTypes,
#[error("Relational argument {0:?} is not a boolean vector")] #[error("Relational argument {0:?} is not a boolean vector")]
@ -847,7 +847,11 @@ impl super::Validator {
function.expressions[right], function.expressions[right],
right_inner right_inner
); );
return Err(ExpressionError::InvalidBinaryOperandTypes(op, left, right)); return Err(ExpressionError::InvalidBinaryOperandTypes {
op,
lhs: left,
rhs: right,
});
} }
ShaderStages::all() ShaderStages::all()
} }