Skip to content

Conversation

@jsgf
Copy link
Contributor

@jsgf jsgf commented Oct 21, 2025

Wrap the FAM generic parameter in ManuallyDrop when the parent struct is packed. This satisfies Rust's requirement that DST fields in packed structs must not need Drop to be run.

The fix automatically detects packed structs and generates:
pub field: ::std::mem::ManuallyDrop
instead of:
pub field: FAM

Fixes #2936

Wrap the FAM generic parameter in `ManuallyDrop` when the parent struct
is packed. This satisfies Rust's requirement that DST fields in packed
structs must not need `Drop` to be run.

The fix automatically detects packed structs and generates:
  pub field: ::std::mem::ManuallyDrop<FAM>
instead of:
  pub field: FAM

Fixes rust-lang#2936
@emilio emilio added this pull request to the merge queue Oct 21, 2025
Merged via the queue into rust-lang:main with commit 4731d6c Oct 21, 2025
51 checks passed
@jsgf jsgf deleted the issue-2936 branch October 22, 2025 00:19
meta-codesync bot pushed a commit to facebook/sapling that referenced this pull request Oct 23, 2025
Summary:
This includes 3 recent PRs:
- rust-lang/rust-bindgen#3305 - Fix packed structs with flexible array members (merged)
- rust-lang/rust-bindgen#3306 - Support nested flexible array members
- rust-lang/rust-bindgen#3307 - Add support for custom per-field attributes

The last one is specifically intended to allow per-field attributes from proc-macros to be applied.

These have been cherry-picked onto the v0.72.1 release branch, as the main branch is still listed as v0.72.0 and I didn't want a backwards version step. The upstream branch is https://github.com/jsgf/rust-bindgen/tree/PR-merged

Reviewed By: dtolnay

Differential Revision: D85273915

fbshipit-source-id: 211916b9611cbfa409296a6854b4a94bba2c5195
meta-codesync bot pushed a commit to facebookexperimental/rust-shed that referenced this pull request Oct 23, 2025
Summary:
This includes 3 recent PRs:
- rust-lang/rust-bindgen#3305 - Fix packed structs with flexible array members (merged)
- rust-lang/rust-bindgen#3306 - Support nested flexible array members
- rust-lang/rust-bindgen#3307 - Add support for custom per-field attributes

The last one is specifically intended to allow per-field attributes from proc-macros to be applied.

These have been cherry-picked onto the v0.72.1 release branch, as the main branch is still listed as v0.72.0 and I didn't want a backwards version step. The upstream branch is https://github.com/jsgf/rust-bindgen/tree/PR-merged

Reviewed By: dtolnay

Differential Revision: D85273915

fbshipit-source-id: 211916b9611cbfa409296a6854b4a94bba2c5195
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Packed struct with DST fails to compile

2 participants