-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
dead_code lint warns about struct fields it can't actually know are dead due to C FFI #15101
Comments
/cc @jakub-. The PR that introduced this behavior was #14696. |
Hrm, ok I just took another look, and apparently #14309 includes adding a lint for warning about non- /cc @cmr |
If #14309 isn't implemented in a timely manner we can revisit opening this. |
Check Workspace Edit ResourceOps PR fixes rust-lang#14780
Purge of unwraps Removes unnecessary unwraps that I have overlooked in rust-lang#15101 ( fixes rust-lang#15176 )
The
dead_code
lint has started warning about struct fields, in 9bb8f88. The problem is, it does this even if it can't guarantee the field is actually dead. Notably, it warns about struct fields for structs that are passed as*mut
pointers to C FFI functions. In this case, my Rust code only zero-initializes the field, and never reads it because it's purely for use by the C FFI function.This reproduces with lilyball/rust-lua@be46e268c with the
lua_Debug
struct (inraw.rs
). It has a single private field that's used by the Lua C functions internally, and is intentionally not touched (beyond being zero-initialized) by the Rust code.I think the solution here is for the
dead_code
lint to assume that anyextern { fn }
that takes a*mut
pointer to a struct may potentially use every field of the struct, and therefore to treat any fields of structs with said C FFI functions as live regardless of whether the Rust code touches them.The text was updated successfully, but these errors were encountered: