Skip to content

Commit 390beed

Browse files
WIP: diag(naga): narrow "easy" ExpressionError labels to single expr.
TODO: Validate that these look as we want, preferably with tests!
1 parent 89a11f3 commit 390beed

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

naga/src/valid/expression.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,23 @@ pub enum ExpressionError {
147147

148148
impl ExpressionError {
149149
pub(crate) fn expr_handles(&self) -> impl Iterator<Item = (Handle<crate::Expression>, String)> {
150+
let just = |handle| vec![(handle, "".into())];
150151
match *self {
151152
Self::NotInScope => Vec::new(),
152-
Self::InvalidBaseType(..) => Vec::new(),
153-
Self::InvalidIndexType(..) => Vec::new(),
154-
Self::NegativeIndex(..) => Vec::new(),
153+
Self::InvalidBaseType(handle) => just(handle),
154+
Self::InvalidIndexType(handle) => just(handle),
155+
Self::NegativeIndex(handle) => just(handle),
155156
Self::IndexOutOfBounds(..) => Vec::new(),
156157
Self::FunctionArgumentDoesntExist(..) => Vec::new(),
157-
Self::InvalidPointerType(..) => Vec::new(),
158-
Self::InvalidArrayType(..) => Vec::new(),
159-
Self::InvalidRayQueryType(..) => Vec::new(),
160-
Self::InvalidSplatType(..) => Vec::new(),
161-
Self::InvalidVectorType(..) => Vec::new(),
158+
Self::InvalidPointerType(handle) => just(handle),
159+
Self::InvalidArrayType(handle) => just(handle),
160+
Self::InvalidRayQueryType(handle) => just(handle),
161+
Self::InvalidSplatType(handle) => just(handle),
162+
Self::InvalidVectorType(handle) => just(handle),
162163
Self::InvalidSwizzleComponent(..) => Vec::new(),
163164
Self::Compose(..) => Vec::new(),
164165
Self::IndexableLength(..) => Vec::new(),
165-
Self::InvalidUnaryOperandType(..) => Vec::new(),
166+
Self::InvalidUnaryOperandType(_unary_operator, handle) => just(handle),
166167
Self::InvalidBinaryOperandTypes { .. } => Vec::new(),
167168
Self::SelectValuesTypeMismatch {
168169
accept,
@@ -179,8 +180,8 @@ impl ExpressionError {
179180
} => {
180181
vec![(actual, format!("this is of type {actual_ty:?}"))]
181182
}
182-
Self::InvalidBooleanVector(..) => Vec::new(),
183-
Self::InvalidFloatArgument(..) => Vec::new(),
183+
Self::InvalidBooleanVector(handle) => just(handle),
184+
Self::InvalidFloatArgument(handle) => just(handle),
184185
Self::Type(..) => Vec::new(),
185186
Self::ExpectedGlobalVariable => Vec::new(),
186187
Self::ExpectedGlobalOrArgument => Vec::new(),
@@ -191,24 +192,24 @@ impl ExpressionError {
191192
Self::InvalidDerivative => Vec::new(),
192193
Self::InvalidImageArrayIndex => Vec::new(),
193194
Self::InvalidImageOtherIndex => Vec::new(),
194-
Self::InvalidImageArrayIndexType(..) => Vec::new(),
195-
Self::InvalidImageOtherIndexType(..) => Vec::new(),
196-
Self::InvalidImageCoordinateType(..) => Vec::new(),
195+
Self::InvalidImageArrayIndexType(handle) => just(handle),
196+
Self::InvalidImageOtherIndexType(handle) => just(handle),
197+
Self::InvalidImageCoordinateType(_image_dimension, handle) => just(handle),
197198
Self::ComparisonSamplingMismatch { .. } => Vec::new(),
198199
Self::InvalidSampleOffsetExprType => Vec::new(),
199-
Self::InvalidSampleOffset(..) => Vec::new(),
200-
Self::InvalidDepthReference(..) => Vec::new(),
200+
Self::InvalidSampleOffset(_image_dimension, handle) => just(handle),
201+
Self::InvalidDepthReference(handle) => just(handle),
201202
Self::InvalidDepthSampleLevel => Vec::new(),
202203
Self::InvalidGatherLevel => Vec::new(),
203204
Self::InvalidGatherComponent(..) => Vec::new(),
204205
Self::InvalidGatherDimension(..) => Vec::new(),
205-
Self::InvalidSampleLevelExactType(..) => Vec::new(),
206-
Self::InvalidSampleLevelBiasType(..) => Vec::new(),
206+
Self::InvalidSampleLevelExactType(handle) => just(handle),
207+
Self::InvalidSampleLevelBiasType(handle) => just(handle),
207208
Self::InvalidSampleLevelBiasDimension(..) => Vec::new(),
208-
Self::InvalidSampleLevelGradientType(..) => Vec::new(),
209+
Self::InvalidSampleLevelGradientType(_image_dimension, handle) => just(handle),
209210
Self::InvalidCastArgument => Vec::new(),
210211
Self::WrongArgumentCount(..) => Vec::new(),
211-
Self::InvalidArgumentType(..) => Vec::new(),
212+
Self::InvalidArgumentType(_math_function, _, handle) => just(handle),
212213
Self::InvalidWorkGroupUniformLoadResultType(..) => Vec::new(),
213214
Self::MissingCapabilities(..) => Vec::new(),
214215
Self::Literal(..) => Vec::new(),

0 commit comments

Comments
 (0)