Skip to content

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

Open
@workingjubilee

Description

@workingjubilee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)A-clippyArea: ClippyA-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.C-cleanupCategory: PRs that clean code up or issues documenting cleanup.L-improper_ctypesLint: improper_ctypesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions