@@ -320,25 +320,31 @@ impl<T: ?Sized> *const T {
320320 /// * Both pointers must be *derived from* a pointer to the same object.
321321 /// (See below for an example.)
322322 ///
323- /// * The distance between the pointers, **in bytes**, cannot overflow an `isize`.
324- ///
325323 /// * The distance between the pointers, in bytes, must be an exact multiple
326324 /// of the size of `T`.
327325 ///
326+ /// * The distance between the pointers, **in bytes**, cannot overflow an `isize`.
327+ ///
328328 /// * The distance being in bounds cannot rely on "wrapping around" the address space.
329329 ///
330- /// The compiler and standard library generally try to ensure allocations
331- /// never reach a size where an offset is a concern. For instance, `Vec`
332- /// and `Box` ensure they never allocate more than `isize::MAX` bytes, so
333- /// `ptr_into_vec.offset_from(vec.as_ptr())` is always safe.
330+ /// Rust types are never larger than `isize::MAX` and Rust allocations never wrap around the
331+ /// address space, so two pointers within some value of any Rust type `T` will always satisfy
332+ /// the last two conditions. The standard library also generally ensures that allocations
333+ /// never reach a size where an offset is a concern. For instance, `Vec` and `Box` ensure they
334+ /// never allocate more than `isize::MAX` bytes, so `ptr_into_vec.offset_from(vec.as_ptr())`
335+ /// always satisfies the last two conditions.
334336 ///
335- /// Most platforms fundamentally can't even construct such an allocation.
337+ /// Most platforms fundamentally can't even construct such a large allocation.
336338 /// For instance, no known 64-bit platform can ever serve a request
337339 /// for 2<sup>63</sup> bytes due to page-table limitations or splitting the address space.
338340 /// However, some 32-bit and 16-bit platforms may successfully serve a request for
339341 /// more than `isize::MAX` bytes with things like Physical Address
340342 /// Extension. As such, memory acquired directly from allocators or memory
341343 /// mapped files *may* be too large to handle with this function.
344+ /// (Note that [`offset`] and [`add`] also have a similar limitation and hence cannot be used on
345+ /// such large allocations either.)
346+ ///
347+ /// [`add`]: #method.add
342348 ///
343349 /// # Panics
344350 ///
0 commit comments