Uh oh!
There was an error while loading. Please reload this page.
Replace more casts with safer conversions & enable cast-related lints. - #445
Replace more casts with safer conversions & enable cast-related lints.#445briansmith wants to merge 7 commits into
Conversation
d29aa27 to
125a3e6CompareUh oh!
There was an error while loading. Please reload this page.
d9b4a3a to
90b24d4Comparebriansmith
commented
Jun 1, 2024
I have rebased this on top of #447 and extended it to address additional Clippy feedback from that change. |
f331ab0 to
67f3bd5Comparebriansmith
commented
Jun 2, 2024
4008b07 to
7a89e48Comparebriansmith
commented
Jun 6, 2024
usize and u32 both implement `From<u16>` so use u16 for the length.
| #![deny( | ||
| clippy::cast_lossless, | ||
| clippy::cast_possible_truncation, | ||
| clippy::cast_possible_wrap, | ||
| clippy::cast_precision_loss, | ||
| clippy::cast_ptr_alignment, | ||
| clippy::cast_sign_loss, | ||
| clippy::char_lit_as_u8, | ||
| clippy::checked_conversions, | ||
| clippy::fn_to_numeric_cast, | ||
| clippy::fn_to_numeric_cast_with_truncation, | ||
| clippy::ptr_as_ptr, | ||
| clippy::unnecessary_cast, | ||
| clippy::useless_conversion | ||
| )] |
There was a problem hiding this comment.
Would it be possible to deny entire categories of lints (pedantic, correctness, complexity, etc...) rather than specific ones?
There was a problem hiding this comment.
Also, with the number of additional lints it may be better to enable them in clippy.toml.
d06067f to
4f8d78dCompare| for chunk in dest.chunks_mut(chunk_size) { | ||
| let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr().cast::<c_void>(), chunk.len() as u32) }; | ||
| #[allow(clippy::cast_possible_truncation)] | ||
| let chunk_len = chunk.len() as u32; |
There was a problem hiding this comment.
You can write it as chunk.len().try_into().expect("chunk size is bounded by i32::MAX"). Compiler is able to properly remove such panic.
| for chunk in dest.chunks_mut(WEB_CRYPTO_BUFFER_SIZE.into()) { | ||
| // The chunk can be smaller than buf's length, so we call to | ||
| // JS to create a smaller view of buf without allocation. | ||
| #[allow(clippy::cast_possible_truncation)] |
There was a problem hiding this comment.
You can use .try_into().expect("..") here same as in windows7.
newpavlov
commented
Oct 9, 2024
Closing in favor of #510. |
No description provided.