mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-16 10:35:22 +00:00
79 lines
2.6 KiB
Plaintext
79 lines
2.6 KiB
Plaintext
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
|
|
--> $DIR/uninit_vec.rs:12:5
|
|
|
|
|
LL | let mut vec: Vec<u8> = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
LL | unsafe {
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::uninit-vec` implied by `-D warnings`
|
|
= 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:18:5
|
|
|
|
|
LL | vec.reserve(1000);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
LL | unsafe {
|
|
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:32: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:41:5
|
|
|
|
|
LL | my_vec.vec.reserve(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
LL | unsafe {
|
|
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:46:5
|
|
|
|
|
LL | my_vec.vec = Vec::with_capacity(1000);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
LL | unsafe {
|
|
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:25:9
|
|
|
|
|
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:28:9
|
|
|
|
|
LL | vec.reserve(1000);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
LL | vec.set_len(200);
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
|
|
|
|
error: aborting due to 7 previous errors
|
|
|