macros: add support for exhaustive attribute - #5390
Open
dybucc wants to merge 1 commit into
Open
Conversation
exhaustive attrexhaustive attribute
dybucc
force-pushed
the
non_exhaustive-macro-extension
branch
from
August 8, 2026 08:06
8c61548 to
5a738cb
Compare
Add support for `exhaustive` custom attribute to opt out of having the record have a `__non_exhaustive` field added to it. Modify `struct_with_default` to automatically add a private field to all records such that they are always built field-by-field in downstream crates.
dybucc
force-pushed
the
non_exhaustive-macro-extension
branch
from
August 8, 2026 08:13
5a738cb to
f11b352
Compare
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.
Description
Attempts to take the first steps in closing #4080. This should
allow us to add a private field for each of the records declared within
s_with_defaultors_no_extra_traits_with_default.This should in turn enforce those records to be initialized field-by-field in
downstream crates, while avoiding the lint that currently pops up when using a
structmarkednon_exhaustivein FFI contexts.Checklist
libc-test/semverhave been updated*LASTor*MAXhave the standarddoc comment
cargo test -p libc-test --target mytarget); especiallyrelevant for platforms that may not be checked in CI
@rustbot label +stable-nominated