diff --git a/benches/varint.rs b/benches/varint.rs index 33a7da18..248ab0a9 100644 --- a/benches/varint.rs +++ b/benches/varint.rs @@ -9,7 +9,7 @@ fn slice_varint_u8(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("slice_varint_u8", |b| { b.iter(|| { @@ -25,7 +25,7 @@ fn slice_varint_u16(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("slice_varint_u16", |b| { b.iter(|| { @@ -41,7 +41,7 @@ fn slice_varint_u32(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("slice_varint_u32", |b| { b.iter(|| { @@ -57,7 +57,7 @@ fn slice_varint_u64(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("slice_varint_u64", |b| { b.iter(|| { @@ -73,7 +73,7 @@ fn bufreader_varint_u8(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("bufreader_varint_u8", |b| { b.iter(|| { @@ -91,7 +91,7 @@ fn bufreader_varint_u16(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("bufreader_varint_u16", |b| { b.iter(|| { @@ -109,7 +109,7 @@ fn bufreader_varint_u32(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("bufreader_varint_u32", |b| { b.iter(|| { @@ -127,7 +127,7 @@ fn bufreader_varint_u64(c: &mut Criterion) { .take(10_000) .collect(); let config = config::standard(); - let bytes = bincode::encode_to_vec(&input, config).unwrap(); + let bytes = bincode::encode_to_vec(input, config).unwrap(); c.bench_function("bufreader_varint_u64", |b| { b.iter(|| { diff --git a/src/de/impls.rs b/src/de/impls.rs index 7228d423..8b592f57 100644 --- a/src/de/impls.rs +++ b/src/de/impls.rs @@ -606,7 +606,7 @@ where Ok(Err(u)) } x => Err(DecodeError::UnexpectedVariant { - found: x as u32, + found: x, allowed: &crate::error::AllowedEnumVariants::Range { max: 1, min: 0 }, type_name: core::any::type_name::>(), }), @@ -631,7 +631,7 @@ where Ok(Err(u)) } x => Err(DecodeError::UnexpectedVariant { - found: x as u32, + found: x, allowed: &crate::error::AllowedEnumVariants::Range { max: 1, min: 0 }, type_name: core::any::type_name::>(), }), diff --git a/src/varint/decode_unsigned.rs b/src/varint/decode_unsigned.rs index 7b0fc278..1aa57a85 100644 --- a/src/varint/decode_unsigned.rs +++ b/src/varint/decode_unsigned.rs @@ -54,8 +54,8 @@ where let mut bytes = [0u8; 4]; read.read(&mut bytes)?; Ok(match endian { - Endian::Big => u32::from_be_bytes(bytes) as u32, - Endian::Little => u32::from_le_bytes(bytes) as u32, + Endian::Big => u32::from_be_bytes(bytes), + Endian::Little => u32::from_le_bytes(bytes), }) } U64_BYTE => invalid_varint_discriminant(IntegerType::U32, IntegerType::U64), @@ -94,8 +94,8 @@ where let mut bytes = [0u8; 8]; read.read(&mut bytes)?; Ok(match endian { - Endian::Big => u64::from_be_bytes(bytes) as u64, - Endian::Little => u64::from_le_bytes(bytes) as u64, + Endian::Big => u64::from_be_bytes(bytes), + Endian::Little => u64::from_le_bytes(bytes), }) } U128_BYTE => invalid_varint_discriminant(IntegerType::U64, IntegerType::U128), @@ -242,7 +242,7 @@ pub fn varint_decode_u32(read: &mut R, endian: Endian) -> Result u32::from_le_bytes(bytes[..4].try_into().unwrap()), }; - (val as u32, 5) + (val, 5) } U64_BYTE => return invalid_varint_discriminant(IntegerType::U32, IntegerType::U64), U128_BYTE => return invalid_varint_discriminant(IntegerType::U32, IntegerType::U128), @@ -283,7 +283,7 @@ pub fn varint_decode_u64(read: &mut R, endian: Endian) -> Result u64::from_le_bytes(bytes[..8].try_into().unwrap()), }; - (val as u64, 9) + (val, 9) } U128_BYTE => return invalid_varint_discriminant(IntegerType::U32, IntegerType::U128), _ => return invalid_varint_discriminant(IntegerType::U32, IntegerType::Reserved), @@ -371,7 +371,7 @@ pub fn varint_decode_u128(read: &mut R, endian: Endian) -> Result u128::from_le_bytes(bytes[..16].try_into().unwrap()), }; - (val as u128, 17) + (val, 17) } _ => return invalid_varint_discriminant(IntegerType::Usize, IntegerType::Reserved), }; diff --git a/tests/alloc.rs b/tests/alloc.rs index 0a69c079..08c07bb0 100644 --- a/tests/alloc.rs +++ b/tests/alloc.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] #![cfg(feature = "alloc")] extern crate alloc; diff --git a/tests/basic_types.rs b/tests/basic_types.rs index f58d6da1..b269f8e8 100644 --- a/tests/basic_types.rs +++ b/tests/basic_types.rs @@ -245,7 +245,7 @@ fn test_duration_out_of_range() { let mut input = [0u8; 14]; bincode::encode_into_slice( - &(u64::MAX, u32::MAX), + (u64::MAX, u32::MAX), &mut input, bincode::config::standard(), ) @@ -269,7 +269,7 @@ fn test_duration_wrapping() { let mut input = [0u8; 14]; bincode::encode_into_slice( - &(u64::MAX - 4, u32::MAX), + (u64::MAX - 4, u32::MAX), &mut input, bincode::config::standard(), ) diff --git a/tests/issues/issue_474.rs b/tests/issues/issue_474.rs index 8a80973c..0526ebb9 100644 --- a/tests/issues/issue_474.rs +++ b/tests/issues/issue_474.rs @@ -63,7 +63,7 @@ impl MemCache { let config = bincode::config::standard(); let mut guard = self.cache.write().unwrap(); - let encoded = bincode::serde::encode_to_vec(&cache_data, config)?; + let encoded = bincode::serde::encode_to_vec(cache_data, config)?; let cache_item = CacheItem::new(encoded, expire_seconds); guard.insert(*key, cache_item); diff --git a/tests/std.rs b/tests/std.rs index 34d01623..f32461f5 100644 --- a/tests/std.rs +++ b/tests/std.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] #![cfg(feature = "std")] mod utils; diff --git a/tests/utils.rs b/tests/utils.rs index 3672ebc0..c336bd5f 100644 --- a/tests/utils.rs +++ b/tests/utils.rs @@ -7,7 +7,7 @@ where CMP: Fn(&V, &V) -> bool, { let mut buffer = [0u8; 2048]; - let len = bincode::encode_into_slice(&element, &mut buffer, config).unwrap(); + let len = bincode::encode_into_slice(element, &mut buffer, config).unwrap(); println!( "{:?} ({}): {:?} ({:?})", element, @@ -40,7 +40,7 @@ where use bincode::error::EncodeError; let mut buffer = [0u8; 2048]; - let len = bincode::serde::encode_into_slice(&element, &mut buffer, config); + let len = bincode::serde::encode_into_slice(element, &mut buffer, config); let decoded = bincode::serde::decode_from_slice(&buffer, config);