-
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
Rewrite the improper_ctypes lint. #26583
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
With some help on IRC, I got part of the way handling projection types (54e183f). Still doesn't work completely correctly, though; not sure what's missing. |
☔ The latest upstream changes (presumably #26575) made this pull request unmergeable. Please resolve the merge conflicts. |
060b6eb
to
f951898
Compare
Rebased, and updated with some handling for late-bound lifetimes. Ready to be reviewed, I think? |
☔ The latest upstream changes (presumably #26694) made this pull request unmergeable. Please resolve the merge conflicts. |
Rebased. |
Ping. |
r? @nrc |
pub fn is_ffi_safe(&'tcx self, cx: &ctxt<'tcx>) -> bool { | ||
!self.type_contents(cx).intersects(TC::ReachesFfiUnsafe) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean we no longer use ReachesFfiUnsafe
at all? If so, it should be removed, not just this helper function.
dcc0cbb
to
484d071
Compare
Updated to address review comments. Function pointers are now checked. Tuples are now disallowed. Zero-size structs are now disallowed. |
Seems reasonable |
@bors r+ |
📌 Commit 484d071 has been approved by |
⌛ Testing commit 484d071 with merge d7e2f6f... |
📌 Commit 8d47c3d has been approved by |
⌛ Testing commit 8d47c3d with merge 3825fc1... |
💔 Test failed - auto-mac-64-nopt-t |
Fixed again... |
@bors r+ |
📌 Commit 858a1b9 has been approved by |
⌛ Testing commit 858a1b9 with merge 48ef346... |
💔 Test failed - auto-win-msvc-64-opt |
Makes the lint a bit more accurate, and improves the quality of the diagnostic messages by explicitly returning an error message. The new lint is also a little more aggressive: specifically, it now rejects tuples, and it recurses into function pointers.
Fixed again... |
Makes the lint a bit more accurate, and improves the quality of the diagnostic messages by explicitly returning an error message.
These warnings starting appearing from rust-lang/rust#26583.
These warnings starting appearing from rust-lang/rust#26583.
This warning starting appearing from rust-lang/rust#26583.
…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 { ... }`.
Makes the lint a bit more accurate, and improves the quality of the diagnostic
messages by explicitly returning an error message.