Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit402992c

Browse files
authored
Rollup merge ofrust-lang#127071 - Sky9x:remove-ptr-to-from-bits, r=scottmcm
Remove (deprecated & unstable) {to,from}_bits pointer methodsThese unstable methods have been deprecated for more than a year (sincerust-lang#95583). Remove them.Seerust-lang#91126 (comment) andhttps://github.com/rust-lang/rust/pull/110441/files#r1169574509.Closesrust-lang#91126.r? `@scottmcm`
2 parents0a2d8e4 +a722d39 commit402992c

File tree

2 files changed

+0
-131
lines changed

2 files changed

+0
-131
lines changed

‎core/src/ptr/const_ptr.rs‎

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -112,71 +112,6 @@ impl<T: ?Sized> *const T {
112112
selfas_
113113
}
114114

115-
/// Casts a pointer to its raw bits.
116-
///
117-
/// This is equivalent to `as usize`, but is more specific to enhance readability.
118-
/// The inverse method is [`from_bits`](#method.from_bits).
119-
///
120-
/// In particular, `*p as usize` and `p as usize` will both compile for
121-
/// pointers to numeric types but do very different things, so using this
122-
/// helps emphasize that reading the bits was intentional.
123-
///
124-
/// # Examples
125-
///
126-
/// ```
127-
/// #![feature(ptr_to_from_bits)]
128-
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
129-
/// let array = [13, 42];
130-
/// let p0: *const i32 = &array[0];
131-
/// assert_eq!(<*const _>::from_bits(p0.to_bits()), p0);
132-
/// let p1: *const i32 = &array[1];
133-
/// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
134-
/// # }
135-
/// ```
136-
#[unstable(feature ="ptr_to_from_bits", issue ="91126")]
137-
#[deprecated(
138-
since ="1.67.0",
139-
note ="replaced by the `expose_provenance` method, or update your code\
140-
to follow the strict provenance rules using its APIs"
141-
)]
142-
#[inline(always)]
143-
pubfnto_bits(self) ->usize
144-
where
145-
T:Sized,
146-
{
147-
selfasusize
148-
}
149-
150-
/// Creates a pointer from its raw bits.
151-
///
152-
/// This is equivalent to `as *const T`, but is more specific to enhance readability.
153-
/// The inverse method is [`to_bits`](#method.to_bits).
154-
///
155-
/// # Examples
156-
///
157-
/// ```
158-
/// #![feature(ptr_to_from_bits)]
159-
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
160-
/// use std::ptr::NonNull;
161-
/// let dangling: *const u8 = NonNull::dangling().as_ptr();
162-
/// assert_eq!(<*const u8>::from_bits(1), dangling);
163-
/// # }
164-
/// ```
165-
#[unstable(feature ="ptr_to_from_bits", issue ="91126")]
166-
#[deprecated(
167-
since ="1.67.0",
168-
note ="replaced by the `ptr::with_exposed_provenance` function, or update\
169-
your code to follow the strict provenance rules using its APIs"
170-
)]
171-
#[allow(fuzzy_provenance_casts)]// this is an unstable and semi-deprecated cast function
172-
#[inline(always)]
173-
pubfnfrom_bits(bits:usize) ->Self
174-
where
175-
T:Sized,
176-
{
177-
bitsasSelf
178-
}
179-
180115
/// Gets the "address" portion of the pointer.
181116
///
182117
/// This is similar to `self as usize`, which semantically discards *provenance* and

‎core/src/ptr/mut_ptr.rs‎

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -117,72 +117,6 @@ impl<T: ?Sized> *mut T {
117117
selfas_
118118
}
119119

120-
/// Casts a pointer to its raw bits.
121-
///
122-
/// This is equivalent to `as usize`, but is more specific to enhance readability.
123-
/// The inverse method is [`from_bits`](pointer#method.from_bits-1).
124-
///
125-
/// In particular, `*p as usize` and `p as usize` will both compile for
126-
/// pointers to numeric types but do very different things, so using this
127-
/// helps emphasize that reading the bits was intentional.
128-
///
129-
/// # Examples
130-
///
131-
/// ```
132-
/// #![feature(ptr_to_from_bits)]
133-
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
134-
/// let mut array = [13, 42];
135-
/// let mut it = array.iter_mut();
136-
/// let p0: *mut i32 = it.next().unwrap();
137-
/// assert_eq!(<*mut _>::from_bits(p0.to_bits()), p0);
138-
/// let p1: *mut i32 = it.next().unwrap();
139-
/// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
140-
/// }
141-
/// ```
142-
#[unstable(feature ="ptr_to_from_bits", issue ="91126")]
143-
#[deprecated(
144-
since ="1.67.0",
145-
note ="replaced by the `expose_provenance` method, or update your code\
146-
to follow the strict provenance rules using its APIs"
147-
)]
148-
#[inline(always)]
149-
pubfnto_bits(self) ->usize
150-
where
151-
T:Sized,
152-
{
153-
selfasusize
154-
}
155-
156-
/// Creates a pointer from its raw bits.
157-
///
158-
/// This is equivalent to `as *mut T`, but is more specific to enhance readability.
159-
/// The inverse method is [`to_bits`](pointer#method.to_bits-1).
160-
///
161-
/// # Examples
162-
///
163-
/// ```
164-
/// #![feature(ptr_to_from_bits)]
165-
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
166-
/// use std::ptr::NonNull;
167-
/// let dangling: *mut u8 = NonNull::dangling().as_ptr();
168-
/// assert_eq!(<*mut u8>::from_bits(1), dangling);
169-
/// }
170-
/// ```
171-
#[unstable(feature ="ptr_to_from_bits", issue ="91126")]
172-
#[deprecated(
173-
since ="1.67.0",
174-
note ="replaced by the `ptr::with_exposed_provenance_mut` function, or\
175-
update your code to follow the strict provenance rules using its APIs"
176-
)]
177-
#[allow(fuzzy_provenance_casts)]// this is an unstable and semi-deprecated cast function
178-
#[inline(always)]
179-
pubfnfrom_bits(bits:usize) ->Self
180-
where
181-
T:Sized,
182-
{
183-
bitsasSelf
184-
}
185-
186120
/// Gets the "address" portion of the pointer.
187121
///
188122
/// This is similar to `self as usize`, which semantically discards *provenance* and

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp