-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std: Remove deprecated ptr functions #23503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,10 @@ | |
|
||
use marker::Sized; | ||
|
||
#[cfg(stage0)] pub use self::copy_memory as copy; | ||
#[cfg(stage0)] pub use self::set_memory as write_bytes; | ||
#[cfg(stage0)] pub use self::copy_nonoverlapping_memory as copy_nonoverlapping; | ||
|
||
extern "rust-intrinsic" { | ||
|
||
// NB: These intrinsics take unsafe pointers because they mutate aliased | ||
|
@@ -246,7 +250,7 @@ extern "rust-intrinsic" { | |
/// Copies `count * size_of<T>` bytes from `src` to `dst`. The source | ||
/// and destination may *not* overlap. | ||
/// | ||
/// `copy_nonoverlapping_memory` is semantically equivalent to C's `memcpy`. | ||
/// `copy_nonoverlapping` is semantically equivalent to C's `memcpy`. | ||
/// | ||
/// # Safety | ||
/// | ||
|
@@ -271,9 +275,9 @@ extern "rust-intrinsic" { | |
/// let mut t: T = mem::uninitialized(); | ||
/// | ||
/// // Perform the swap, `&mut` pointers never alias | ||
/// ptr::copy_nonoverlapping_memory(&mut t, &*x, 1); | ||
/// ptr::copy_nonoverlapping_memory(x, &*y, 1); | ||
/// ptr::copy_nonoverlapping_memory(y, &t, 1); | ||
/// ptr::copy_nonoverlapping(&mut t, &*x, 1); | ||
/// ptr::copy_nonoverlapping(x, &*y, 1); | ||
/// ptr::copy_nonoverlapping(y, &t, 1); | ||
/// | ||
/// // y and t now point to the same thing, but we need to completely forget `tmp` | ||
/// // because it's no longer relevant. | ||
|
@@ -282,12 +286,18 @@ extern "rust-intrinsic" { | |
/// } | ||
/// ``` | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[cfg(not(stage0))] | ||
pub fn copy_nonoverlapping<T>(dst: *mut T, src: *const T, count: usize); | ||
|
||
/// dox | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
#[cfg(stage0)] | ||
pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: usize); | ||
|
||
/// Copies `count * size_of<T>` bytes from `src` to `dst`. The source | ||
/// and destination may overlap. | ||
/// | ||
/// `copy_memory` is semantically equivalent to C's `memmove`. | ||
/// `copy` is semantically equivalent to C's `memmove`. | ||
/// | ||
/// # Safety | ||
/// | ||
|
@@ -306,16 +316,28 @@ extern "rust-intrinsic" { | |
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> { | ||
/// let mut dst = Vec::with_capacity(elts); | ||
/// dst.set_len(elts); | ||
/// ptr::copy_memory(dst.as_mut_ptr(), ptr, elts); | ||
/// ptr::copy(dst.as_mut_ptr(), ptr, elts); | ||
/// dst | ||
/// } | ||
/// ``` | ||
/// | ||
#[cfg(not(stage0))] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub fn copy<T>(dst: *mut T, src: *const T, count: usize); | ||
|
||
/// dox | ||
#[cfg(stage0)] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub fn copy_memory<T>(dst: *mut T, src: *const T, count: usize); | ||
|
||
/// Invokes memset on the specified pointer, setting `count * size_of::<T>()` | ||
/// bytes of memory starting at `dst` to `c`. | ||
#[cfg(not(stage0))] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR isn't changing the names, though. It's just bringing the intrinsics in line with the already-stable names to improve the rustdoc output. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (FWIW, I do like this suggestion. But it's probably too late to change at this point.) |
||
|
||
/// dox | ||
#[cfg(stage0)] | ||
#[stable(feature = "rust1", since = "1.0.0")] | ||
pub fn set_memory<T>(dst: *mut T, val: u8, count: usize); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// SNAP
comment pleaseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally very much prefer to not use
// SNAP
as in the past it has ended up causing lots of pain when registering a new snapshot. It simultaneously forces the snapshot-maker to do the work necessary to remove it (which can be quite large and isn't always necessary) and also causes extra pain if a// SNAP
annotation was added after the new snapshot was made.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have some way of marking that lines should be removed with the new snapshot? The amount of permanently-
#[cfg(stage0)]
d code is probably going to keep increasing, and the snapshot maker has to go through this each time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string
stage0
is enough, I regularly clean out viagit grep stage0
whenever a new snapshot is registered. We have very little permanent#[cfg(stage0)]