encoding_rs
encoding_rs copied to clipboard
Fix clippy lints 2025
This PR cleans up the clippy lints, allowing some and addressing others.
I am developing on x86_64 Windows, so there's a chance I've overlooked lints in platform-specific places such as the ARM NEON code.
I have intentionally left the following 6 clippy lints unsolved, as they are addressed in sibling PR #121. (click to expand)
(warning and error are repeated 3 times each)
warning: this expression borrows a value the compiler would automatically borrow
--> src\mem.rs:2055:5
|
2055 | (&mut vec[..up_to]).copy_from_slice(head);
| ^^^^^^^^^^^^^^^^^^^ help: change this to: `vec[..up_to]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
error: calling `set_len()` immediately after reserving a buffer creates uninitialized values
--> src\lib.rs:3319:9
|
3319 | / let mut vec: Vec<u8> = Vec::with_capacity(
3320 | | (checked_add(
3321 | | valid_up_to,
3322 | | encoder.max_buffer_length_from_utf8_if_no_unmappables(string.len() - valid_up_to),
... |
3325 | | .next_power_of_two(),
3326 | | );
| |__________^
3327 | unsafe {
3328 | vec.set_len(valid_up_to);
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: initialize the buffer or wrap the content in `MaybeUninit`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninit_vec
warning: `encoding_rs` (lib) generated 6 warnings
error: could not compile `encoding_rs` (lib) due to 3 previous errors; 6 warnings emitted
Obsoletes open PR #78 ("Fix clippy lints") from 3 years ago.