diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index 977797a258..30f2864bf9 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -4228,7 +4228,6 @@ impl Parser { type_span, ); self.lookup_type.insert(name.to_owned(), ty); - lexer.expect(Token::Separator(';'))?; } (Token::Word("type"), _) => { let name = lexer.next_ident()?; diff --git a/src/front/wgsl/tests.rs b/src/front/wgsl/tests.rs index 1ccff93e89..281bd21f62 100644 --- a/src/front/wgsl/tests.rs +++ b/src/front/wgsl/tests.rs @@ -157,13 +157,13 @@ fn parse_type_cast() { fn parse_struct() { parse_str( " - struct Foo { x: i32 }; + struct Foo { x: i32 } struct Bar { @size(16) x: vec2, @align(16) y: f32, @size(32) @align(8) z: vec3, }; - struct Empty {}; + struct Empty {} var s: Foo; ", ) @@ -443,7 +443,7 @@ fn parse_struct_instantiation() { struct Foo { a: f32, b: vec3, - }; + } @stage(fragment) fn fs_main() { @@ -460,7 +460,7 @@ fn parse_array_length() { " struct Foo { data: array - }; // this is used as both input and output for convenience + } // this is used as both input and output for convenience @group(0) @binding(0) var foo: Foo; diff --git a/tests/in/access.wgsl b/tests/in/access.wgsl index 390a018b11..7c96367ac1 100644 --- a/tests/in/access.wgsl +++ b/tests/in/access.wgsl @@ -2,7 +2,7 @@ struct AlignedWrapper { @align(8) value: i32 -}; +} struct Bar { matrix: mat4x4, @@ -10,7 +10,7 @@ struct Bar { atom: atomic, arr: array, 2>, data: array, -}; +} @group(0) @binding(0) var bar: Bar; diff --git a/tests/in/boids.wgsl b/tests/in/boids.wgsl index 2655f2783a..7194d4878c 100644 --- a/tests/in/boids.wgsl +++ b/tests/in/boids.wgsl @@ -3,7 +3,7 @@ let NUM_PARTICLES: u32 = 1500u; struct Particle { pos : vec2, vel : vec2, -}; +} struct SimParams { deltaT : f32, @@ -13,11 +13,11 @@ struct SimParams { rule1Scale : f32, rule2Scale : f32, rule3Scale : f32, -}; +} struct Particles { particles : array -}; +} @group(0) @binding(0) var params : SimParams; @group(0) @binding(1) var particlesSrc : Particles; diff --git a/tests/in/bounds-check-restrict.wgsl b/tests/in/bounds-check-restrict.wgsl index d88be39fb4..2b7208355c 100644 --- a/tests/in/bounds-check-restrict.wgsl +++ b/tests/in/bounds-check-restrict.wgsl @@ -5,7 +5,7 @@ struct Globals { v: vec4, m: mat3x4, d: array, -}; +} @group(0) @binding(0) var globals: Globals; diff --git a/tests/in/bounds-check-zero-atomic.wgsl b/tests/in/bounds-check-zero-atomic.wgsl index c64cc8bd0a..3cdbea14a7 100644 --- a/tests/in/bounds-check-zero-atomic.wgsl +++ b/tests/in/bounds-check-zero-atomic.wgsl @@ -8,7 +8,7 @@ struct Globals { a: atomic, b: array, 10>, c: array>, -}; +} @group(0) @binding(0) var globals: Globals; diff --git a/tests/in/bounds-check-zero.wgsl b/tests/in/bounds-check-zero.wgsl index 1dbfd9cb5e..010f46ec3b 100644 --- a/tests/in/bounds-check-zero.wgsl +++ b/tests/in/bounds-check-zero.wgsl @@ -5,7 +5,7 @@ struct Globals { v: vec4, m: mat3x4, d: array, -}; +} @group(0) @binding(0) var globals: Globals; diff --git a/tests/in/collatz.wgsl b/tests/in/collatz.wgsl index 377c0f8449..b2d990732e 100644 --- a/tests/in/collatz.wgsl +++ b/tests/in/collatz.wgsl @@ -1,6 +1,6 @@ struct PrimeIndices { data: array -}; // this is used as both input and output for convenience +} // this is used as both input and output for convenience @group(0) @binding(0) var v_indices: PrimeIndices; diff --git a/tests/in/extra.wgsl b/tests/in/extra.wgsl index 6dcecd5535..a0130da17a 100644 --- a/tests/in/extra.wgsl +++ b/tests/in/extra.wgsl @@ -1,13 +1,13 @@ struct PushConstants { index: u32, double: vec2, -}; +} var pc: PushConstants; struct FragmentIn { @location(0) color: vec4, @builtin(primitive_index) primitive_index: u32, -}; +} @stage(fragment) fn main(in: FragmentIn) -> @location(0) vec4 { diff --git a/tests/in/globals.wgsl b/tests/in/globals.wgsl index ed8c40a70d..0dff3f8e7f 100644 --- a/tests/in/globals.wgsl +++ b/tests/in/globals.wgsl @@ -9,7 +9,7 @@ struct Foo { v3: vec3, // test packed vec3 v1: f32, -}; +} @group(0) @binding(1) var alignment: Foo; diff --git a/tests/in/interface.wgsl b/tests/in/interface.wgsl index d2cf84023c..3655ba9b84 100644 --- a/tests/in/interface.wgsl +++ b/tests/in/interface.wgsl @@ -3,7 +3,7 @@ struct VertexOutput { @builtin(position) position: vec4, @location(1) varying: f32, -}; +} @stage(vertex) fn vertex( @@ -19,7 +19,7 @@ struct FragmentOutput { @builtin(frag_depth) depth: f32, @builtin(sample_mask) sample_mask: u32, @location(0) color: f32, -}; +} @stage(fragment) fn fragment( @@ -48,11 +48,11 @@ fn compute( struct Input1 { @builtin(vertex_index) index: u32, -}; +} struct Input2 { @builtin(instance_index) index: u32, -}; +} @stage(vertex) fn vertex_two_structs(in1: Input1, in2: Input2) -> @builtin(position) vec4 { diff --git a/tests/in/interpolate.wgsl b/tests/in/interpolate.wgsl index 1cb7239458..86753a83e2 100644 --- a/tests/in/interpolate.wgsl +++ b/tests/in/interpolate.wgsl @@ -9,7 +9,7 @@ struct FragmentInput { @location(4) @interpolate(perspective) perspective : vec4, @location(5) @interpolate(perspective, centroid) perspective_centroid : f32, @location(6) @interpolate(perspective, sample) perspective_sample : f32, -}; +} @stage(vertex) fn vert_main() -> FragmentInput { diff --git a/tests/in/operators.wgsl b/tests/in/operators.wgsl index 23dbf734c2..4af87d48e2 100644 --- a/tests/in/operators.wgsl +++ b/tests/in/operators.wgsl @@ -41,7 +41,7 @@ fn bool_cast(x: vec3) -> vec3 { struct Foo { a: vec4, b: i32, -}; +} fn constructors() -> f32 { var foo: Foo; diff --git a/tests/in/pointers.wgsl b/tests/in/pointers.wgsl index cf07d5dbf1..bfd88c9467 100644 --- a/tests/in/pointers.wgsl +++ b/tests/in/pointers.wgsl @@ -6,7 +6,7 @@ fn f() { struct DynamicArray { arr: array -}; +} @group(0) @binding(0) var dynamic_array: DynamicArray; diff --git a/tests/in/policy-mix.wgsl b/tests/in/policy-mix.wgsl index a29556a5b3..f1fb723892 100644 --- a/tests/in/policy-mix.wgsl +++ b/tests/in/policy-mix.wgsl @@ -4,12 +4,12 @@ // Storage and Uniform storage classes struct InStorage { a: array, 10> -}; +} @group(0) @binding(0) var in_storage: InStorage; struct InUniform { a: array, 20> -}; +} @group(0) @binding(1) var in_uniform: InUniform; // Textures automatically land in the `handle` storage class. diff --git a/tests/in/push-constants.wgsl b/tests/in/push-constants.wgsl index 4a55ed20a8..e0bf46758f 100644 --- a/tests/in/push-constants.wgsl +++ b/tests/in/push-constants.wgsl @@ -1,11 +1,11 @@ struct PushConstants { multiplier: f32 -}; +} var pc: PushConstants; struct FragmentIn { @location(0) color: vec4 -}; +} @stage(fragment) fn main(in: FragmentIn) -> @location(0) vec4 { diff --git a/tests/in/quad.wgsl b/tests/in/quad.wgsl index 37b543397b..590ba0e4ca 100644 --- a/tests/in/quad.wgsl +++ b/tests/in/quad.wgsl @@ -4,7 +4,7 @@ let c_scale: f32 = 1.2; struct VertexOutput { @location(0) uv : vec2, @builtin(position) position : vec4, -}; +} @stage(vertex) fn vert_main( diff --git a/tests/in/shadow.wgsl b/tests/in/shadow.wgsl index 37e17877c9..af46ec0d4f 100644 --- a/tests/in/shadow.wgsl +++ b/tests/in/shadow.wgsl @@ -1,7 +1,7 @@ struct Globals { view_proj: mat4x4, num_lights: vec4, -}; +} @group(0) @binding(0) @@ -10,7 +10,7 @@ var u_globals: Globals; struct Entity { world: mat4x4, color: vec4, -}; +} @group(1) @binding(0) @@ -27,7 +27,7 @@ struct VertexOutput { @builtin(position) proj_position: vec4, @location(0) world_normal: vec3, @location(1) world_position: vec4, -}; +} @stage(vertex) fn vs_main( @@ -49,7 +49,7 @@ struct Light { proj: mat4x4, pos: vec4, color: vec4, -}; +} @group(0) @binding(1) diff --git a/tests/in/skybox.wgsl b/tests/in/skybox.wgsl index 06e5a07aa0..0b589c7f56 100644 --- a/tests/in/skybox.wgsl +++ b/tests/in/skybox.wgsl @@ -1,12 +1,12 @@ struct VertexOutput { @builtin(position) position: vec4, @location(0) uv: vec3, -}; +} struct Data { proj_inv: mat4x4, view: mat4x4, -}; +} @group(0) @binding(0) var r_data: Data; diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index bde6da336b..7e6b3578ec 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -377,7 +377,7 @@ fn struct_member_zero_size() { r#" struct Bar { @size(0) data: array - }; + } "#, r#"error: struct member size or alignment must not be 0 ┌─ wgsl:3:23 @@ -395,7 +395,7 @@ fn struct_member_zero_align() { r#" struct Bar { @align(0) data: array - }; + } "#, r#"error: struct member size or alignment must not be 0 ┌─ wgsl:3:24 @@ -641,12 +641,12 @@ fn reserved_keyword() { // struct check( r#" - struct array {}; + struct array {} "#, r###"error: name `array` is a reserved keyword ┌─ wgsl:2:20 │ -2 │ struct array {}; +2 │ struct array {} │ ^^^^^ definition of `array` "###, @@ -655,12 +655,12 @@ fn reserved_keyword() { // struct member check( r#" - struct Foo { sampler: f32 }; + struct Foo { sampler: f32 } "#, r###"error: name `sampler` is a reserved keyword ┌─ wgsl:2:26 │ -2 │ struct Foo { sampler: f32 }; +2 │ struct Foo { sampler: f32 } │ ^^^^^^^ definition of `sampler` "###, @@ -843,8 +843,8 @@ fn invalid_arrays() { #[test] fn invalid_structs() { check_validation_error! { - "struct Bad { data: sampler };", - "struct Bad { data: texture_2d };": + "struct Bad { data: sampler }", + "struct Bad { data: texture_2d }": Err(naga::valid::ValidationError::Type { error: naga::valid::TypeError::InvalidData(_), .. @@ -852,7 +852,7 @@ fn invalid_structs() { } check_validation_error! { - "struct Bad { data: array, other: f32, };": + "struct Bad { data: array, other: f32, }": Err(naga::valid::ValidationError::Type { error: naga::valid::TypeError::InvalidDynamicArray(_, _), .. @@ -865,7 +865,7 @@ fn invalid_functions() { check_validation_error! { "fn unacceptable_unsized(arg: array) { }", " - struct Unsized { data: array }; + struct Unsized { data: array } fn unacceptable_unsized(arg: Unsized) { } ": Err(naga::valid::ValidationError::Function { @@ -883,7 +883,7 @@ fn invalid_functions() { check_validation_error! { "fn unacceptable_unsized(arg: ptr>) { }", " - struct Unsized { data: array }; + struct Unsized { data: array } fn unacceptable_unsized(arg: ptr) { } ": Err(naga::valid::ValidationError::Type { @@ -1000,7 +1000,7 @@ fn missing_bindings() { struct VertexIn { @location(0) pos: vec4, uv: vec2 - }; + } @stage(vertex) fn vertex(input: VertexIn) -> @location(0) vec4 { @@ -1088,7 +1088,7 @@ fn valid_access() { fn invalid_local_vars() { check_validation_error! { " - struct Unsized { data: array }; + struct Unsized { data: array } fn local_ptr_dynamic_array(okay: ptr) { var not_okay: ptr> = &(*okay).data; } @@ -1145,12 +1145,12 @@ fn invalid_runtime_sized_arrays() { " struct Unsized { arr: array - }; + } struct Outer { legit: i32, unsized: Unsized - }; + } @group(0) @binding(0) var outer: Outer; @@ -1187,7 +1187,7 @@ fn select() { } ", " - struct S { member: i32 }; + struct S { member: i32 } fn select_structs(which: bool) -> S { var x: S = S(1); var y: S = S(2); @@ -1258,7 +1258,7 @@ fn wrong_access_mode() { " struct Globals { i: i32 - }; + } @group(0) @binding(0) var globals: Globals; @@ -1270,7 +1270,7 @@ fn wrong_access_mode() { " struct Globals { i: i32 - }; + } @group(0) @binding(0) var globals: Globals;