-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Constify copy
related functions
#83091
Conversation
r? @KodrAus (rust-highfive has picked a reviewer for you, use r? to override) |
What do we want to call the feature gate for copy_to and copy_from? Would it make sense to reuse |
Cc @rust-lang/wg-const-eval
Yeah that makes sense. |
library/core/src/ptr/mod.rs
Outdated
#[rustc_const_unstable(feature = "const_swap", issue = "none")] | ||
pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) { | ||
// FIXME: Is it okay to remove these checks? The same checks were removed for | ||
// ptr::copy_nonoverlapping |
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.
Do we want to keep these checks? The same checks were removed for ptr::copy_nonoverlapping
when it was constified in #79684
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.
For copy_nonoverlapping
we ended up removing them entirely also for performance reasons. I am not sure if those apply here.
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.
"Not sure" as in "Lets undo those changes for now so we can continue with the less controversial changes and maybe consider that for some other time"? Or just "Not sure" :)
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.
"Not sure" as in "let's see what others think"... @oli-obk ?
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.
I'm for removing the checks. I don't see why swap_nonoverlapping
should have them while copy_nonoverlapping
doesn't have them.
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.
Yeah, that's fair.
I have removed the |
library/core/src/ptr/mod.rs
Outdated
@@ -394,7 +394,8 @@ pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] { | |||
/// ``` | |||
#[inline] | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
pub unsafe fn swap<T>(x: *mut T, y: *mut T) { | |||
#[rustc_const_unstable(feature = "const_swap", issue = "none")] |
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.
could you create and reference an issue for these?
one commit per feature gate is great, thanks! Once all unstable feature attributes have an issue instead of |
@usbalbin: 🔑 Insufficient privileges: Not in reviewers |
copy
related functions
@bors r=oli-obk |
📌 Commit db9a53b has been approved by |
Rollup of 10 pull requests Successful merges: - rust-lang#81822 (Added `try_exists()` method to `std::path::Path`) - rust-lang#83072 (Update `Vec` docs) - rust-lang#83077 (rustdoc: reduce GC work during search) - rust-lang#83091 (Constify `copy` related functions) - rust-lang#83156 (Fall-back to sans-serif if Arial is not available) - rust-lang#83157 (No background for code in portability snippets) - rust-lang#83160 (Deprecate RustcEncodable and RustcDecodable.) - rust-lang#83162 (Specify *.woff2 files as binary) - rust-lang#83172 (More informative diagnotic from `x.py test` attempt atop beta checkout) - rust-lang#83196 (Use delay_span_bug instead of panic in layout_scalar_valid_range) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…Mark-Simulacrum Make copy/copy_nonoverlapping fn's again Make copy/copy_nonoverlapping fn's again, rather than intrinsics. This a short-term change to address issue rust-lang#84297. It effectively reverts PRs rust-lang#81167 rust-lang#81238 (and part of rust-lang#82967), rust-lang#83091, and parts of rust-lang#79684.
…Mark-Simulacrum Make copy/copy_nonoverlapping fn's again Make copy/copy_nonoverlapping fn's again, rather than intrinsics. This a short-term change to address issue rust-lang#84297. It effectively reverts PRs rust-lang#81167 rust-lang#81238 (and part of rust-lang#82967), rust-lang#83091, and parts of rust-lang#79684.
Constify
*const T::copy_to[_nonoverlapping]
*mut T::copy_to[_nonoverlapping]
*mut T::copy_from[_nonoverlapping]
mem::transmute_copy
mem::swap
ptr::swap[_nonoverlapping]
mem::replace
ptr::replace