Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to avoid #[repr(packed)] when align is needed #2734

Merged
merged 1 commit into from
Jan 31, 2024

Commits on Jan 31, 2024

  1. try to avoid #[repr(packed)] when align is needed

    Currently rustc forbids compound types from having both a `packed` and
    `align` attribute.
    
    When a source type has both attributes, this may mean it cannot be
    represented with the current rustc. Often, though, one or both of these
    attributes is redundant and can be safely removed from the generated
    Rust code.
    
    Previously, bindgen avoided placing the `align` attribute when it is
    not needed. However, it would always place the `packed` attribute if the
    source type has it, even when it is redundant because the source type is
    "naturally packed".
    
    With this change, bindgen avoids placing `packed` on a type if the
    `packed` is redundant and the type needs an `align` attribute. If the
    type does not have an "align" attribute, then bindgen will still place
    `packed` so as to avoid changing existing working behavior.
    
    This commit also takes out an extraneous `is_packed()` call from
    `StructLayoutTracker::new()` since the value can be passed in from the
    caller; this avoids duplicating work in some cases.
    bertschingert committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    c45be66 View commit details
    Browse the repository at this point in the history