Skip to content

Commit

Permalink
Auto merge of #114795 - RalfJung:cell-swap, r=dtolnay
Browse files Browse the repository at this point in the history
make Cell::swap panic if the Cells partially overlap

The following function ought to be sound:
```rust
fn as_cell_of_array<T, const N: usize>(c: &[Cell<T>; N]) -> &Cell<[T; N]> {
    unsafe { transmute(c) }
}
```
However, due to `Cell::swap`, it currently is not -- safe code can [cause a use-after-free](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=c9415799722d985ff7d2c2c997b724ca). This PR fixes that.

Fixes rust-lang/rust#80778
  • Loading branch information
bors committed Aug 29, 2023
2 parents dcb9e2d + e184aa5 commit 4931165
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 4931165

Please sign in to comment.