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

Types only referenced by bindgen layout checks incorrectly handled #13

Open
bjorn3 opened this issue Oct 15, 2024 · 0 comments
Open

Types only referenced by bindgen layout checks incorrectly handled #13

bjorn3 opened this issue Oct 15, 2024 · 0 comments

Comments

@bjorn3
Copy link
Member

bjorn3 commented Oct 15, 2024

struct group {
    gr_name: *const u8,
    gr_passwd: *const u8,
    gr_gid: *const u8,
    gr_mem: *const u8,
}

#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
    ["Size of group"][::std::mem::size_of::<group>() - 32usize];
    ["Alignment of group"][::std::mem::align_of::<group>() - 8usize];
    ["Offset of field: group::gr_name"][::std::mem::offset_of!(group, gr_name) - 0usize];
    ["Offset of field: group::gr_passwd"][::std::mem::offset_of!(group, gr_passwd) - 8usize];
    ["Offset of field: group::gr_gid"][::std::mem::offset_of!(group, gr_gid) - 16usize];
    ["Offset of field: group::gr_mem"][::std::mem::offset_of!(group, gr_mem) - 24usize];
};

results in

warning: struct `group` is never constructed
   --> src/pam/sys.rs:148:8
    |
148 | struct group {
    |        ^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

which causes cargo-minify to remove the group struct which then results in a whole bunch of errors. Ideally the layout checks would be removed too, but if that is not possible, it should avoid removing group.

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

No branches or pull requests

1 participant