-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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: also check extern fn's #30499
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
6e6ac2e
to
78462fe
Compare
IMO this is a wrong thing to do or at very least needs an RFC process to happen. That is because use of a certain calling convention for functions does not necessarily mean they are meant to be used via FFI. |
I understand your argument and it is the same reason why structs with On the other hand we have people unfamiliar with rust who would have benefited from such a lint (see #19834 (comment)) and I personally would like for rust to check that I did not make a mistake in my c api. I have rarely seen a use for functions with a custom calling convention which were not meant to be used from c, so in my mind warning about them is preferable, especially since you can opt-out of these checks but not opt-in. I see now that the situation is more controversial than I though so I'm going to leave this open for a few days, to wait for some more comments, and then, depending on the response, write a RFC first. Maybe the best solution would be to have three separate lints, one for checking extern blocks (the current |
I've been think some more about this and came to the conclusion that if one can argue that there are use cases for As such I decided to close this pull request for now and instead am going to write an RFC (or open an RFC issue) soon. |
The improper ctypes lint currently only checks functions inside of
extern
blocks. This changes the lint so that it also checks all functions with anextern
calling convention.Closes #19834.
This probably need a crater run.
Edit: I just realised that there's still some stuff to be tested: generics and methods, I will add those soon.