@@ -47,17 +47,22 @@ impl<T: ?Sized> *mut T {
47
47
/// operation because the returned value could be pointing to invalid
48
48
/// memory.
49
49
///
50
- /// When calling this method, you have to ensure that if the pointer is
51
- /// non-NULL, then it is properly aligned, dereferenceable (for the whole
52
- /// size of `T`) and points to an initialized instance of `T`. This applies
53
- /// even if the result of this method is unused!
50
+ /// When calling this method, you have to ensure that *either* the pointer is NULL *or*
51
+ /// all of the following is true:
52
+ /// - it is properly aligned
53
+ /// - it must point to an initialized instance of T; in particular, the pointer must be
54
+ /// "dereferencable" in the sense defined [here].
55
+ ///
56
+ /// This applies even if the result of this method is unused!
54
57
/// (The part about being initialized is not yet fully decided, but until
55
58
/// it is, the only safe approach is to ensure that they are indeed initialized.)
56
59
///
57
60
/// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
58
- /// not necessarily reflect the actual lifetime of the data. It is up to the
59
- /// caller to ensure that for the duration of this lifetime, the memory this
60
- /// pointer points to does not get written to outside of `UnsafeCell<U>`.
61
+ /// not necessarily reflect the actual lifetime of the data. *You* must enforce
62
+ /// Rust's aliasing rules. In particular, for the duration of this lifetime,
63
+ /// the memory the pointer points to must not get mutated (except inside `UnsafeCell`).
64
+ ///
65
+ /// [here]: crate::ptr#safety
61
66
///
62
67
/// # Examples
63
68
///
0 commit comments