Refactor improper_ctypes to separate "UCG questions" from linting decisions #72774
Labels
A-FFI
Area: Foreign function interface (FFI)
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
L-improper_ctypes
Lint: improper_ctypes
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
(Elaborating on #66220 (comment))
I think that the current state of
improper_ctypes
is difficult to maintain and extend -- especially once we add more lints that are similar but distinct -- because it's a big pile of mud that interleaving several different concerns: UCG-ish questions about ABI and layout guarantees, plus value judgements about how these interact with "proper" FFI, plus diagnostics code and suggestions. I imagine (but have not worked out the details) that we could improve this by separating this code into two "layers":I think such an organization would make it clearer what are the language-level guarantees are (including making it easier to audit and evolve) vs what's just a choice or limitation of some lint. More importantly, it would also enable us to implement (without lots of duplication and without making the visitor even more of a big ball of mud) a broader variety of lints that need similar information. For example:
extern
imports vs definitions(theconst
alternative totransmute
)improper_ctypes
that e.g. prohibits references (due to their aliasing implications which are rarely appropriate in FFI)The text was updated successfully, but these errors were encountered: