Skip to content

Commit 729614b

Browse files
diag(naga): merge FunctionError::InvalidStoreValue with InvalidStoreTypes
1 parent 894d036 commit 729614b

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

naga/src/valid/function.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ pub enum FunctionError {
151151
#[error("The type of {value:?} doesn't match the type stored in {pointer:?}")]
152152
InvalidStoreTypes {
153153
pointer: Handle<crate::Expression>,
154+
pointer_ty: crate::TypeInner,
154155
value: Handle<crate::Expression>,
156+
value_ty: crate::TypeInner,
155157
},
156158
#[error("Image store parameters are invalid")]
157159
InvalidImageStore(#[source] ExpressionError),
@@ -1022,7 +1024,9 @@ impl super::Validator {
10221024
}
10231025
}
10241026

1027+
let pointer_ty = context.resolve_pointer_type(pointer);
10251028
let value_ty = context.resolve_type(value, &self.valid_expression_set)?;
1029+
10261030
match *value_ty {
10271031
Ti::Image { .. } | Ti::Sampler { .. } => {
10281032
return Err(FunctionError::InvalidStoreTexture {
@@ -1038,8 +1042,6 @@ impl super::Validator {
10381042
_ => {}
10391043
}
10401044

1041-
let pointer_ty = context.resolve_pointer_type(pointer);
1042-
10431045
let good = match *pointer_ty {
10441046
Ti::Pointer { base, space: _ } => match context.types[base].inner {
10451047
Ti::Atomic(scalar) => *value_ty == Ti::Scalar(scalar),
@@ -1058,10 +1060,15 @@ impl super::Validator {
10581060
_ => false,
10591061
};
10601062
if !good {
1061-
return Err(FunctionError::InvalidStoreTypes { pointer, value }
1062-
.with_span()
1063-
.with_handle(pointer, context.expressions)
1064-
.with_handle(value, context.expressions));
1063+
return Err(FunctionError::InvalidStoreTypes {
1064+
pointer,
1065+
pointer_ty: pointer_ty.clone(),
1066+
value,
1067+
value_ty: value_ty.clone(),
1068+
}
1069+
.with_span()
1070+
.with_handle(pointer, context.expressions)
1071+
.with_handle(value, context.expressions));
10651072
}
10661073

10671074
if let Some(space) = pointer_ty.pointer_space() {

0 commit comments

Comments
 (0)