Skip to content

Commit 7877929

Browse files
.github/: Enforce no clippy warnings (#2148)
* Fix remaining clippy warnings. Co-authored-by: Max Inden <[email protected]>
1 parent e437c00 commit 7877929

File tree

9 files changed

+13
-8
lines changed

9 files changed

+13
-8
lines changed

.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[alias]
2+
# 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.
3+
custom-clippy = "clippy -- -A clippy::type_complexity -A clippy::pedantic -A clippy::style -D warnings"

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ jobs:
152152
- name: Run cargo clippy
153153
uses: actions-rs/[email protected]
154154
with:
155-
command: clippy
156-
args: -- -A clippy::type_complexity -A clippy::pedantic -A clippy::style
155+
command: custom-clippy # cargo alias to allow reuse of config locally
157156

158157
integration-test:
159158
name: Integration tests

protocols/relay/src/behaviour.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ impl NetworkBehaviour for Relay {
756756
}
757757

758758
#[derive(Debug)]
759+
#[allow(clippy::large_enum_variant)]
759760
pub enum BehaviourToListenerMsg {
760761
ConnectionToRelayEstablished,
761762
IncomingRelayedConnection {

protocols/relay/src/handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ impl ProtocolsHandler for RelayHandler {
733733
}
734734
}
735735

736+
#[allow(clippy::large_enum_variant)]
736737
pub enum RelayOutboundOpenInfo {
737738
Relay {
738739
dst_peer_id: PeerId,

protocols/relay/src/protocol/listen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl upgrade::InboundUpgrade<NegotiatedSubstream> for RelayListen {
7676
let msg: bytes::BytesMut = substream
7777
.next()
7878
.await
79-
.ok_or(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""))??;
79+
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""))??;
8080
let CircuitRelay {
8181
r#type,
8282
src_peer,

protocols/relay/src/protocol/outgoing_dst_req.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingDstReq {
100100
substream
101101
.next()
102102
.await
103-
.ok_or(OutgoingDstReqError::Io(std::io::Error::new(
103+
.ok_or_else(|| OutgoingDstReqError::Io(std::io::Error::new(
104104
std::io::ErrorKind::UnexpectedEof,
105105
"",
106106
)))??;

protocols/relay/src/protocol/outgoing_relay_req.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingRelayReq {
8787
}),
8888
dst_peer: Some(circuit_relay::Peer {
8989
id: dst_id.to_bytes(),
90-
addrs: vec![dst_address.unwrap_or(Multiaddr::empty()).to_vec()],
90+
addrs: vec![dst_address.unwrap_or_else(Multiaddr::empty).to_vec()],
9191
}),
9292
code: None,
9393
};
@@ -107,7 +107,7 @@ impl upgrade::OutboundUpgrade<NegotiatedSubstream> for OutgoingRelayReq {
107107
substream
108108
.next()
109109
.await
110-
.ok_or(OutgoingRelayReqError::Io(std::io::Error::new(
110+
.ok_or_else(|| OutgoingRelayReqError::Io(std::io::Error::new(
111111
std::io::ErrorKind::UnexpectedEof,
112112
"",
113113
)))??;

protocols/relay/src/transport.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<T: Transport + Clone> Transport for RelayTransport<T> {
198198
};
199199

200200
let (to_listener, from_behaviour) = mpsc::channel(0);
201-
let mut to_behaviour = self.to_behaviour.clone();
201+
let mut to_behaviour = self.to_behaviour;
202202
let msg_to_behaviour = Some(
203203
async move {
204204
to_behaviour
@@ -242,7 +242,7 @@ impl<T: Transport + Clone> Transport for RelayTransport<T> {
242242
let relay_addr = relay_addr.ok_or(RelayError::MissingRelayAddr)?;
243243
let dst_peer_id = dst_peer_id.ok_or(RelayError::MissingDstPeerId)?;
244244

245-
let mut to_behaviour = self.to_behaviour.clone();
245+
let mut to_behaviour = self.to_behaviour;
246246
Ok(EitherFuture::Second(
247247
async move {
248248
let (tx, rx) = oneshot::channel();

transports/dns/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ where
330330

331331
/// The possible errors of a [`GenDnsConfig`] wrapped transport.
332332
#[derive(Debug)]
333+
#[allow(clippy::large_enum_variant)]
333334
pub enum DnsErr<TErr> {
334335
/// The underlying transport encountered an error.
335336
Transport(TErr),

0 commit comments

Comments
 (0)