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

improper_ctypes is many clippy lints in 1~2 rustc lints #116963

Open
workingjubilee opened this issue Oct 19, 2023 · 0 comments
Open

improper_ctypes is many clippy lints in 1~2 rustc lints #116963

workingjubilee opened this issue Oct 19, 2023 · 0 comments
Labels
A-clippy Area: Clippy A-diagnostics Area: Messages for errors, warnings, and lints A-FFI Area: Foreign function interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. C-cleanup Category: PRs that clean code up or issues documenting cleanup. L-improper_ctypes Lint: improper_ctypes T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@workingjubilee
Copy link
Member

In general, rustc lints are held to a standard of "low false positives". Sometimes they may be opinionated (e.g. all the style lints), but they should generally at least be correct about what they are linting on. Unfortunately, the improper_ctypes lint is a grab-bag of opinions, but few of them necessarily reflect the actuality of what safe FFI looks like, partly because Rust's in-compiler understanding of C ABIs is actually fairly lacking. They are over-conservative approximations, which must often be responded to with liberal usage of allow(improper_ctypes).

In other words, it's a clippy lint. Probably multiple (it's already split into improper_ctypes_definitions, for instance).

This is not a new concern, considering:

I'm not the only one who has suggested extensively refactoring it:

Perhaps the more niche cases that it warns on should be moved to clippy and allowed to bake for... a while. This, admittedly, would be the first case that I know of for casting a lint down instead of lifting it up, but it may be justified.

@workingjubilee workingjubilee added C-cleanup Category: PRs that clean code up or issues documenting cleanup. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints A-FFI Area: Foreign function interface (FFI) C-bug Category: This is a bug. labels Oct 19, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Oct 19, 2023
@fmease fmease added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-clippy Area: Clippy and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Oct 19, 2023
@jieyouxu jieyouxu added the L-improper_ctypes Lint: improper_ctypes label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-clippy Area: Clippy A-diagnostics Area: Messages for errors, warnings, and lints A-FFI Area: Foreign function interface (FFI) A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. C-cleanup Category: PRs that clean code up or issues documenting cleanup. L-improper_ctypes Lint: improper_ctypes T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants