@@ -247,24 +247,7 @@ impl<T: ?Sized> *mut T {
247
247
/// # Safety
248
248
///
249
249
/// When calling this method, you have to ensure that *either* the pointer is null *or*
250
- /// all of the following is true:
251
- ///
252
- /// * The pointer must be properly aligned.
253
- ///
254
- /// * It must be "dereferenceable" in the sense defined in [the module documentation].
255
- ///
256
- /// * The pointer must point to an initialized instance of `T`.
257
- ///
258
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
259
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
260
- /// In particular, while this reference exists, the memory the pointer points to must
261
- /// not get mutated (except inside `UnsafeCell`).
262
- ///
263
- /// This applies even if the result of this method is unused!
264
- /// (The part about being initialized is not yet fully decided, but until
265
- /// it is, the only safe approach is to ensure that they are indeed initialized.)
266
- ///
267
- /// [the module documentation]: crate::ptr#safety
250
+ /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
268
251
///
269
252
/// # Examples
270
253
///
@@ -313,24 +296,7 @@ impl<T: ?Sized> *mut T {
313
296
///
314
297
/// # Safety
315
298
///
316
- /// When calling this method, you have to ensure that all of the following is true:
317
- ///
318
- /// * The pointer must be properly aligned.
319
- ///
320
- /// * It must be "dereferenceable" in the sense defined in [the module documentation].
321
- ///
322
- /// * The pointer must point to an initialized instance of `T`.
323
- ///
324
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
325
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
326
- /// In particular, while this reference exists, the memory the pointer points to must
327
- /// not get mutated (except inside `UnsafeCell`).
328
- ///
329
- /// This applies even if the result of this method is unused!
330
- /// (The part about being initialized is not yet fully decided, but until
331
- /// it is, the only safe approach is to ensure that they are indeed initialized.)
332
- ///
333
- /// [the module documentation]: crate::ptr#safety
299
+ /// When calling this method, you have to ensure that the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
334
300
///
335
301
/// # Examples
336
302
///
@@ -364,20 +330,9 @@ impl<T: ?Sized> *mut T {
364
330
/// # Safety
365
331
///
366
332
/// When calling this method, you have to ensure that *either* the pointer is null *or*
367
- /// all of the following is true:
368
- ///
369
- /// * The pointer must be properly aligned.
370
- ///
371
- /// * It must be "dereferenceable" in the sense defined in [the module documentation].
372
- ///
373
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
374
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
375
- /// In particular, while this reference exists, the memory the pointer points to must
376
- /// not get mutated (except inside `UnsafeCell`).
377
- ///
378
- /// This applies even if the result of this method is unused!
379
- ///
380
- /// [the module documentation]: crate::ptr#safety
333
+ /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
334
+ /// Note that because the created reference is to `MaybeUninit<T>`, the
335
+ /// source pointer can point to uninitialized memory.
381
336
///
382
337
/// # Examples
383
338
///
@@ -609,25 +564,10 @@ impl<T: ?Sized> *mut T {
609
564
///
610
565
/// # Safety
611
566
///
612
- /// When calling this method, you have to ensure that *either* the pointer is null *or*
613
- /// all of the following is true:
614
- ///
615
- /// * The pointer must be properly aligned.
616
- ///
617
- /// * It must be "dereferenceable" in the sense defined in [the module documentation].
618
- ///
619
- /// * The pointer must point to an initialized instance of `T`.
567
+ /// When calling this method, you have to ensure that *either*
568
+ /// the pointer is null *or*
569
+ /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
620
570
///
621
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
622
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
623
- /// In particular, while this reference exists, the memory the pointer points to must
624
- /// not get accessed (read or written) through any other pointer.
625
- ///
626
- /// This applies even if the result of this method is unused!
627
- /// (The part about being initialized is not yet fully decided, but until
628
- /// it is, the only safe approach is to ensure that they are indeed initialized.)
629
- ///
630
- /// [the module documentation]: crate::ptr#safety
631
571
///
632
572
/// # Examples
633
573
///
@@ -675,24 +615,8 @@ impl<T: ?Sized> *mut T {
675
615
///
676
616
/// # Safety
677
617
///
678
- /// When calling this method, you have to ensure that all of the following is true:
679
- ///
680
- /// * The pointer must be properly aligned.
681
- ///
682
- /// * It must be "dereferenceable" in the sense defined in [the module documentation].
683
- ///
684
- /// * The pointer must point to an initialized instance of `T`.
685
- ///
686
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
687
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
688
- /// In particular, while this reference exists, the memory the pointer points to must
689
- /// not get mutated (except inside `UnsafeCell`).
690
- ///
691
- /// This applies even if the result of this method is unused!
692
- /// (The part about being initialized is not yet fully decided, but until
693
- /// it is, the only safe approach is to ensure that they are indeed initialized.)
694
- ///
695
- /// [the module documentation]: crate::ptr#safety
618
+ /// When calling this method, you have to ensure that
619
+ /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
696
620
///
697
621
/// # Examples
698
622
///
@@ -727,20 +651,7 @@ impl<T: ?Sized> *mut T {
727
651
/// # Safety
728
652
///
729
653
/// When calling this method, you have to ensure that *either* the pointer is null *or*
730
- /// all of the following is true:
731
- ///
732
- /// * The pointer must be properly aligned.
733
- ///
734
- /// * It must be "dereferenceable" in the sense defined in [the module documentation].
735
- ///
736
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
737
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
738
- /// In particular, while this reference exists, the memory the pointer points to must
739
- /// not get accessed (read or written) through any other pointer.
740
- ///
741
- /// This applies even if the result of this method is unused!
742
- ///
743
- /// [the module documentation]: crate::ptr#safety
654
+ /// the pointer is [convertible to a reference](crate::ptr#pointer-to-reference-conversion).
744
655
#[ inline]
745
656
#[ unstable( feature = "ptr_as_uninit" , issue = "75402" ) ]
746
657
#[ rustc_const_unstable( feature = "const_ptr_as_ref" , issue = "91822" ) ]
0 commit comments