diff --git a/.travis.yml b/.travis.yml index 05943014..6d272d12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_script: - rustup target add thumbv7em-none-eabihf # Any target that does not have a standard library will do script: - cargo fmt --all -- --check + - (rustup component add clippy && cargo clippy --all --all-features -- -D clippy::all) || true - cargo build - cargo test - cargo build --no-default-features --target thumbv7em-none-eabihf # Test we can build a platform that does not have std. diff --git a/src/de.rs b/src/de.rs index 56420f2f..e5ef4dff 100644 --- a/src/de.rs +++ b/src/de.rs @@ -226,6 +226,7 @@ where } /// Turn a CBOR deserializer into an iterator over values of type T. + #[allow(clippy::should_implement_trait)] // Trait doesn't allow unconstrained T. pub fn into_iter(self) -> StreamDeserializer<'de, R, T> where T: de::Deserialize<'de>, @@ -599,7 +600,7 @@ where 0x3b => { let value = self.parse_u64()?; if value > i64::max_value() as u64 { - return visitor.visit_i128(-1 - value as i128); + return visitor.visit_i128(-1 - i128::from(value)); } visitor.visit_i64(-1 - value as i64) } diff --git a/src/error.rs b/src/error.rs index e462061c..b1a6a459 100644 --- a/src/error.rs +++ b/src/error.rs @@ -60,7 +60,7 @@ impl Error { pub fn scratch_too_small(offset: u64) -> Error { Error(ErrorImpl { code: ErrorCode::ScratchTooSmall, - offset: offset, + offset, }) } diff --git a/src/ser.rs b/src/ser.rs index 5d13f96b..d827728c 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -61,7 +61,7 @@ where #[inline] pub fn new(writer: W) -> Self { Serializer { - writer: writer, + writer, packed: false, enum_as_map: true, } @@ -263,12 +263,12 @@ where #[inline] fn serialize_i128(self, value: i128) -> Result<()> { if value < 0 { - if -(value + 1) > u64::max_value() as i128 { + if -(value + 1) > i128::from(u64::max_value()) { return Err(Error::message("The number can't be stored in CBOR")); } self.write_u64(1, -(value + 1) as u64) } else { - if value > u64::max_value() as i128 { + if value > i128::from(u64::max_value()) { return Err(Error::message("The number can't be stored in CBOR")); } self.write_u64(0, value as u64) @@ -297,7 +297,7 @@ where #[inline] fn serialize_u128(self, value: u128) -> Result<()> { - if value > u64::max_value() as u128 { + if value > u128::from(u64::max_value()) { return Err(Error::message("The number can't be stored in CBOR")); } self.write_u64(0, value as u64) diff --git a/src/value/ser.rs b/src/value/ser.rs index e931abbc..e51dea89 100644 --- a/src/value/ser.rs +++ b/src/value/ser.rs @@ -344,7 +344,7 @@ impl serde::ser::SerializeMap for SerializeMap { where T: Serialize, { - self.next_key = Some(Value::from(to_value(&key)?)); + self.next_key = Some(to_value(&key)?); Ok(()) } diff --git a/tests/de.rs b/tests/de.rs index 8eed7cd1..7e3fd9cf 100644 --- a/tests/de.rs +++ b/tests/de.rs @@ -725,5 +725,4 @@ mod std_tests { let deserialized_ip = from_slice::(&buf).unwrap(); assert_eq!(ip, deserialized_ip); } - }