diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..3f2c1e60 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[alias] +# Temporary solution to have clippy config in a single place until https://github.com/rust-lang/rust-clippy/blob/master/doc/roadmap-2021.md#lintstoml-configuration is shipped. +custom-clippy = "clippy -- -A clippy::type_complexity -A clippy::pedantic -A clippy::style -D warnings" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46d7bab7..1f625bc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -152,8 +152,7 @@ jobs: - name: Run cargo clippy uses: actions-rs/cargo@v1.0.3 with: - command: clippy - args: -- -A clippy::type_complexity -A clippy::pedantic -A clippy::style + command: custom-clippy # cargo alias to allow reuse of config locally integration-test: name: Integration tests diff --git a/protocols/relay/src/behaviour.rs b/protocols/relay/src/behaviour.rs index 81fe6da8..78e9e5d8 100644 --- a/protocols/relay/src/behaviour.rs +++ b/protocols/relay/src/behaviour.rs @@ -756,6 +756,7 @@ impl NetworkBehaviour for Relay { } #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum BehaviourToListenerMsg { ConnectionToRelayEstablished, IncomingRelayedConnection { diff --git a/protocols/relay/src/handler.rs b/protocols/relay/src/handler.rs index 7ea0d873..e336b482 100644 --- a/protocols/relay/src/handler.rs +++ b/protocols/relay/src/handler.rs @@ -733,6 +733,7 @@ impl ProtocolsHandler for RelayHandler { } } +#[allow(clippy::large_enum_variant)] pub enum RelayOutboundOpenInfo { Relay { dst_peer_id: PeerId, diff --git a/protocols/relay/src/protocol/listen.rs b/protocols/relay/src/protocol/listen.rs index 70a08464..168861a2 100644 --- a/protocols/relay/src/protocol/listen.rs +++ b/protocols/relay/src/protocol/listen.rs @@ -76,7 +76,7 @@ impl upgrade::InboundUpgrade for RelayListen { let msg: bytes::BytesMut = substream .next() .await - .ok_or(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""))??; + .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""))??; let CircuitRelay { r#type, src_peer, diff --git a/protocols/relay/src/protocol/outgoing_dst_req.rs b/protocols/relay/src/protocol/outgoing_dst_req.rs index 0a257da3..7cffb1a1 100644 --- a/protocols/relay/src/protocol/outgoing_dst_req.rs +++ b/protocols/relay/src/protocol/outgoing_dst_req.rs @@ -100,7 +100,7 @@ impl upgrade::OutboundUpgrade for OutgoingDstReq { substream .next() .await - .ok_or(OutgoingDstReqError::Io(std::io::Error::new( + .ok_or_else(|| OutgoingDstReqError::Io(std::io::Error::new( std::io::ErrorKind::UnexpectedEof, "", )))??; diff --git a/protocols/relay/src/protocol/outgoing_relay_req.rs b/protocols/relay/src/protocol/outgoing_relay_req.rs index 8f6ed8b3..a34f10eb 100644 --- a/protocols/relay/src/protocol/outgoing_relay_req.rs +++ b/protocols/relay/src/protocol/outgoing_relay_req.rs @@ -87,7 +87,7 @@ impl upgrade::OutboundUpgrade for OutgoingRelayReq { }), dst_peer: Some(circuit_relay::Peer { id: dst_id.to_bytes(), - addrs: vec![dst_address.unwrap_or(Multiaddr::empty()).to_vec()], + addrs: vec![dst_address.unwrap_or_else(Multiaddr::empty).to_vec()], }), code: None, }; @@ -107,7 +107,7 @@ impl upgrade::OutboundUpgrade for OutgoingRelayReq { substream .next() .await - .ok_or(OutgoingRelayReqError::Io(std::io::Error::new( + .ok_or_else(|| OutgoingRelayReqError::Io(std::io::Error::new( std::io::ErrorKind::UnexpectedEof, "", )))??; diff --git a/protocols/relay/src/transport.rs b/protocols/relay/src/transport.rs index 4aa96f69..b3729c05 100644 --- a/protocols/relay/src/transport.rs +++ b/protocols/relay/src/transport.rs @@ -198,7 +198,7 @@ impl Transport for RelayTransport { }; let (to_listener, from_behaviour) = mpsc::channel(0); - let mut to_behaviour = self.to_behaviour.clone(); + let mut to_behaviour = self.to_behaviour; let msg_to_behaviour = Some( async move { to_behaviour @@ -242,7 +242,7 @@ impl Transport for RelayTransport { let relay_addr = relay_addr.ok_or(RelayError::MissingRelayAddr)?; let dst_peer_id = dst_peer_id.ok_or(RelayError::MissingDstPeerId)?; - let mut to_behaviour = self.to_behaviour.clone(); + let mut to_behaviour = self.to_behaviour; Ok(EitherFuture::Second( async move { let (tx, rx) = oneshot::channel(); diff --git a/transports/dns/src/lib.rs b/transports/dns/src/lib.rs index 0d2e2212..499f33e8 100644 --- a/transports/dns/src/lib.rs +++ b/transports/dns/src/lib.rs @@ -330,6 +330,7 @@ where /// The possible errors of a [`GenDnsConfig`] wrapped transport. #[derive(Debug)] +#[allow(clippy::large_enum_variant)] pub enum DnsErr { /// The underlying transport encountered an error. Transport(TErr),