File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -255,12 +255,17 @@ extern "rust-intrinsic" {
255
255
/// Returns `true` if a type is managed (will be allocated on the local heap)
256
256
pub fn owns_managed < T > ( ) -> bool ;
257
257
258
- /// Calculates the offset from a pointer. The offset *must* be in-bounds of
259
- /// the object, or one-byte-past-the-end. An arithmetic overflow is also
260
- /// undefined behaviour.
258
+ /// Calculates the offset from a pointer.
261
259
///
262
260
/// This is implemented as an intrinsic to avoid converting to and from an
263
261
/// integer, since the conversion would throw away aliasing information.
262
+ ///
263
+ /// # Safety
264
+ ///
265
+ /// Both the starting and resulting pointer must be either in bounds or one
266
+ /// byte past the end of an allocated object. If either pointer is out of
267
+ /// bounds or arithmetic overflow occurs then any further use of the
268
+ /// returned value will result in undefined behavior.
264
269
pub fn offset < T > ( dst : * const T , offset : isize ) -> * const T ;
265
270
266
271
/// Copies `count * size_of<T>` bytes from `src` to `dst`. The source
Original file line number Diff line number Diff line change @@ -284,9 +284,10 @@ impl<T: ?Sized> *const T {
284
284
///
285
285
/// # Safety
286
286
///
287
- /// The offset must be in-bounds of the object, or one-byte-past-the-end.
288
- /// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
289
- /// the pointer is used.
287
+ /// Both the starting and resulting pointer must be either in bounds or one
288
+ /// byte past the end of an allocated object. If either pointer is out of
289
+ /// bounds or arithmetic overflow occurs then
290
+ /// any further use of the returned value will result in undefined behavior.
290
291
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
291
292
#[ inline]
292
293
pub unsafe fn offset ( self , count : isize ) -> * const T where T : Sized {
You can’t perform that action at this time.
0 commit comments