Commit 4adebb9
authored
Rollup merge of #71148 - bluss:vec-drop-raw-slice, r=RalfJung
Vec drop and truncate: drop using raw slice *mut [T]
By creating a *mut [T] directly (without going through &mut [T]), avoid
questions of validity of the contents of the slice.
Consider the following risky code:
```rust
unsafe {
let mut v = Vec::<bool>::with_capacity(16);
v.set_len(16);
}
```
The intention is that with this change, we avoid one of the soundness
questions about the above snippet, because Vec::drop no longer
produces a mutable slice of the vector's contents.
r? @RalfJung1 file changed
+10
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
741 | 741 | | |
742 | 742 | | |
743 | 743 | | |
744 | | - | |
| 744 | + | |
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
| |||
2379 | 2379 | | |
2380 | 2380 | | |
2381 | 2381 | | |
2382 | | - | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
2383 | 2385 | | |
2384 | 2386 | | |
2385 | 2387 | | |
| |||
2596 | 2598 | | |
2597 | 2599 | | |
2598 | 2600 | | |
2599 | | - | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
2600 | 2606 | | |
2601 | 2607 | | |
2602 | 2608 | | |
| |||
2708 | 2714 | | |
2709 | 2715 | | |
2710 | 2716 | | |
2711 | | - | |
| 2717 | + | |
2712 | 2718 | | |
2713 | 2719 | | |
2714 | 2720 | | |
| |||
0 commit comments