Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed new clippy lints #721

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ impl<E, I, L> Configuration<E, I, L> {
/// 2. If `251 <= u < 2**16`, encode it as a literal byte 251, followed by a u16 with value `u`.
/// 3. If `2**16 <= u < 2**32`, encode it as a literal byte 252, followed by a u32 with value `u`.
/// 4. If `2**32 <= u < 2**64`, encode it as a literal byte 253, followed by a u64 with value `u`.
/// 5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a
/// u128 with value `u`.
/// 5. If `2**64 <= u < 2**128`, encode it as a literal byte 254, followed by a u128 with value `u`.
///
/// Then, for signed integers, we first convert to unsigned using the zigzag algorithm,
/// and then encode them as we do for unsigned integers generally. The reason we use this
Expand Down
4 changes: 2 additions & 2 deletions src/features/impl_alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ where
let mut vec = alloc::vec![0u8; len];
decoder.reader().read(&mut vec)?;
// Safety: Vec<T> is Vec<u8>
Ok(unsafe { core::mem::transmute(vec) })
Ok(unsafe { core::mem::transmute::<Vec<u8>, Vec<T>>(vec) })
} else {
decoder.claim_container_read::<T>(len)?;

Expand Down Expand Up @@ -290,7 +290,7 @@ where
let mut vec = alloc::vec![0u8; len];
decoder.reader().read(&mut vec)?;
// Safety: Vec<T> is Vec<u8>
Ok(unsafe { core::mem::transmute(vec) })
Ok(unsafe { core::mem::transmute::<Vec<u8>, Vec<T>>(vec) })
} else {
decoder.claim_container_read::<T>(len)?;

Expand Down
2 changes: 1 addition & 1 deletion src/varint/decode_unsigned.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core::{convert::TryInto, u32};
use core::convert::TryInto;

use super::{SINGLE_BYTE_MAX, U128_BYTE, U16_BYTE, U32_BYTE, U64_BYTE};
use crate::{
Expand Down
4 changes: 2 additions & 2 deletions tests/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ fn test_container_limits() {
let test_cases = &[
// u64::max_value(), should overflow
#[cfg(target_pointer_width = "64")]
bincode::encode_to_vec(u64::max_value(), bincode::config::standard()).unwrap(),
bincode::encode_to_vec(u64::MAX, bincode::config::standard()).unwrap(),
#[cfg(target_pointer_width = "32")]
bincode::encode_to_vec(u32::max_value(), bincode::config::standard()).unwrap(),
bincode::encode_to_vec(u32::MAX, bincode::config::standard()).unwrap(),
// A high value which doesn't overflow, but exceeds the decode limit
bincode::encode_to_vec(DECODE_LIMIT as u64, bincode::config::standard()).unwrap(),
];
Expand Down
Loading