-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Raw pointer coercion #361
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Raw pointer coercion #361
Conversation
Yes Thank you This is a constant source of pain with the |
+1 (#16926) |
Definitely. I doubt that the current behavior is intended. |
+1 |
I was hesitant at first to allow these (philosophically we are dereferencing the raw pointer, which is unsafe, and then referencing with a different raw point), but since we don't actually do a dereference I think they are fine. I have a big RFCs on coercions almost ready which includes this change too. |
Counterpoint: remove Pointers have no semantics, they just point to things. There is no difference between Pure Rust does not need it, references work better. C bindings don't need it either, just running bindgen won't give you the full story anyway. A C binding needs the full documentation encoded in a safe interface, not just individual unsafe signatures. |
assigning to @nick29581 to shepherd |
Should we then remove |
I'm not sure I agree with @Jurily about the need for const raw pointers. Even in C, constness is used as a hint for mutability and ownership transfer, allowing to catch many errors. |
Rust can express the We already need
|
I do think it is worth talking about these things, but this particular RFC is just about some very simple and safe additions to the coercion rules. |
@nick29581: Do you think this RFC needs more details or discussion? |
Feel free to add the content of this RFC to #401 if it's not already a superset. There was little debate here regarding the content of the RFC and I believe this RFC could be implemented quickly. There are enormous ergonomics benefits to be had for all those who work with lots of FFI code. Therefore I would appreciate it if this RFC could be merged and implemented quickly, even if it is later superseded by your RFC. |
#401 has been accepted and I believe includes everything in this one. Closing for now, but if there is anything I've missed and I can re-open |
*mut T
and&mut T
should coerce to*const T
.Rendered