From be9e168fcf0a161a2a7e5244b35c7b7575c72d58 Mon Sep 17 00:00:00 2001 From: Juniper Tyree <50025784+juntyr@users.noreply.github.com> Date: Sun, 5 May 2024 14:37:05 +0000 Subject: [PATCH] Fix clippy lints for 1.78 --- clippy.toml | 1 - fuzz/fuzz_targets/bench/lib.rs | 4 ++-- src/de/mod.rs | 2 ++ src/options.rs | 2 ++ src/parse.rs | 12 ++++++------ src/ser/mod.rs | 4 ++-- src/value/map.rs | 17 +++++++++++------ 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/clippy.toml b/clippy.toml index cb8cfcd1c..22fd4be73 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1 @@ msrv = "1.64.0" -blacklisted-names = [] diff --git a/fuzz/fuzz_targets/bench/lib.rs b/fuzz/fuzz_targets/bench/lib.rs index db7c568d9..01126003a 100644 --- a/fuzz/fuzz_targets/bench/lib.rs +++ b/fuzz/fuzz_targets/bench/lib.rs @@ -117,8 +117,8 @@ struct ArbitraryPrettyConfig { /// Enumerate array items in comments enumerate_arrays: bool, #[arbitrary(with = arbitrary_ron_extensions)] - /// Enable extensions. Only configures 'implicit_some', - /// 'unwrap_newtypes', and 'unwrap_variant_newtypes' for now. + /// Enable extensions. Only configures `implicit_some`, + /// `unwrap_newtypes`, and `unwrap_variant_newtypes` for now. extensions: Extensions, /// Enable compact arrays, which do not insert new lines and indentation /// between the elements of an array diff --git a/src/de/mod.rs b/src/de/mod.rs index 9707a7a1e..6028236b6 100644 --- a/src/de/mod.rs +++ b/src/de/mod.rs @@ -63,6 +63,8 @@ impl<'de> Deserializer<'de> { Ok(deserializer) } + // FIXME: panic is not actually possible, remove once utf8_chunks is stabilized + #[allow(clippy::missing_panics_doc)] pub fn from_bytes_with_options(input: &'de [u8], options: &Options) -> SpannedResult { let err = match str::from_utf8(input) { Ok(input) => return Self::from_str_with_options(input, options), diff --git a/src/options.rs b/src/options.rs index 0e5bb2a52..c7bf4429e 100644 --- a/src/options.rs +++ b/src/options.rs @@ -121,6 +121,8 @@ impl Options { /// A convenience function for building a deserializer /// and deserializing a value of type `T` from a reader /// and a seed. + // FIXME: panic is not actually possible, remove once utf8_chunks is stabilized + #[allow(clippy::missing_panics_doc)] pub fn from_reader_seed(&self, mut rdr: R, seed: S) -> SpannedResult where R: io::Read, diff --git a/src/parse.rs b/src/parse.rs index b944e66a3..b1d4f8831 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -192,7 +192,7 @@ impl<'a> Parser<'a> { Ok(false) } }) - .fold(Ok(true), |acc, x| acc.and_then(|val| x.map(|x| x && val))) + .try_fold(true, |acc, x| x.map(|x| x && acc)) } pub fn expect_char(&mut self, expected: char, error: Error) -> Result<()> { @@ -256,10 +256,10 @@ impl<'a> Parser<'a> { fn parse_integer(&mut self, sign: i8) -> Result { let base = match () { - _ if self.consume_str("0b") => 2, - _ if self.consume_str("0o") => 8, - _ if self.consume_str("0x") => 16, - _ => 10, + () if self.consume_str("0b") => 2, + () if self.consume_str("0o") => 8, + () if self.consume_str("0x") => 16, + () => 10, }; let num_bytes = self.next_chars_while_len(is_int_char); @@ -324,7 +324,7 @@ impl<'a> Parser<'a> { let num_bytes = self.next_chars_while_len(is_int_char); - if self.src()[num_bytes..].starts_with(&['i', 'u']) { + if self.src()[num_bytes..].starts_with(['i', 'u']) { let int_cursor = self.cursor; self.advance_bytes(num_bytes); diff --git a/src/ser/mod.rs b/src/ser/mod.rs index fc040937f..6157f05f1 100644 --- a/src/ser/mod.rs +++ b/src/ser/mod.rs @@ -92,8 +92,8 @@ pub struct PrettyConfig { pub separate_tuple_members: bool, /// Enumerate array items in comments pub enumerate_arrays: bool, - /// Enable extensions. Only configures 'implicit_some', - /// 'unwrap_newtypes', and 'unwrap_variant_newtypes' for now. + /// Enable extensions. Only configures `implicit_some`, + /// `unwrap_newtypes`, and `unwrap_variant_newtypes` for now. pub extensions: Extensions, /// Enable compact arrays, which do not insert new lines and indentation /// between the elements of an array diff --git a/src/value/map.rs b/src/value/map.rs index fd840caa4..8375184fa 100644 --- a/src/value/map.rs +++ b/src/value/map.rs @@ -73,27 +73,32 @@ impl Map { } /// Iterate all key-value pairs. - pub fn iter(&self) -> impl Iterator + DoubleEndedIterator { + #[must_use] + pub fn iter(&self) -> impl DoubleEndedIterator { self.0.iter() } /// Iterate all key-value pairs mutably. - pub fn iter_mut(&mut self) -> impl Iterator + DoubleEndedIterator { + #[must_use] + pub fn iter_mut(&mut self) -> impl DoubleEndedIterator { self.0.iter_mut() } /// Iterate all keys. - pub fn keys(&self) -> impl Iterator + DoubleEndedIterator { + #[must_use] + pub fn keys(&self) -> impl DoubleEndedIterator { self.0.keys() } /// Iterate all values. - pub fn values(&self) -> impl Iterator + DoubleEndedIterator { + #[must_use] + pub fn values(&self) -> impl DoubleEndedIterator { self.0.values() } /// Iterate all values mutably. - pub fn values_mut(&mut self) -> impl Iterator + DoubleEndedIterator { + #[must_use] + pub fn values_mut(&mut self) -> impl DoubleEndedIterator { self.0.values_mut() } @@ -158,7 +163,7 @@ impl Eq for Map {} impl PartialOrd for Map { fn partial_cmp(&self, other: &Map) -> Option { - self.iter().partial_cmp(other.iter()) + Some(self.cmp(other)) } }