rust/library/core
bors 56d540e057 Auto merge of #97053 - CAD97:realloc-clarification, r=dtolnay
Remove potentially misleading realloc parenthetical

This parenthetical is problematic, because it suggests that the following is sound:

```rust
let layout = Layout:🆕:<[u8; 32]>();
let p1 = alloc(layout);
let p2 = realloc(p1, layout, 32);
if p1 == p2 {
    p1.write([0; 32]);
    dealloc(p1, layout);
} else {
    dealloc(p2, layout);
}
```

At the very least, this isn't the case for [ANSI `realloc`](https://en.cppreference.com/w/c/memory/realloc)

> The original pointer `ptr` is invalidated and any access to it is undefined behavior (even if reallocation was in-place).

and [Windows `HeapReAlloc`](https://docs.microsoft.com/en-us/windows/win32/api/heapapi/nf-heapapi-heaprealloc) is unclear at best (`HEAP_REALLOC_IN_PLACE_ONLY`'s description may imply that the old pointer may be used if `HEAP_REALLOC_IN_PLACE_ONLY` is provided).

The conservative position is to just remove the parenthetical.

cc `@rust-lang/wg-unsafe-code-guidelines` `@rust-lang/wg-allocators`
2022-05-16 02:33:34 +00:00
..
benches Auto merge of #96626 - thomcc:rand-bump, r=m-ou-se 2022-05-05 05:08:44 +00:00
primitive_docs
src Auto merge of #97053 - CAD97:realloc-clarification, r=dtolnay 2022-05-16 02:33:34 +00:00
tests Auto merge of #95602 - scottmcm:faster-array-intoiter-fold, r=the8472 2022-05-14 03:12:53 +00:00
Cargo.toml Avoid use of rand::thread_rng in stdlib benchmarks 2022-05-02 00:08:21 -07:00