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 @@ -301,9 +301,10 @@ impl<T: ?Sized> *const T {
301
301
///
302
302
/// # Safety
303
303
///
304
- /// The offset must be in-bounds of the object, or one-byte-past-the-end.
305
- /// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
306
- /// the pointer is used.
304
+ /// Both the starting and resulting pointer must be either in bounds or one
305
+ /// byte past the end of an allocated object. If either pointer is out of
306
+ /// bounds or arithmetic overflow occurs then
307
+ /// any further use of the returned value will result in undefined behavior.
307
308
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
308
309
#[ inline]
309
310
pub unsafe fn offset ( self , count : isize ) -> * const T where T : Sized {
You can’t perform that action at this time.
0 commit comments