Skip to content

Support @must_use function attribute in WGSL #5186

Closed
@ErichDonGubler

Description

We do not currently support the @must_use function attribute, despite being specified in the current v1 spec. draft. This was introduced in early 2023; see gpuweb/gpuweb#3862, gpuweb/gpuweb#3819.

Repro steps

Ideally, a runnable example we can check out.

  1. With this in.wgsl input file:

    @must_use 
    fn helper() -> u32 {
    	return 2;
    }
    
    @compute @workgroup_size(1)
    fn comp_main() {
    	let asdf = helper();
    }

    …run this on latest trunk (ATOW, d239361):

    $ cargo run -p naga-cli --all-features -- in.wgsl
    

Expected vs observed behavior

Clearly describe what you get, and how it goes across your expectations.

This should compile without error. The asdf binding is unused, but that should, at most, be a warning. Instead, the current output of repro steps is:

Could not parse WGSL:
error: unknown attribute: 'must_use'
  ┌─ in.wgsl:1:2
  │
1 │ @must_use
  │  ^^^^^^^^ unknown attribute

Metadata

Assignees

Labels

lang: WGSLWebGPU Shading LanguagenagaShader Translator

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions