mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Reject empty struct types. (#1826)
This commit is contained in:
@@ -676,6 +676,8 @@ pub enum TypeInner {
|
||||
|
||||
/// User-defined structure.
|
||||
///
|
||||
/// There must always be at least one member.
|
||||
///
|
||||
/// A `Struct` type is [`DATA`], and the types of its members must be
|
||||
/// `DATA` as well.
|
||||
///
|
||||
|
||||
@@ -120,6 +120,8 @@ pub enum TypeError {
|
||||
size: u32,
|
||||
span: u32,
|
||||
},
|
||||
#[error("Structure types must have at least one member")]
|
||||
EmptyStruct,
|
||||
}
|
||||
|
||||
// Only makes sense if `flags.contains(HOST_SHARED)`
|
||||
@@ -451,6 +453,10 @@ impl super::Validator {
|
||||
}
|
||||
}
|
||||
Ti::Struct { ref members, span } => {
|
||||
if members.is_empty() {
|
||||
return Err(TypeError::EmptyStruct);
|
||||
}
|
||||
|
||||
let mut ti = TypeInfo::new(
|
||||
TypeFlags::DATA
|
||||
| TypeFlags::SIZED
|
||||
|
||||
@@ -930,6 +930,14 @@ fn invalid_structs() {
|
||||
..
|
||||
})
|
||||
}
|
||||
|
||||
check_validation_error! {
|
||||
"struct Empty {}":
|
||||
Err(naga::valid::ValidationError::Type {
|
||||
error: naga::valid::TypeError::EmptyStruct,
|
||||
..
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user