-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dcutr: fix clippy lints #2772
dcutr: fix clippy lints #2772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK modulo one thing.
@@ -324,7 +320,6 @@ impl NetworkBehaviour for Behaviour { | |||
|
|||
/// A [`NetworkBehaviourAction`], either complete, or still requiring data from [`PollParameters`] | |||
/// before being returned in [`Behaviour::poll`]. | |||
#[allow(clippy::large_enum_variant)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I always allow this one because the Box is quite the ergonomic hit when pattern matching and the lint desc. also says that one would need to measure the performance benefit gained from boxing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that in some cases it makes more sense to allow this lint rather than using a Box
.
That being said, in this case here we pass around the inbound_connect
quite a bit without using it, and for all enums it appeared on this error was thrown. We can wrap it once in a Box
and pass that around instead, without any ergonomic hit. The only place where inbound_connect
is used is in
rust-libp2p/protocols/dcutr/src/handler/relayed.rs
Lines 371 to 373 in f85a990
if let Some(Poll::Ready(result)) = self.inbound_connect.as_mut().map(|f| f.poll_unpin(cx)) { | |
self.inbound_connect = None; |
where we have to use
AsMut
anyway to access the inner future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Elena!
Description
Fix clippy warnings in libp2p-dcutr:
new-without-default
,single-match
,large-enum-variant
,redundant-pattern-matching
andredundant-closure
.