about summary refs log tree commit diff
path: root/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-23 15:37:13 +0000
committerbors <bors@rust-lang.org>2022-09-23 15:37:13 +0000
commitdc14531fe9fca306fa56ab38191e3aadfa4e85c6 (patch)
tree12e29e6af047c72eccace0230ecac2f0e27cfecf /tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff
parent61fd2a8c6f8336ea12fe5b6fd1051fcf5a7b915e (diff)
parent49319b4206cbde83e0113c024b09275677ab8d74 (diff)
downloadrust-dc14531fe9fca306fa56ab38191e3aadfa4e85c6.tar.gz
rust-dc14531fe9fca306fa56ab38191e3aadfa4e85c6.zip
Auto merge of #9519 - alessandrod:uninit-set-len-0, r=llogiq
uninit_vec: fix false positive with set_len(0)

`set_len(0)` does not create uninitialized elements. Fixes a false positive with the following pattern:

```rust
fn copy_slice_into_vec(dst: &mut Vec<u8>, src: &[u8]) {
    dst.reserve(src.len().saturating_sub(dst.len()));
    unsafe {
        dst.set_len(0);
        std::ptr::copy_nonoverlapping(src.as_ptr(), dst.as_mut_ptr(), src.len());
        dst.set_len(src.len());
    }
}
```

zulip thread: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/uninit_vec.20and.20set_len.280.29

changelog: FP: [`uninit_vec`]: No longer lints `Vec::set_len(0)`
Diffstat (limited to 'tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff')
0 files changed, 0 insertions, 0 deletions