-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix slice::ChunksMut aliasing #94247
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
But that could be improved by implementing slicing and |
9643dd8
to
be3f695
Compare
We discussed this in the libs team meeting. The general approach looks acceptable, but we'd like the new slice pointer APIs to be split out into a separate PR so they could be reviewed on their own. This PR can then be rebased once that's accepted. |
I think that sounds awesome. If there is someone else willing to do the new slice pointer APIs that would be ideal, my plate is pretty full already so it might take me some time to get through that whole process. |
|
Split out from rust-lang#94247 This adds the following methods to raw slices that already exist on regular slices * `*mut [T]::is_empty` * `*mut [T]::split_at_mut` * `*mut [T]::split_at_unchecked` 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 <[email protected]>
61d9d94
to
ecb728f
Compare
This comment has been minimized.
This comment has been minimized.
Additional `*mut [T]` methods Split out from rust-lang#94247 This adds the following methods to raw slices that already exist on regular slices * `*mut [T]::is_empty` * `*mut [T]::split_at_mut` * `*mut [T]::split_at_mut_unchecked` These methods reduce the amount of unsafe code needed to migrate `ChunksMut` and related iterators to raw slices (rust-lang#94247) r? `@m-ou-se`
☔ The latest upstream changes (presumably #97632) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot label: -S-blocked |
ecb728f
to
6627931
Compare
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
I am stuck. The code works, but I cannot figure out how to write safety comments in most of these cases, because what makes the unsafe code valid is highly nonlocal. Basically I imagine these all as "this is safe because it is an invariant of the type" but that doesn't seem remotely helpful as a safety comment. Help? Here are where I'm definitely missing safety comments (those that exist may need improving too):
|
This comment has been minimized.
This comment has been minimized.
6627931
to
7919e42
Compare
This comment has been minimized.
This comment has been minimized.
It's mostly about the new I think this can be addressed in several steps
Or perhaps even simpler: We could explain that all uses should be treated as-if it were a |
This comment has been minimized.
This comment has been minimized.
05dc00a
to
746afe8
Compare
@bors r+ |
…laumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#94247 (Fix slice::ChunksMut aliasing) - rust-lang#99358 (Allow `ValTree::try_to_raw_bytes` on `u8` array) - rust-lang#99651 (Deeply deny fn and raw ptrs in const generics) - rust-lang#99710 (lint: add bad opt access internal lint) - rust-lang#99717 (Add some comments to the docs issue template to clarify) - rust-lang#99728 (Clean up HIR-based lifetime resolution) - rust-lang#99812 (Fix headings colors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Is the PR description outdated? With that description (which will now live forever in our git history) it doesn't sound like this was ready to land... |
🤦 it's outdated |
These were accidentally removed in rust-lang#94247 because the representation was changed from &mut [T] to *mut T, which has !Send + !Sync.
Add back Send and Sync impls on ChunksMut iterators Fixes rust-lang#100014 These were accidentally removed in rust-lang#94247 because the representation was changed from `&mut [T]` to `*mut T`, which has `!Send + !Sync`.
Fixes #94231, details in that issue.
cc @RalfJung
This isn't done just yet, all the safety comments are placeholders. But otherwise, it seems to work.
I don't really like this approach though. There's a lot of unsafe code where there wasn't before, but as far as I can tell the only other way to uphold the aliasing requirement imposed by
__iterator_get_unchecked
is to use raw slices, which I think require the same amount of unsafe code. All that would do is tie thelen
andptr
fields together.Oh I just looked and I'm pretty sure that
ChunksExactMut
,RChunksMut
, andRChunksExactMut
also need to be patched. Even more reason to put up a draft.