naga: Enforce @must_use for built-in functions
#8713
+810
−679
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The spec defines many built-ins to have the
@must_useattribute. This PR applies "must use" enforcement on calls to applicable built-ins.There are some preliminary refactors including moving a chunk of code. They are in separate commits and it is probably easier to review that way.
This is a breaking change for shaders that call these functions without using the result, which is unfortunate, but we don't have infrastructure for deprecation warnings.
This can of course wait until after the release if desired, although it seems like a change that will cause the same amount of pain in whatever release it goes in, rather than a change that needs soak time before being released.
I don't love
MUST_USE_YESandMUST_USE_NO, but I also don't love random booleans that you have to look 100 lines up or down to interpret.Testing
Tested by the CTS
Squash or Rebase? Rebase (after squashing fixups)
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.