Additional *mut [T] methods by the8472 · Pull Request #95594 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation14 Commits3 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

the8472

Split out from #94247

This adds the following methods to raw slices that already exist on regular slices

These methods reduce the amount of unsafe code needed to migrate ChunksMut and related iterators
to raw slices (#94247)

r? @m-ou-se

This was referenced

Apr 2, 2022

@saethlin @the8472

Split out from rust-lang#94247

This adds the following methods to raw slices that already exist on regular slices

These methods reduce the amount of unsafe code needed to migrate ChunksMut and related iterators to raw slices (rust-lang#94247)

Co-authored-by:: The 8472 git@infinite-source.de

@the8472

@saethlin

The implementations of ChunksMut::last and RChunksMut::last currently use checked indexing, but in the PR this is supporting I used get_unchecked_mut, only because it's already there. Should we also add some kind of checked indexing for raw slices?

@the8472

Indexing raw slices could be useful, but I think that should go into a separate PR if we want to mirror SliceIndex. Plus we'd still need unsafe to deref or read the pointer.

@dtolnay dtolnay added the T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

label

Apr 2, 2022

BoxyUwU

@the8472

&mut [T] implies validity which automatically makes ptr::add ok within its bounds. But *mut [T] does not. Since we still want the benefits of in-bounds pointer arithmetic split_at_must must require the caller to pass valid pointers and therefore it is unsafe.

@saethlin

Hi, this PR has been open for a while with no activity and I think it's blocking me from fixing what I think is a soundness issue in the standard library: #94231

This is just a PR to add new methods behind features so I don't think it should be a lot of work to move this forward, but please let me know if there's something I can do to help.

yaahc

@yaahc

@bors

📌 Commit b0ca46e has been approved by yaahc

@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

May 31, 2022

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jun 1, 2022

@bors

Rollup of 6 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

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.