Skip to content

Commit 4d37d1f

Browse files
committed
Refer to the exposed versions of the methods instead
Changing to those doesn't introduce any new unsoundness over the existing ones, so they're the better "if you won't want to think about it" replacement. But also mention the strict provenance APIs, as that's what we'd rather they use instead.
1 parent 9072281 commit 4d37d1f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

library/core/src/ptr/const_ptr.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ impl<T: ?Sized> *const T {
119119
/// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
120120
/// ```
121121
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
122-
#[rustc_deprecated(since = "1.62", reason = "replaced by the `addr` method")]
122+
#[rustc_deprecated(
123+
since = "1.62",
124+
reason = "replaced by the `exposed_addr` method, or update your code \
125+
to follow the strict provenance rules using its APIs"
126+
)]
123127
pub fn to_bits(self) -> usize
124128
where
125129
T: Sized,
@@ -143,7 +147,8 @@ impl<T: ?Sized> *const T {
143147
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
144148
#[rustc_deprecated(
145149
since = "1.62",
146-
reason = "replaced by the `with_addr` method or the `ptr::invalid` function"
150+
reason = "replaced by the `ptr::from_exposed_addr` function, or update \
151+
your code to follow the strict provenance rules using its APIs"
147152
)]
148153
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
149154
pub fn from_bits(bits: usize) -> Self

library/core/src/ptr/mut_ptr.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ impl<T: ?Sized> *mut T {
125125
/// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
126126
/// ```
127127
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
128-
#[rustc_deprecated(since = "1.62", reason = "replaced by the `addr` method")]
128+
#[rustc_deprecated(
129+
since = "1.62",
130+
reason = "replaced by the `exposed_addr` method, or update your code \
131+
to follow the strict provenance rules using its APIs"
132+
)]
129133
pub fn to_bits(self) -> usize
130134
where
131135
T: Sized,
@@ -149,7 +153,8 @@ impl<T: ?Sized> *mut T {
149153
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
150154
#[rustc_deprecated(
151155
since = "1.62",
152-
reason = "replaced by the `with_addr` method or the `ptr::invalid_mut` function"
156+
reason = "replaced by the `ptr::from_exposed_addr_mut` function, or \
157+
update your code to follow the strict provenance rules using its APIs"
153158
)]
154159
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
155160
pub fn from_bits(bits: usize) -> Self

0 commit comments

Comments
 (0)