Skip to content

macros: forward cfg attributes to generated impls - #5372

Open
telcharr wants to merge 2 commits into
rust-lang:mainfrom
telcharr:feature/default-macro-cfg
Open

macros: forward cfg attributes to generated impls#5372
telcharr wants to merge 2 commits into
rust-lang:mainfrom
telcharr:feature/default-macro-cfg

Conversation

@telcharr

@telcharr telcharr commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #5257 for the cfg issue that was spotted, plus the same on Debug for unions.

Attributes are now split into cfg_attrs and other_attrs, both go on the type, only the cfgs repeat on the impl. Needed them as tt rather than meta so cfg is still matchable.

The generated impls also warn when the type or its fields are deprecated. s_no_extra_traits! got an allow(deprecated) for that but the newer macros never picked it up.

The splitting arms are duplicated between union_with_debug! and struct_with_default!. Sharing them needs a callback macro which felt worse to read, but let me know if you'd rather have that.

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

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