Skip to content

Commit 3eba888

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 6d6a99f commit 3eba888

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
@@ -148,22 +148,23 @@ pub enum ExpressionError {
148148

149149
impl ExpressionError {
150150
pub(crate) fn expr_handles(&self) -> impl Iterator<Item = (Handle<crate::Expression>, String)> {
151+
let just = |handle| vec![(handle, "".into())];
151152
match *self {
152153
Self::NotInScope => Vec::new(),
153-
Self::InvalidBaseType(..) => Vec::new(),
154-
Self::InvalidIndexType(..) => Vec::new(),
155-
Self::NegativeIndex(..) => Vec::new(),
154+
Self::InvalidBaseType(handle) => just(handle),
155+
Self::InvalidIndexType(handle) => just(handle),
156+
Self::NegativeIndex(handle) => just(handle),
156157
Self::IndexOutOfBounds(..) => Vec::new(),
157158
Self::FunctionArgumentDoesntExist(..) => Vec::new(),
158-
Self::InvalidPointerType(..) => Vec::new(),
159-
Self::InvalidArrayType(..) => Vec::new(),
160-
Self::InvalidRayQueryType(..) => Vec::new(),
161-
Self::InvalidSplatType(..) => Vec::new(),
162-
Self::InvalidVectorType(..) => Vec::new(),
159+
Self::InvalidPointerType(handle) => just(handle),
160+
Self::InvalidArrayType(handle) => just(handle),
161+
Self::InvalidRayQueryType(handle) => just(handle),
162+
Self::InvalidSplatType(handle) => just(handle),
163+
Self::InvalidVectorType(handle) => just(handle),
163164
Self::InvalidSwizzleComponent(..) => Vec::new(),
164165
Self::Compose(..) => Vec::new(),
165166
Self::IndexableLength(..) => Vec::new(),
166-
Self::InvalidUnaryOperandType(..) => Vec::new(),
167+
Self::InvalidUnaryOperandType(_unary_operator, handle) => just(handle),
167168
Self::InvalidBinaryOperandTypes { .. } => Vec::new(),
168169
Self::SelectValuesTypeMismatch {
169170
accept,
@@ -180,8 +181,8 @@ impl ExpressionError {
180181
} => {
181182
vec![(actual, format!("this is of type {actual_ty:?}"))]
182183
}
183-
Self::InvalidBooleanVector(..) => Vec::new(),
184-
Self::InvalidFloatArgument(..) => Vec::new(),
184+
Self::InvalidBooleanVector(handle) => just(handle),
185+
Self::InvalidFloatArgument(handle) => just(handle),
185186
Self::Type(..) => Vec::new(),
186187
Self::ExpectedGlobalVariable => Vec::new(),
187188
Self::ExpectedGlobalOrArgument => Vec::new(),
@@ -192,24 +193,24 @@ impl ExpressionError {
192193
Self::InvalidDerivative => Vec::new(),
193194
Self::InvalidImageArrayIndex => Vec::new(),
194195
Self::InvalidImageOtherIndex => Vec::new(),
195-
Self::InvalidImageArrayIndexType(..) => Vec::new(),
196-
Self::InvalidImageOtherIndexType(..) => Vec::new(),
197-
Self::InvalidImageCoordinateType(..) => Vec::new(),
196+
Self::InvalidImageArrayIndexType(handle) => just(handle),
197+
Self::InvalidImageOtherIndexType(handle) => just(handle),
198+
Self::InvalidImageCoordinateType(_image_dimension, handle) => just(handle),
198199
Self::ComparisonSamplingMismatch { .. } => Vec::new(),
199200
Self::InvalidSampleOffsetExprType => Vec::new(),
200-
Self::InvalidSampleOffset(..) => Vec::new(),
201-
Self::InvalidDepthReference(..) => Vec::new(),
201+
Self::InvalidSampleOffset(_image_dimension, handle) => just(handle),
202+
Self::InvalidDepthReference(handle) => just(handle),
202203
Self::InvalidDepthSampleLevel => Vec::new(),
203204
Self::InvalidGatherLevel => Vec::new(),
204205
Self::InvalidGatherComponent(..) => Vec::new(),
205206
Self::InvalidGatherDimension(..) => Vec::new(),
206-
Self::InvalidSampleLevelExactType(..) => Vec::new(),
207-
Self::InvalidSampleLevelBiasType(..) => Vec::new(),
207+
Self::InvalidSampleLevelExactType(handle) => just(handle),
208+
Self::InvalidSampleLevelBiasType(handle) => just(handle),
208209
Self::InvalidSampleLevelBiasDimension(..) => Vec::new(),
209-
Self::InvalidSampleLevelGradientType(..) => Vec::new(),
210+
Self::InvalidSampleLevelGradientType(_image_dimension, handle) => just(handle),
210211
Self::InvalidCastArgument => Vec::new(),
211212
Self::WrongArgumentCount(..) => Vec::new(),
212-
Self::InvalidArgumentType(..) => Vec::new(),
213+
Self::InvalidArgumentType(_math_function, _, handle) => just(handle),
213214
Self::InvalidWorkGroupUniformLoadResultType(..) => Vec::new(),
214215
Self::MissingCapabilities(..) => Vec::new(),
215216
Self::Literal(..) => Vec::new(),

0 commit comments

Comments
 (0)