@@ -1074,17 +1074,22 @@ impl<T: ?Sized> *const T {
10741074 /// operation because the returned value could be pointing to invalid
10751075 /// memory.
10761076 ///
1077- /// When calling this method, you have to ensure that if the pointer is
1078- /// non-NULL, then it is properly aligned, dereferencable (for the whole
1079- /// size of `T`) and points to an initialized instance of `T`. This applies
1080- /// even if the result of this method is unused!
1077+ /// When calling this method, you have to ensure that *either* the pointer is NULL *or*
1078+ /// all of the following is true:
1079+ /// - it is properly aligned
1080+ /// - it must point to an initialized instance of T; in particular, the pointer must be
1081+ /// "dereferencable" in the sense defined [here].
1082+ ///
1083+ /// This applies even if the result of this method is unused!
10811084 /// (The part about being initialized is not yet fully decided, but until
10821085 /// it is, the only safe approach is to ensure that they are indeed initialized.)
10831086 ///
10841087 /// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
1085- /// not necessarily reflect the actual lifetime of the data. It is up to the
1086- /// caller to ensure that for the duration of this lifetime, the memory this
1087- /// pointer points to does not get written to outside of `UnsafeCell<U>`.
1088+ /// not necessarily reflect the actual lifetime of the data. *You* must enforce
1089+ /// Rust's aliasing rules. In particular, for the duration of this lifetime,
1090+ /// the memory the pointer points to must not get mutated (except inside `UnsafeCell`).
1091+ ///
1092+ /// [here]: crate::ptr#safety
10881093 ///
10891094 /// # Examples
10901095 ///
@@ -1929,18 +1934,23 @@ impl<T: ?Sized> *mut T {
19291934 /// of the returned pointer, nor can it ensure that the lifetime `'a`
19301935 /// returned is indeed a valid lifetime for the contained data.
19311936 ///
1932- /// When calling this method, you have to ensure that if the pointer is
1933- /// non-NULL, then it is properly aligned, dereferencable (for the whole
1934- /// size of `T`) and points to an initialized instance of `T`. This applies
1935- /// even if the result of this method is unused!
1937+ /// When calling this method, you have to ensure that *either* the pointer is NULL *or*
1938+ /// all of the following is true:
1939+ /// - it is properly aligned
1940+ /// - it must point to an initialized instance of T; in particular, the pointer must be
1941+ /// "dereferencable" in the sense defined [here].
1942+ ///
1943+ /// This applies even if the result of this method is unused!
19361944 /// (The part about being initialized is not yet fully decided, but until
19371945 /// it is the only safe approach is to ensure that they are indeed initialized.)
19381946 ///
19391947 /// Additionally, the lifetime `'a` returned is arbitrarily chosen and does
1940- /// not necessarily reflect the actual lifetime of the data. It is up to the
1941- /// caller to ensure that for the duration of this lifetime, the memory this
1942- /// pointer points to does not get accessed through any other pointer.
1948+ /// not necessarily reflect the actual lifetime of the data. *You* must enforce
1949+ /// Rust's aliasing rules. In particular, for the duration of this lifetime,
1950+ /// the memory this pointer points to must not get accessed (read or written)
1951+ /// through any other pointer.
19431952 ///
1953+ /// [here]: crate::ptr#safety
19441954 /// [`as_ref`]: #method.as_ref
19451955 ///
19461956 /// # Examples
0 commit comments