Skip to content
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

Merged
merged 1 commit into from
Jul 24, 2015
Merged

Conversation

eefriedman
Copy link
Contributor

Makes the lint a bit more accurate, and improves the quality of the diagnostic
messages by explicitly returning an error message.

@rust-highfive
Copy link
Collaborator

r? @pcwalton

(rust_highfive has picked a reviewer for you, use r? to override)

@eefriedman
Copy link
Contributor Author

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.

@bors
Copy link
Contributor

bors commented Jun 27, 2015

☔ The latest upstream changes (presumably #26575) made this pull request unmergeable. Please resolve the merge conflicts.

@eefriedman eefriedman force-pushed the lint-ffi branch 2 times, most recently from 060b6eb to f951898 Compare July 2, 2015 02:25
@eefriedman
Copy link
Contributor Author

Rebased, and updated with some handling for late-bound lifetimes. Ready to be reviewed, I think?

@bors
Copy link
Contributor

bors commented Jul 4, 2015

☔ The latest upstream changes (presumably #26694) made this pull request unmergeable. Please resolve the merge conflicts.

@eefriedman
Copy link
Contributor Author

Rebased.

@eefriedman
Copy link
Contributor Author

Ping.

@alexcrichton
Copy link
Member

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned pcwalton Jul 21, 2015
pub fn is_ffi_safe(&'tcx self, cx: &ctxt<'tcx>) -> bool {
!self.type_contents(cx).intersects(TC::ReachesFfiUnsafe)
}

Copy link
Member

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.

@eefriedman eefriedman force-pushed the lint-ffi branch 3 times, most recently from dcc0cbb to 484d071 Compare July 22, 2015 02:04
@eefriedman
Copy link
Contributor Author

Updated to address review comments.

Function pointers are now checked. Tuples are now disallowed. Zero-size structs are now disallowed. is_repr_nullable_ptr is still a separate function; unifying it with the trans enum handling is going to be a big task.

@tomjakubowski
Copy link
Contributor

Any chance fixes (or tests, if these commits already fix them) for #20098 and #19834 could slip in? :-)

@eefriedman
Copy link
Contributor Author

This already fixes and tests #20098 (Box was affected by the same issue as String). #19834 is essentially orthogonal; I don't want to make too many changes at once.

@nrc
Copy link
Member

nrc commented Jul 22, 2015

Pulling the whole algorithm out of trans into librustc is rather complicated... I can do it, but I think I'll submit it as a separate PR (it's a few hundred lines of code).

Seems reasonable

@nrc
Copy link
Member

nrc commented Jul 22, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Jul 22, 2015

📌 Commit 484d071 has been approved by nrc

@bors
Copy link
Contributor

bors commented Jul 22, 2015

⌛ Testing commit 484d071 with merge d7e2f6f...

@bors
Copy link
Contributor

bors commented Jul 23, 2015

📌 Commit 8d47c3d has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jul 23, 2015

⌛ Testing commit 8d47c3d with merge 3825fc1...

@bors
Copy link
Contributor

bors commented Jul 23, 2015

💔 Test failed - auto-mac-64-nopt-t

@eefriedman
Copy link
Contributor Author

Fixed again...

@nrc
Copy link
Member

nrc commented Jul 23, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Jul 23, 2015

📌 Commit 858a1b9 has been approved by nrc

@bors
Copy link
Contributor

bors commented Jul 23, 2015

⌛ Testing commit 858a1b9 with merge 48ef346...

@bors
Copy link
Contributor

bors commented Jul 23, 2015

💔 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.
@eefriedman
Copy link
Contributor Author

Fixed again...

@alexcrichton
Copy link
Member

@bors: r=nrc 6fa17b4

@bors
Copy link
Contributor

bors commented Jul 24, 2015

⌛ Testing commit 6fa17b4 with merge 68e0d13...

bors added a commit that referenced this pull request Jul 24, 2015
Makes the lint a bit more accurate, and improves the quality of the diagnostic
messages by explicitly returning an error message.
@bors bors merged commit 6fa17b4 into rust-lang:master Jul 24, 2015
@arielb1 arielb1 mentioned this pull request Sep 15, 2015
SSheldon added a commit to SSheldon/rust-objc that referenced this pull request Sep 20, 2015
SSheldon added a commit to SSheldon/rust-dispatch that referenced this pull request Sep 21, 2015
SSheldon added a commit to SSheldon/rust-block that referenced this pull request Oct 10, 2015
@TimNN TimNN mentioned this pull request Dec 20, 2015
hanna-kruppe pushed a commit to hanna-kruppe/rust that referenced this pull request Feb 15, 2018
…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 { ... }`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants