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 up"Safe" Gecko binding sugars allow undefined behavior in safe Rust #15477
Comments
Another way to do this is to "flatten" that supermodule, use |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
style::gecko_bindings::sugarmodule implements various safe methods and traits for FFI types from Gecko. However, many of these methods are actually unsafe because they depend on invariants that are not enforced. For example, this program has undefined behavior without usingunsafe:Since the structs’ fields are public, we can’t statically enforce invariants on them. Assuming we don’t want to add runtime checks, we need to make sure these methods and impls can be used only on valid struct values. Possible solutions:
pub(super)or similar to make their fields public within some trusted supermodule, but private to outside code. Not yet possible in stable Rust (rust-lang/rust#32409).