-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Overhaul improper_ctypes output #48221
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
I think it'd be helpful to make that a UI test and have the before/after be a diff in GH (so separate commit moving the file) |
Great idea, will do that (and fix the travis failure) tomorrow. |
4e84ec6
to
8cac9a6
Compare
Done. |
☔ The latest upstream changes (presumably #48203) made this pull request unmergeable. Please resolve the merge conflicts. |
…enums This dates back to at least rust-lang#26583. At the time, usize and isize were considered ffi-unsafe to nudge people away from them, but this changed in the aforementioned PR, making it inconsistent to complain about it in enum discriminants. In fact, repr(usize) is probably the best way to interface with `enum Foo : size_t { ... }`.
- Always name the non-FFI-safe - Explain *why* the type is not FFI-safe - Stop vaguely gesturing at structs/enums/unions if the non-FFI-safe types occured in a field. The last part is arguably a regression, but it's minor now that the non-FFI-safe type is actually named. Removing it avoids some code duplication.
The suggestion is unconditional, so following it could lead to further errors. This is already the case for the repr(C) suggestion, which makes this acceptable, though not *good*. Checking up-front whether the suggestion can help would be great but applies more broadly (and would require some refactoring to avoid duplicating the checks).
8cac9a6
to
4454a2d
Compare
Rebased. |
r=me once travis passes |
…objects It's unhelpful since raw pointers to trait objects are also FFI-unsafe and casting to a thin raw pointer loses the vtable. There are working solutions that _involve_ raw pointers but they're too complex to explain in one line and have serious trade offs.
4454a2d
to
051ea5c
Compare
@bors r=estebank |
📌 Commit 051ea5c has been approved by |
…bank Overhaul improper_ctypes output This snowballed into a rather big set of improvements to the diagnostics of the improper_ctypes lint. See commits for details, including effects of each change on the `compile-fail/improper-ctypes.rs` test (now a UI test), which is pretty gnarly and hopefully not representative of real code, but covers a lot of different error cases. Fixes rust-lang#42050
…bank Overhaul improper_ctypes output This snowballed into a rather big set of improvements to the diagnostics of the improper_ctypes lint. See commits for details, including effects of each change on the `compile-fail/improper-ctypes.rs` test (now a UI test), which is pretty gnarly and hopefully not representative of real code, but covers a lot of different error cases. Fixes rust-lang#42050
This snowballed into a rather big set of improvements to the diagnostics of the improper_ctypes lint. See commits for details, including effects of each change on the
compile-fail/improper-ctypes.rs
test (now a UI test), which is pretty gnarly and hopefully not representative of real code, but covers a lot of different error cases.Fixes #42050