Skip to content

macros: add support for exhaustive attribute - #5390

Open
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:non_exhaustive-macro-extension
Open

macros: add support for exhaustive attribute#5390
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:non_exhaustive-macro-extension

Conversation

@dybucc

@dybucc dybucc commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

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_default or s_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
struct marked non_exhaustive in FFI contexts.

Checklist

  • Relevant tests in libc-test/semver have been updated
  • Commit messages permalink to headers for added or changed API
  • Placeholder or unstable values like *LAST or *MAX have the standard
    doc comment
  • Tested locally (cargo test -p libc-test --target mytarget); especially
    relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@dybucc dybucc changed the title macros: add support for exhaustive attr macros: add support for exhaustive attribute Aug 8, 2026
@dybucc
dybucc force-pushed the non_exhaustive-macro-extension branch from 8c61548 to 5a738cb Compare August 8, 2026 08:06
@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Aug 8, 2026
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
dybucc force-pushed the non_exhaustive-macro-extension branch from 5a738cb to f11b352 Compare August 8, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants