Skip to content

add macros for generating Default impls#5257

Open
telcharr wants to merge 1 commit into
rust-lang:mainfrom
telcharr:feature/default-macro
Open

add macros for generating Default impls#5257
telcharr wants to merge 1 commit into
rust-lang:mainfrom
telcharr:feature/default-macro

Conversation

@telcharr

@telcharr telcharr commented Jul 7, 2026

Copy link
Copy Markdown

Description

Adds impl_default!, s_with_default!, and s_no_extra_traits_with_default! as a start for #4975. Unions get no implicit Default so a union field would need to supply one via #[custom_default(unsafe { mem::zeroed::<U>() })]. As discussed, custom_default needs to be the first attribute on a field since the macro matches it literally.

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@rustbot rustbot added S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jul 7, 2026
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