From 51ea34b2176578251ab739c2453accbd27cc5e53 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Tue, 22 Nov 2022 18:40:27 -0800 Subject: [PATCH] Resolve needless_borrowed_reference clippy lints error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/de.rs:1813:39 | 1813 | let map = content.iter().map(|&(ref k, ref v)| { | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference = note: `-D clippy::needless-borrowed-reference` implied by `-D clippy::all` help: try removing the `&` and `ref` parts | 1813 - let map = content.iter().map(|&(ref k, ref v)| { 1813 + let map = content.iter().map(|(k, v)| { | error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/de.rs:2110:25 | 2110 | let &(ref variant, ref value) = match iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference help: try removing the `&` and `ref` parts | 2110 - let &(ref variant, ref value) = match iter.next() { 2110 + let (variant, value) = match iter.next() { | error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/de.rs:2257:22 | 2257 | Some(&Content::Seq(ref v)) => { | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference help: try removing the `&` and `ref` parts | 2257 - Some(&Content::Seq(ref v)) => { 2257 + Some(Content::Seq(v)) => { | error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/de.rs:2280:22 | 2280 | Some(&Content::Map(ref v)) => { | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference help: try removing the `&` and `ref` parts | 2280 - Some(&Content::Map(ref v)) => { 2280 + Some(Content::Map(v)) => { | error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/de.rs:2283:22 | 2283 | Some(&Content::Seq(ref v)) => { | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference help: try removing the `&` and `ref` parts | 2283 - Some(&Content::Seq(ref v)) => { 2283 + Some(Content::Seq(v)) => { | error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/de.rs:2406:22 | 2406 | Some(&(ref key, ref value)) => { | ^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference help: try removing the `&` and `ref` parts | 2406 - Some(&(ref key, ref value)) => { 2406 + Some((key, value)) => { | error: dereferencing a tuple pattern where every element takes a reference --> serde/src/private/ser.rs:528:25 | 528 | for &(ref k, ref v) in entries { | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference help: try removing the `&` and `ref` parts | 528 - for &(ref k, ref v) in entries { 528 + for (k, v) in entries { | --- serde/src/private/de.rs | 12 ++++++------ serde/src/private/ser.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index 01e5bf78..77ed94f8 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -1810,7 +1810,7 @@ mod content { V: Visitor<'de>, E: de::Error, { - let map = content.iter().map(|&(ref k, ref v)| { + let map = content.iter().map(|(k, v)| { ( ContentRefDeserializer::new(k), ContentRefDeserializer::new(v), @@ -2107,7 +2107,7 @@ mod content { let (variant, value) = match *self.content { Content::Map(ref value) => { let mut iter = value.iter(); - let &(ref variant, ref value) = match iter.next() { + let (variant, value) = match iter.next() { Some(v) => v, None => { return Err(de::Error::invalid_value( @@ -2254,7 +2254,7 @@ mod content { V: de::Visitor<'de>, { match self.value { - Some(&Content::Seq(ref v)) => { + Some(Content::Seq(v)) => { de::Deserializer::deserialize_any(SeqRefDeserializer::new(v), visitor) } Some(other) => Err(de::Error::invalid_type( @@ -2277,10 +2277,10 @@ mod content { V: de::Visitor<'de>, { match self.value { - Some(&Content::Map(ref v)) => { + Some(Content::Map(v)) => { de::Deserializer::deserialize_any(MapRefDeserializer::new(v), visitor) } - Some(&Content::Seq(ref v)) => { + Some(Content::Seq(v)) => { de::Deserializer::deserialize_any(SeqRefDeserializer::new(v), visitor) } Some(other) => Err(de::Error::invalid_type( @@ -2403,7 +2403,7 @@ mod content { T: de::DeserializeSeed<'de>, { match self.iter.next() { - Some(&(ref key, ref value)) => { + Some((key, value)) => { self.value = Some(value); seed.deserialize(ContentRefDeserializer::new(key)).map(Some) } diff --git a/serde/src/private/ser.rs b/serde/src/private/ser.rs index 293d8a86..528e8c12 100644 --- a/serde/src/private/ser.rs +++ b/serde/src/private/ser.rs @@ -525,7 +525,7 @@ mod content { Content::Map(ref entries) => { use ser::SerializeMap; let mut map = try!(serializer.serialize_map(Some(entries.len()))); - for &(ref k, ref v) in entries { + for (k, v) in entries { try!(map.serialize_entry(k, v)); } map.end()