-
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
Make from{,_mut}_ptr_range
const
#97419
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
@rustbot label +T-libs-api -T-libs |
@bors r+ rollup |
📌 Commit 70fe652c8945e73effbddf840309d40eab91988b has been approved by |
@bors r- Please add a test showing some uses of these functions from within const contexts |
@oli-obk should it be a documentation test or where should I place it? |
Maybe wherever from_raw_parts is tested? I think there are some ui tests for when it errors and for when it succeeds |
I haven't found any. All tests that mention |
That's not great, we should test the failure paths for all of these. Please add a new ui test that creates all kinds of bogus slices at compile time and puts them in the final value of a constant or static |
Turns out coming out with bogus slices is not that simple, I have problems with my imagination xD I've added UI tests and also fixed the reexport and feature name. |
This comment has been minimized.
This comment has been minimized.
5f8ebc5
to
f4fff04
Compare
This comment has been minimized.
This comment has been minimized.
I do not understand why CI is failing, locally the test passes just fine :( |
The test is failing on 32 bit systems. You can either emit stderr per bitsize (there's a modifier comment for that) or disable the test on 32 bit. Either wfm, tho the former seems better for coverage. If you do the former you'll have to bless for 32 bit, too. You can do this by passing --target=foo to your x.py command with a 32 bit platform that you can build for locally (for me that is |
@bors r+ |
📌 Commit 3414c03 has been approved by |
why is it just Anyway, I've normalized some more, maybe this time I've fixed all problems? |
Let's try it. @bors r=oli-obk |
📌 Commit 3a2bb78 has been approved by |
⌛ Testing commit 3a2bb78 with merge b7cb2e9f17d546601b4f7276f2c1315261b04b44... |
💔 Test failed - checks-actions |
|
@bors retry spurious network issue |
☀️ Test successful - checks-actions |
Yay 🎉 |
@@ -263,7 +264,8 @@ pub unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { | |||
/// | |||
/// [valid]: ptr#safety | |||
#[unstable(feature = "slice_from_ptr_range", issue = "89792")] | |||
pub unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] { | |||
#[rustc_const_unstable(feature = "slice_from_mut_ptr_range_const", issue = "89792")] |
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.
Oh no, I messed up the feature gate
Finished benchmarking commit (0a43923): comparison url. Instruction count
Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
…compiler-errors Fixup feature name to be more consistent with others `slice_from_mut_ptr_range_const` -> `const_slice_from_mut_ptr_range`, we usually have `const` in the front. I've made a typo in rust-lang#97419
This PR makes the following APIs
const
:Tracking issue: #89792.
Feature for
from_ptr_range
as aconst fn
:slice_from_ptr_range_const
.Feature for
from_mut_ptr_range
as aconst fn
:slice_from_mut_ptr_range_const
.r? @oli-obk