mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
119 lines
3.8 KiB
Text
119 lines
3.8 KiB
Text
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> $DIR/uninit_vec.rs:17: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`
|
|
= 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
|
|
--> $DIR/uninit_vec.rs:24: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
|
|
--> $DIR/uninit_vec.rs:31: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
|
|
--> $DIR/uninit_vec.rs:38: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
|
|
--> $DIR/uninit_vec.rs:44: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
|
|
--> $DIR/uninit_vec.rs:61: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
|
|
--> $DIR/uninit_vec.rs:71: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
|
|
--> $DIR/uninit_vec.rs:77: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
|
|
--> $DIR/uninit_vec.rs:52: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
|
|
--> $DIR/uninit_vec.rs:56: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
|
|
--> $DIR/uninit_vec.rs:132: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 11 previous errors
|
|
|