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

Latest nightly compiler reports dead_code warnings for structs with private fields #3740

Closed
asomers opened this issue Jun 8, 2024 · 2 comments
Labels
C-bug Category: bug

Comments

@asomers
Copy link
Contributor

asomers commented Jun 8, 2024

Sometime in the last week the rustc nightly compiler got more aggressive about reporting dead_code warnings. It now warns whenever a struct contains a private field but no constructor. That catches many structs in libc, which are intended to be initialized with std::mem::zeroed(). IMHO this is a rustc bug. This ought to be a separate lint so it can be silenced without silencing all dead_code warnings.

Here's an example build failure:
https://cirrus-ci.com/task/6392171014651904?logs=test#L17

@my4ng
Copy link
Contributor

my4ng commented Jun 13, 2024

I don't think the change is going to get reverted or changed IMO. One workaround would be to add allow(dead_code) to all affected structs, but that can easily hide potential problems. Another is to change all the private fields to public, and I think this was the suggestion in the upstream issue.

Dajamante added a commit to ferrocene/ferrocene that referenced this issue Jun 13, 2024
added dead_code lint while this needs fix:
rust-lang/libc#3740

deleted Makefiles annotations are still covered
- ferrocene-annotations: um_rustc_C_link_args
- ferrocene-annotations: um_rustc_C_codegen_units
- ferrocene-annotations: um_rustc_C_prefer_dynamic
Dajamante added a commit to ferrocene/ferrocene that referenced this issue Jun 14, 2024
added dead_code lint while this needs fix:
rust-lang/libc#3740
@tgross35
Copy link
Contributor

With rust-lang/rust#128404, I think this has been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants