Add pub const fn default() for various types. - #9929
Merged
Conversation
kpreid
force-pushed
the
const
branch
3 times, most recently
from
July 22, 2026 19:42
cf6d79b to
ddae7ac
Compare
ErichDonGubler
approved these changes
Jul 27, 2026
ErichDonGubler
left a comment
Member
There was a problem hiding this comment.
This broadly LGTM, and does what it says it does. Just want to ping at least one other @gfx-rs/wgpu member for their thoughts/approval before we merge this API addition (which I don't want to wait longer than a couple of days for, unless you feel strongly, @kpreid).
Member
|
Leaving unmerged in case the latest feedback made you want to edit something. Otherwise: fire when ready! |
Collaborator
Author
|
Pushed 1 doc edit. Should be good to merge now. |
The default functions are generated using a `macro_rules_attribute` emulated derive macro, just fancy enough to work. It does not support structs with generics, so `*Descriptor`s are left alone for now. When Rust const traits stabilize, we can replace this with real const traits.
Member
|
Rebased with resolved conflicts in the |
ErichDonGubler
enabled auto-merge (rebase)
August 3, 2026 10:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Connections
Fixes #9923.
Description
Allows use of
wgpu’s provided default values for its types in dependents’ constant evaluation.The default functions are generated using a
macro_rules_attributeemulated derive macro, just fancy enough to work. It does not support structs with generics, so*Descriptors are left alone for now.ConstDefaultHelperis not part of the public API.Separately,
ForceShaderModelToken::{with_shader_model, get}are nowconst fn.DxcShaderModelnow implementsCopy.Testing
Existing tests pass. But perhaps we should also add a test or doctest showing that this constant works. Where?
Squash or Rebase?
Rebase
Checklist
wgpumay be affected behaviorally.CHANGELOG.mdentries for the user-facing effects of this change are present.