-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for ptr::slice_from_raw_parts[_mut]
#36925
Comments
Given that |
Why would you want one, but also, this seems like it depends on (yet to be decided?) details of the memory model. Is the fleeting moment where a reference exists in |
If the reference is |
Add functions for building raw slices to libcore implement rust-lang#36925
Add functions for building raw slices to libcore implement rust-lang#36925
Is there anything holding cc @RalfJung #63880 #63851 @rust-lang/wg-unsafe-code-guidelines If I'm reading the various issue threads correctly, the validity invariant of pointer metadata is at max that of the metadata type. For slice pointers, the metadata is typed at Context: I happen to currently be writing a library that cannot use the reference-based functions, because though the pointers are known to be non-null (and valid), it is not (and cannot be, with the current abstraction) known whether the pointer has unique or shared provenance (thus should use |
I don't recall any reason that |
The implementation PR #60667 used this feature requested as a tracking issue, but this wasn’t labelled properly. Doing so now. |
*const [T]
from a ptr and a lenptr::slice_from_raw_parts[_mut]
By the way, rust-lang/rfcs#2580 would also cover this :) |
In stable Rust, the only way to get a
*const [T]
with an arbitrary length is throughslice::from_raw_parts
. Unfortunately, that function returns a&[T]
, which makes it very dubious to use with arbitrary raw pointers.The text was updated successfully, but these errors were encountered: