mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
129 lines
4.3 KiB
Text
129 lines
4.3 KiB
Text
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:18:5
|
|
|
|
|
LL | let mut vec = Vec::<UnsafeCell<*mut S>>::with_capacity(1);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
LL | vec.set_len(1);
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
= note: `-D clippy::uninit-vec` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::uninit_vec)]`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:24:5
|
|
|
|
|
LL | let mut vec: Vec<u8> = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:31:5
|
|
|
|
|
LL | vec.reserve(1000);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` on empty `Vec` creates out-of-bound values
|
|
--> tests/ui/uninit_vec.rs:38:5
|
|
|
|
|
LL | let mut vec: Vec<u8> = Vec::new();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: calling `set_len()` on empty `Vec` creates out-of-bound values
|
|
--> tests/ui/uninit_vec.rs:45:5
|
|
|
|
|
LL | let mut vec: Vec<u8> = Default::default();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: calling `set_len()` on empty `Vec` creates out-of-bound values
|
|
--> tests/ui/uninit_vec.rs:51:5
|
|
|
|
|
LL | let mut vec: Vec<u8> = Vec::default();
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:68:5
|
|
|
|
|
LL | let mut vec: Vec<u8> = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:78:5
|
|
|
|
|
LL | my_vec.vec.reserve(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | my_vec.vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:84:5
|
|
|
|
|
LL | my_vec.vec = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | my_vec.vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:59:9
|
|
|
|
|
LL | let mut vec: Vec<u8> = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
LL |
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:63:9
|
|
|
|
|
LL | vec.reserve(1000);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
LL |
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> tests/ui/uninit_vec.rs:139:9
|
|
|
|
|
LL | let mut vec: Vec<T> = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | vec.set_len(10);
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: aborting due to 12 previous errors
|
|
|