Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix improper_ctypes warnings in Rust Nightly #24684
Comments
|
JSContext is indeed not FFI-safe. It should be a jsapi::JSContext instead, and #24653 fixes that. |
|
The Rust team is (kindly) waiting on us to be able to upgrade before landing rust-lang/rust#66344. I have a branch ready for that, but it requires a Nightly more recent than these new warnings. |
|
I’ve looked into this. Unfortunately there is no accidental bug here: the lint was intentionally changed to warn against a pattern that is in pervasive use in our DOM bindings. Specifically: when an Our DOM objects are based on many Rust structs that are not “FFI-safe”: non-Rust code cannot relay on their exact memory layout. Making a struct FFI-safe involves using Currently, raw pointers to a non-FFI-safe type are themselves not considered FFI-safe by the In the meantime, we could unblock the upgrade by adding |
|
I'm fine with being pragmatic when we're blocking the Rust project from making progress. That being said, our DOM objects should already be repr(C). Which types are actually being warned about? |
|
We use |
|
One other solution would be to make the various |
|
It’s possible. I started doing it for the But there are a number of other cases. It’s hard to say without doing it, but I wonder if pushing this to completion would lead us to having |
|
Yeah while that would work, that would be pretty unfortunate. At the moment I‘m making heavy use of stuff like Option<&mut SomeRustType> as parameters in my C FFI, as it both allows for super clean safe handling from Rust‘s side and also nice automatically generated high level bindings for the other side. Reducing it to raw void pointers only would significantly hurt both. |
|
(Did you mean that comment for rust-lang/rust#66220?) |
|
Is this still an issue? |
|
We do not appear to have blanket allow_ctypes in most of our code (based on https://github.com/servo/servo/search?q=improper_ctypes&unscoped_q=improper_ctypes), so I think the answer is no. |
|
This was an issue because we run CI with There is ongoing work at rust-lang/rust#72700 to add it again, but this time:
With the latter change this lint should not be as much of an issue for as the initial version was. |
Steps:
origin/master./mach rustup, which updates therust-toolchainfile./mach buildrust-toolchainchangeWe don’t need to upgrade the Rust version yet, but the next time we do those warnings would block landing the upgrade unless we change CI to allow build warnings.
Is suspect that rust-lang/rust#65134 is what introduced these warnings.