diff --git a/core/src/peer_id.rs b/core/src/peer_id.rs index 5f9a8f78629..c4a12f703b3 100644 --- a/core/src/peer_id.rs +++ b/core/src/peer_id.rs @@ -68,8 +68,8 @@ impl PeerId { /// Parses a `PeerId` from bytes. pub fn from_bytes(data: &[u8]) -> Result { - Ok(PeerId::from_multihash(Multihash::from_bytes(&data)?) - .map_err(|mh| Error::UnsupportedCode(mh.code()))?) + PeerId::from_multihash(Multihash::from_bytes(&data)?) + .map_err(|mh| Error::UnsupportedCode(mh.code())) } /// Tries to turn a `Multihash` into a `PeerId`. diff --git a/muxers/mplex/src/codec.rs b/muxers/mplex/src/codec.rs index 23ba1fcb632..f56bb146ad0 100644 --- a/muxers/mplex/src/codec.rs +++ b/muxers/mplex/src/codec.rs @@ -244,25 +244,25 @@ impl Encoder for Codec { fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> { let (header, data) = match item { Frame::Open { stream_id } => { - (u64::from(stream_id.num) << 3, Bytes::new()) + (stream_id.num << 3, Bytes::new()) }, Frame::Data { stream_id: LocalStreamId { num, role: Endpoint::Listener }, data } => { - (u64::from(num) << 3 | 1, data) + (num << 3 | 1, data) }, Frame::Data { stream_id: LocalStreamId { num, role: Endpoint::Dialer }, data } => { - (u64::from(num) << 3 | 2, data) + (num << 3 | 2, data) }, Frame::Close { stream_id: LocalStreamId { num, role: Endpoint::Listener } } => { - (u64::from(num) << 3 | 3, Bytes::new()) + (num << 3 | 3, Bytes::new()) }, Frame::Close { stream_id: LocalStreamId { num, role: Endpoint::Dialer } } => { - (u64::from(num) << 3 | 4, Bytes::new()) + (num << 3 | 4, Bytes::new()) }, Frame::Reset { stream_id: LocalStreamId { num, role: Endpoint::Listener } } => { - (u64::from(num) << 3 | 5, Bytes::new()) + (num << 3 | 5, Bytes::new()) }, Frame::Reset { stream_id: LocalStreamId { num, role: Endpoint::Dialer } } => { - (u64::from(num) << 3 | 6, Bytes::new()) + (num << 3 | 6, Bytes::new()) }, }; diff --git a/protocols/identify/src/handler.rs b/protocols/identify/src/handler.rs index 0f541a86587..11c239cdfab 100644 --- a/protocols/identify/src/handler.rs +++ b/protocols/identify/src/handler.rs @@ -211,7 +211,7 @@ impl ProtocolsHandler for IdentifyHandler { }; Poll::Ready(ev) } - Poll::Ready(Err(err)) => Poll::Ready(ProtocolsHandlerEvent::Close(err.into())) + Poll::Ready(Err(err)) => Poll::Ready(ProtocolsHandlerEvent::Close(err)) } } } diff --git a/protocols/identify/src/protocol.rs b/protocols/identify/src/protocol.rs index c3a323ddd0d..896abd7186c 100644 --- a/protocols/identify/src/protocol.rs +++ b/protocols/identify/src/protocol.rs @@ -207,7 +207,7 @@ where Ok(v) => v, Err(err) => { debug!("Invalid message: {:?}", err); - return Err(err.into()) + return Err(err) } }; diff --git a/protocols/kad/src/kbucket.rs b/protocols/kad/src/kbucket.rs index a77d39f0ee7..ff00b0d7ed0 100644 --- a/protocols/kad/src/kbucket.rs +++ b/protocols/kad/src/kbucket.rs @@ -186,7 +186,7 @@ where /// /// The buckets are ordered by proximity to the `local_key`, i.e. the first /// bucket is the closest bucket (containing at most one key). - pub fn iter<'a>(&'a mut self) -> impl Iterator> + 'a { + pub fn iter(&mut self) -> impl Iterator> + '_ { let applied_pending = &mut self.applied_pending; self.buckets.iter_mut().enumerate().map(move |(i, b)| { if let Some(applied) = b.apply_pending() { diff --git a/protocols/mdns/src/dns.rs b/protocols/mdns/src/dns.rs index e0645feac82..fa89caa3fc6 100644 --- a/protocols/mdns/src/dns.rs +++ b/protocols/mdns/src/dns.rs @@ -371,8 +371,7 @@ fn append_txt_record( if value.len() > MAX_TXT_VALUE_LENGTH { return Err(MdnsResponseError::TxtRecordTooLong); } - let mut buffer = Vec::new(); - buffer.push(value.len() as u8); + let mut buffer = vec![value.len() as u8]; append_character_string(&mut buffer, value)?; append_u16(out, buffer.len() as u16); diff --git a/transports/noise/src/protocol/x25519.rs b/transports/noise/src/protocol/x25519.rs index 389c5b94e93..c4e79bc33ae 100644 --- a/transports/noise/src/protocol/x25519.rs +++ b/transports/noise/src/protocol/x25519.rs @@ -235,7 +235,7 @@ impl snow::types::Dh for Keypair { fn set(&mut self, sk: &[u8]) { let mut secret = [0u8; 32]; - secret.copy_from_slice(&sk[..]); + secret.copy_from_slice(&sk); self.secret = SecretKey(X25519(secret)); // Copy self.public = PublicKey(X25519(x25519(secret, X25519_BASEPOINT_BYTES))); secret.zeroize(); diff --git a/transports/noise/src/protocol/x25519_spec.rs b/transports/noise/src/protocol/x25519_spec.rs index c2f3209580b..16e3ffeafee 100644 --- a/transports/noise/src/protocol/x25519_spec.rs +++ b/transports/noise/src/protocol/x25519_spec.rs @@ -146,7 +146,7 @@ impl snow::types::Dh for Keypair { fn set(&mut self, sk: &[u8]) { let mut secret = [0u8; 32]; - secret.copy_from_slice(&sk[..]); + secret.copy_from_slice(&sk); self.secret = SecretKey(X25519Spec(secret)); // Copy self.public = PublicKey(X25519Spec(x25519(secret, X25519_BASEPOINT_BYTES))); secret.zeroize();