Skip to content
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 slice::{split_at,split_at_unchecked} const functions #100076

Merged
merged 2 commits into from
Aug 26, 2022

Conversation

tspiteri
Copy link
Contributor

@tspiteri tspiteri commented Aug 2, 2022

Now that slice::from_raw_parts is const in stable 1.64, it makes sense to have split_at const as well, otherwise unsafe code is required to achieve a const equivalent.

@rustbot
Copy link
Collaborator

rustbot commented Aug 2, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 2, 2022
@rust-highfive
Copy link
Collaborator

r? @thomcc

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 2, 2022
@tspiteri
Copy link
Contributor Author

tspiteri commented Aug 2, 2022

The logic in split_at_unchecked was copied from split_at_mut_unchecked, replacing from_raw_parts_mut with from_raw_parts. So it should be sound.

@tspiteri
Copy link
Contributor Author

tspiteri commented Aug 2, 2022

Makes public stable method slice::split_at unstably const, so

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 2, 2022
@thomcc
Copy link
Member

thomcc commented Aug 22, 2022

Sorry for the delay. It took some discussion as to the process here for making these unstably const. It seems like the process for unstably constifying something is to get some signoff from @rust-lang/wg-const-eval that this is reasonable to have as an (unstable) const fn, and then I can review it.

Hopefully the @ above works to ping someone.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 22, 2022

r? @oli-obk yea, wg-const-eval can do unstable constifications

@rust-highfive rust-highfive assigned oli-obk and unassigned thomcc Aug 22, 2022
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with reviews by oli addressed.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 25, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 25, 2022

📌 Commit bc3d719 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 25, 2022
@tspiteri
Copy link
Contributor Author

Should I create a tracking issue for const_slice_split_at_not_mut once this is merged?

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 25, 2022
…li-obk

make slice::{split_at,split_at_unchecked} const functions

Now that `slice::from_raw_parts` is const in stable 1.64, it makes sense to have `split_at` const as well, otherwise unsafe code is required to achieve a const equivalent.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 26, 2022
Rollup of 8 pull requests

Successful merges:

 - rust-lang#99064 (distinguish the method and associated function diagnostic information)
 - rust-lang#99920 (Custom allocator support in `rustc_serialize`)
 - rust-lang#100034 ( Elaborate all box dereferences in `ElaborateBoxDerefs`)
 - rust-lang#100076 (make slice::{split_at,split_at_unchecked} const functions)
 - rust-lang#100604 (Remove unstable Result::into_ok_or_err)
 - rust-lang#100933 (Reduce code size of `assert_matches_failed`)
 - rust-lang#100978 (Handle `Err` in `ast::LitKind::to_token_lit`.)
 - rust-lang#101010 (rustdoc: remove unused CSS for `.multi-column`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e193f46 into rust-lang:master Aug 26, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 26, 2022
@tspiteri tspiteri deleted the const_slice_split_at branch August 26, 2022 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants