You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there anything about provenance that should be documented on these? Right now I think it always uses the provenance of the first pointer for what it puts in the slice; I'm not sure whether it would ever matter.
@scottmcm current implementation uses sub_ptr which has these safety conditions:
Both the starting and other pointer must be either in bounds or one byte past the end of the same allocated object.
Both pointers must be derived from a pointer to the same object. (See below for an example.)
Which I think implies that both pointers must have the same provenance.
The current documentation of from_ptr_range already mentions that it must be the same allocated object, but it doesn't mention how the pointers must be derived...
The range must contain N consecutive properly initialized values of type T:
The entire memory range of this slice must be contained within a single allocated object! Slices can never span across multiple allocated objects.
Can someone add #97419 to the implementation history? It made the functions const under cons_slice_from_ptr_ranget and const_slice_from_mut_ptr_range features (this also should be added in the description). It also added a reexport of these functions to alloc and std, previously these functions were only accessible via core.
What's the behavior of these functions when T is ZST? Currently, the implementation calls pointer::offset_from, which panics if T is ZST. Maybe we have to add this to the documentation?
Activity
scottmcm commentedon Mar 4, 2022
Is there anything about provenance that should be documented on these? Right now I think it always uses the provenance of the first pointer for what it puts in the slice; I'm not sure whether it would ever matter.
Rollup merge of rust-lang#97419 - WaffleLapkin:const_from_ptr_range, …
WaffleLapkin commentedon May 30, 2022
@scottmcm current implementation uses
sub_ptrwhich has these safety conditions:Which I think implies that both pointers must have the same provenance.
The current documentation of
from_ptr_rangealready mentions that it must be the same allocated object, but it doesn't mention how the pointers must be derived...Rollup merge of rust-lang#97419 - WaffleLapkin:const_from_ptr_range, …
WaffleLapkin commentedon Jun 2, 2022
Can someone add #97419 to the implementation history? It made the functions
constundercons_slice_from_ptr_rangetandconst_slice_from_mut_ptr_rangefeatures (this also should be added in the description). It also added a reexport of these functions toallocandstd, previously these functions were only accessible viacore.wx-csy commentedon Oct 2, 2022
What's the behavior of these functions when
Tis ZST? Currently, the implementation callspointer::offset_from, which panics ifTis ZST. Maybe we have to add this to the documentation?Rollup merge of rust-lang#129892 - oskgo:clarify-slice-from-raw, r=Ra…
Rollup merge of rust-lang#129892 - oskgo:clarify-slice-from-raw, r=Ra…
Unrolled build for rust-lang#129892