google / google/zerocopy

Improve `#[derive(IntoBytes)]` padding analysis on DSTs

Open
#1,112 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.6k
Forks
179
Avg merge
1d 19h
Merged PRs (30d)
29

Description

Many dynamically sized types can be `derive(FromBytes)` but not `derive(IntoBytes)` because of shortcomings in our padding analysis. For example:

```rust
#[derive(KnownLayout, FromBytes, IntoBytes)]
#[repr(C)]
struct Example {
header: Header,
body: [Body],
}
```

Presently, a user must either mark `Example` as `repr(C, packed)`, or they must model `Example` instead as a composite struct containing `Ref`s to the `Header` and `[Body]`.

Can we make our analysis more sophisticated in this case?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.