Fix some rustc/clippy warnings. (#895)

This commit is contained in:
Toralf Wittner
2019-01-30 15:41:54 +01:00
committed by GitHub
parent a77da73010
commit e23b2733e2
25 changed files with 63 additions and 60 deletions

View File

@ -35,7 +35,7 @@ impl TopicHash {
/// Builds a new `TopicHash` from the given hash.
#[inline]
pub fn from_raw(hash: String) -> TopicHash {
TopicHash { hash: hash }
TopicHash { hash }
}
#[inline]
@ -94,7 +94,7 @@ impl TopicBuilder {
let mut builder = rpc_proto::TopicDescriptor::new();
builder.set_name(name.into());
TopicBuilder { builder: builder }
TopicBuilder { builder }
}
/// Turns the builder into an actual `Topic`.

View File

@ -208,7 +208,7 @@ where T: AsyncRead + AsyncWrite,
Ok(v) => v,
Err(err) => {
debug!("Failed to parse protobuf message; error = {:?}", err);
return Err(err.into());
return Err(err)
}
};
@ -248,7 +248,7 @@ fn parse_proto_msg(msg: BytesMut) -> Result<(IdentifyInfo, Multiaddr), IoError>
public_key: PublicKey::from_protobuf_encoding(msg.get_publicKey())?,
protocol_version: msg.take_protocolVersion(),
agent_version: msg.take_agentVersion(),
listen_addrs: listen_addrs,
listen_addrs,
protocols: msg.take_protocols().into_vec(),
};

View File

@ -112,9 +112,9 @@ impl KadPeer {
let connection_ty = peer.get_connection().into();
Ok(KadPeer {
node_id: node_id,
node_id,
multiaddrs: addrs,
connection_ty: connection_ty,
connection_ty
})
}
}

View File

@ -102,7 +102,7 @@ where
if !self.nonce.is_empty() {
let n = min(data_buf.len(), self.nonce.len());
if &data_buf[.. n] != &self.nonce[.. n] {
if data_buf[.. n] != self.nonce[.. n] {
return Err(SecioError::NonceVerificationFailed)
}
self.nonce.drain(.. n);

View File

@ -549,7 +549,7 @@ where
let (encoding_cipher, encoding_hmac) = {
let (iv, rest) = local_infos.split_at(iv_size);
let (cipher_key, mac_key) = rest.split_at(cipher_key_size);
let hmac = Hmac::from_key(context.state.remote.chosen_hash.into(), mac_key);
let hmac = Hmac::from_key(context.state.remote.chosen_hash, mac_key);
let cipher = ctr(chosen_cipher, cipher_key, iv);
(cipher, hmac)
};
@ -557,7 +557,7 @@ where
let (decoding_cipher, decoding_hmac) = {
let (iv, rest) = remote_infos.split_at(iv_size);
let (cipher_key, mac_key) = rest.split_at(cipher_key_size);
let hmac = Hmac::from_key(context.state.remote.chosen_hash.into(), mac_key);
let hmac = Hmac::from_key(context.state.remote.chosen_hash, mac_key);
let cipher = ctr(chosen_cipher, cipher_key, iv);
(cipher, hmac)
};