diff --git a/.evergreen/check-clippy.sh b/.evergreen/check-clippy.sh index fac04d3e..99b02c10 100755 --- a/.evergreen/check-clippy.sh +++ b/.evergreen/check-clippy.sh @@ -5,7 +5,7 @@ set -o errexit . ~/.cargo/env # Pin clippy to the latest version. This should be updated when new versions of Rust are released. -CLIPPY_VERSION=1.65.0 +CLIPPY_VERSION=1.71.0 rustup install $CLIPPY_VERSION diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000..59d02545 --- /dev/null +++ b/clippy.toml @@ -0,0 +1 @@ +msrv = "1.60.0" \ No newline at end of file diff --git a/src/de/raw.rs b/src/de/raw.rs index f8798745..874d025e 100644 --- a/src/de/raw.rs +++ b/src/de/raw.rs @@ -995,7 +995,7 @@ impl TimestampDeserializer { impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut TimestampDeserializer { type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: serde::de::Visitor<'de>, { @@ -1095,7 +1095,7 @@ impl DateTimeDeserializer { impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut DateTimeDeserializer { type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: serde::de::Visitor<'de>, { @@ -1196,7 +1196,7 @@ impl<'a> BinaryDeserializer<'a> { impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut BinaryDeserializer<'de> { type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: serde::de::Visitor<'de>, { @@ -1330,7 +1330,7 @@ impl<'de, 'a> CodeWithScopeDeserializer<'de, 'a> { impl<'de, 'a, 'b> serde::de::Deserializer<'de> for &'b mut CodeWithScopeDeserializer<'de, 'a> { type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: serde::de::Visitor<'de>, { @@ -1447,7 +1447,7 @@ impl<'de, 'a> DbPointerDeserializer<'de, 'a> { impl<'de, 'a, 'b> serde::de::Deserializer<'de> for &'b mut DbPointerDeserializer<'de, 'a> { type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: serde::de::Visitor<'de>, { diff --git a/src/document.rs b/src/document.rs index f27e923d..9b0e982b 100644 --- a/src/document.rs +++ b/src/document.rs @@ -253,7 +253,7 @@ impl Document { /// Get a reference to a Decimal128 value for key, if it exists. pub fn get_decimal128(&self, key: impl AsRef) -> ValueAccessResult<&Decimal128> { match self.get(key) { - Some(&Bson::Decimal128(ref v)) => Ok(v), + Some(Bson::Decimal128(v)) => Ok(v), Some(_) => Err(ValueAccessError::UnexpectedType), None => Err(ValueAccessError::NotPresent), } @@ -274,7 +274,7 @@ impl Document { /// Get a string slice this key if it exists and has the correct type. pub fn get_str(&self, key: impl AsRef) -> ValueAccessResult<&str> { match self.get(key) { - Some(&Bson::String(ref v)) => Ok(v), + Some(Bson::String(v)) => Ok(v), Some(_) => Err(ValueAccessError::UnexpectedType), None => Err(ValueAccessError::NotPresent), } @@ -293,7 +293,7 @@ impl Document { /// the correct type. pub fn get_array(&self, key: impl AsRef) -> ValueAccessResult<&Array> { match self.get(key) { - Some(&Bson::Array(ref v)) => Ok(v), + Some(Bson::Array(v)) => Ok(v), Some(_) => Err(ValueAccessError::UnexpectedType), None => Err(ValueAccessError::NotPresent), } @@ -313,7 +313,7 @@ impl Document { /// the correct type. pub fn get_document(&self, key: impl AsRef) -> ValueAccessResult<&Document> { match self.get(key) { - Some(&Bson::Document(ref v)) => Ok(v), + Some(Bson::Document(v)) => Ok(v), Some(_) => Err(ValueAccessError::UnexpectedType), None => Err(ValueAccessError::NotPresent), } @@ -458,7 +458,7 @@ impl Document { /// Get a reference to a UTC datetime value for this key if it exists and has the correct type. pub fn get_datetime(&self, key: impl AsRef) -> ValueAccessResult<&crate::DateTime> { match self.get(key) { - Some(&Bson::DateTime(ref v)) => Ok(v), + Some(Bson::DateTime(v)) => Ok(v), Some(_) => Err(ValueAccessError::UnexpectedType), None => Err(ValueAccessError::NotPresent), } diff --git a/src/ser/raw/mod.rs b/src/ser/raw/mod.rs index af82c06a..960c5a46 100644 --- a/src/ser/raw/mod.rs +++ b/src/ser/raw/mod.rs @@ -259,11 +259,7 @@ impl<'a> serde::Serializer for &'a mut Serializer { } #[inline] - fn serialize_newtype_struct( - mut self, - name: &'static str, - value: &T, - ) -> Result + fn serialize_newtype_struct(self, name: &'static str, value: &T) -> Result where T: serde::Serialize, { diff --git a/src/tests/modules/macros.rs b/src/tests/modules/macros.rs index ada1ccc5..689c8a1a 100644 --- a/src/tests/modules/macros.rs +++ b/src/tests/modules/macros.rs @@ -143,19 +143,19 @@ fn recursive_macro() { }; match doc.get("a") { - Some(&Bson::String(ref s)) => assert_eq!("foo", s), + Some(Bson::String(s)) => assert_eq!("foo", s), _ => panic!("String 'foo' was not inserted correctly."), } // Inner Doc 1 match doc.get("b") { - Some(&Bson::Document(ref doc)) => { + Some(Bson::Document(doc)) => { // Inner doc 2 match doc.get("bar") { - Some(&Bson::Document(ref inner_doc)) => { + Some(Bson::Document(inner_doc)) => { // Inner array match inner_doc.get("harbor") { - Some(&Bson::Array(ref arr)) => { + Some(Bson::Array(arr)) => { assert_eq!(2, arr.len()); // Match array items @@ -177,7 +177,7 @@ fn recursive_macro() { // Inner floating point match inner_doc.get("jelly") { - Some(&Bson::Double(ref fp)) => assert_eq!(42.0, *fp), + Some(Bson::Double(fp)) => assert_eq!(42.0, *fp), _ => panic!("Floating point 42.0 was not inserted correctly."), } } @@ -189,7 +189,7 @@ fn recursive_macro() { // Single-item array match doc.get("c") { - Some(&Bson::Array(ref arr)) => { + Some(Bson::Array(arr)) => { assert_eq!(1, arr.len()); // Integer type @@ -203,7 +203,7 @@ fn recursive_macro() { // Document nested in array match doc.get("d") { - Some(&Bson::Array(ref arr)) => { + Some(Bson::Array(arr)) => { assert_eq!(1, arr.len()); // Nested document @@ -211,7 +211,7 @@ fn recursive_macro() { Some(Bson::Document(ref doc)) => { // String match doc.get("apple") { - Some(&Bson::String(ref s)) => assert_eq!("ripe", s), + Some(Bson::String(s)) => assert_eq!("ripe", s), _ => panic!("String 'ripe' was not inserted correctly."), } } @@ -223,10 +223,10 @@ fn recursive_macro() { // Single-item document match doc.get("e") { - Some(&Bson::Document(ref bdoc)) => { + Some(Bson::Document(bdoc)) => { // String match bdoc.get("single") { - Some(&Bson::String(ref s)) => assert_eq!("test", s), + Some(Bson::String(s)) => assert_eq!("test", s), _ => panic!("String 'test' was not inserted correctly."), } }