]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #94247 - saethlin:chunksmut-aliasing, r=the8472
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Wed, 27 Jul 2022 15:55:01 +0000 (17:55 +0200)
committerGitHub <noreply@github.com>
Wed, 27 Jul 2022 15:55:01 +0000 (17:55 +0200)
commitef81fca760067e887e1dc69413f004327d23bb7e
treef422a1cde63dd156fc294db5719f34ce459c4653
parent2a220937c283803bfd5d1155e4a81e6287089504
parent746afe8952a026c24fd229474f40658cbc9e12c7
Rollup merge of #94247 - saethlin:chunksmut-aliasing, r=the8472

Fix slice::ChunksMut aliasing

Fixes https://github.com/rust-lang/rust/issues/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 the `len` and `ptr` fields together.

Oh I just looked and I'm pretty sure that `ChunksExactMut`, `RChunksMut`, and `RChunksExactMut` also need to be patched. Even more reason to put up a draft.
library/core/src/slice/iter.rs