-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Clarify story on *T (unsafe pointers) #7362
Comments
nominating production ready |
I'm becoming more inclined to just remove |
Repurposing this issue to, more generally, talk about clarifying the unsafe pointer story. Milestone 1, well-defined |
I'm very strongly against removing Example of this I fixed recently, where a non- If we ever start informing LLVM of mutability/immutability (assuming this is possible), then doing the above would be undefined behaviour. One might argue "FFI is unsafe anyway", but |
(To be clear: I'm strongly against removing |
@huonw It seems to me that this rather argues for the change than against it. As I wrote recently in an e-mail thread, my concern with I could imagine adding I think that the only sensible interpretation of the current pointer types is that |
The |
Thinking more on the issue, I'm pretty sure that our current types are wrong, but I'm not yet sure of the best fix. It would be nice if the bug @huonw mentions could not occur so easily. The fundamental problem seems to be that @erickt you may have an opinion here, I know that safety of |
(You're missing the link.) |
Much of this problem would be addressed with #2124, e.g., resulting in That said, I do agree that
I think this is the crux of what I'm saying. FWIW, I'm personally happy with pretty much any syntax as long as we have the distinction in some form or another, to assist people writing FFI/unsafe code as much as is reasonable (in particular, I have no attachment to the current |
This does not yet change the compiler and libraries from `*T` to `*const T` as it will require a snapshot to do so. cc rust-lang#7362
This does not yet change the compiler and libraries from `*T` to `*const T` as it will require a snapshot to do so. cc #7362 --- Note that the corresponding RFC, rust-lang/rfcs#68, has not yet been accepted. It was [discussed at the last meeting](https://github.com/rust-lang/rust/wiki/Meeting-weekly-2014-06-10#rfc-pr-68-unsafe-pointers-rename-t-to-const-t) and decided to be accepted, however. I figured I'd get started on the preliminary work for the RFC that will be required regardless.
Now that #15208 is closed, nominating for closing. |
Closing, yay! |
Currently we automatically coerce from
&Foo
to*Foo
, which makes interop much nicer. However, for C APIs that have some calls taking*mut Foo
and some*Foo
(getters and setters on an opaque structure for example), you must currently do a lot of&*foo
to turn*mut Foo
into*Foo
. It would be much more convenient to coerce to immutable automatically.I feel like the current situation punishes correct type annotation of FFI calls.
@nikomatsakis mentioned in IRC that
*mut Foo
might just go away, but if it's here to stay, then more coersion would be nice.The text was updated successfully, but these errors were encountered: