Skip to content

Commit e29ca22

Browse files
chore: Clippy stuff (#2879)
Co-authored-by: boquan-fang <[email protected]> Co-authored-by: Boquan Fang <[email protected]>
1 parent 1e12360 commit e29ca22

File tree

8 files changed

+18
-62
lines changed

8 files changed

+18
-62
lines changed

quic/s2n-quic-core/src/event/generated.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6921,20 +6921,16 @@ pub mod supervisor {
69216921
event::{builder::SocketAddress, IntoEvent},
69226922
};
69236923
#[non_exhaustive]
6924-
#[derive(Clone, Debug, Eq, PartialEq)]
6924+
#[derive(Clone, Debug, Default, Eq, PartialEq)]
69256925
pub enum Outcome {
69266926
#[doc = r" Allow the connection to remain open"]
6927+
#[default]
69276928
Continue,
69286929
#[doc = r" Close the connection and notify the peer"]
69296930
Close { error_code: application::Error },
69306931
#[doc = r" Close the connection without notifying the peer"]
69316932
ImmediateClose { reason: &'static str },
69326933
}
6933-
impl Default for Outcome {
6934-
fn default() -> Self {
6935-
Self::Continue
6936-
}
6937-
}
69386934
#[non_exhaustive]
69396935
#[derive(Debug)]
69406936
pub struct Context<'a> {

quic/s2n-quic-core/src/frame/ack_elicitation.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@ use core::ops::{BitOr, BitOrAssign};
1111
//# delay and are called ack-eliciting packets.
1212

1313
/// Describes if a frame or packet requires an ACK from the peer
14-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
14+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
1515
#[cfg_attr(any(test, feature = "generator"), derive(TypeGenerator))]
1616
pub enum AckElicitation {
17+
#[default]
1718
NonEliciting,
1819
Eliciting,
1920
}
2021

21-
impl Default for AckElicitation {
22-
fn default() -> Self {
23-
Self::NonEliciting
24-
}
25-
}
26-
2722
impl AckElicitation {
2823
/// Returns true if the `AckElicitation` is set to `Eliciting`
2924
pub fn is_ack_eliciting(self) -> bool {

quic/s2n-quic-core/src/packet/short.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,13 @@ const SPIN_BIT_MASK: u8 = 0x20;
5757

5858
const RESERVED_BITS_MASK: u8 = 0x18;
5959

60-
#[derive(Clone, Copy, Debug, PartialEq)]
60+
#[derive(Clone, Copy, Debug, PartialEq, Default)]
6161
pub enum SpinBit {
62+
#[default]
6263
Zero,
6364
One,
6465
}
6566

66-
impl Default for SpinBit {
67-
fn default() -> Self {
68-
Self::Zero
69-
}
70-
}
71-
7267
impl SpinBit {
7368
fn from_tag(tag: Tag) -> Self {
7469
if tag & SPIN_BIT_MASK == SPIN_BIT_MASK {

quic/s2n-quic-rustls/src/session.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,9 @@ impl tls::Session for Session {
391391
}
392392
}
393393

394-
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
394+
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Default)]
395395
enum HandshakePhase {
396+
#[default]
396397
Initial,
397398
Handshake,
398399
Application,
@@ -406,9 +407,3 @@ impl HandshakePhase {
406407
};
407408
}
408409
}
409-
410-
impl Default for HandshakePhase {
411-
fn default() -> Self {
412-
Self::Initial
413-
}
414-
}

quic/s2n-quic-tls/src/callback.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,9 @@ impl State {
398398
}
399399
}
400400

401-
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
401+
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Default)]
402402
enum HandshakePhase {
403+
#[default]
403404
Initial,
404405
Handshake,
405406
Application,
@@ -414,27 +415,16 @@ impl HandshakePhase {
414415
}
415416
}
416417

417-
impl Default for HandshakePhase {
418-
fn default() -> Self {
419-
Self::Initial
420-
}
421-
}
422-
423-
#[derive(Debug)]
418+
#[derive(Debug, Default)]
424419
enum Secrets {
420+
#[default]
425421
Waiting,
426422
Half {
427423
secret: Prk,
428424
id: s2n_secret_type_t::Type,
429425
},
430426
}
431427

432-
impl Default for Secrets {
433-
fn default() -> Self {
434-
Self::Waiting
435-
}
436-
}
437-
438428
fn get_algo_type(
439429
connection: *mut s2n_connection,
440430
) -> Option<(hkdf::Algorithm, &'static aead::Algorithm, CipherSuite)> {

quic/s2n-quic-transport/src/connection/close_sender.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ impl<Config: endpoint::Config, Pub: event::ConnectionPublisher> tx::Message
190190
}
191191
}
192192

193-
#[derive(Debug)]
193+
#[derive(Debug, Default)]
194194
enum State {
195+
#[default]
195196
Idle,
196197
Closing {
197198
packet: Bytes,
@@ -202,12 +203,6 @@ enum State {
202203
Closed,
203204
}
204205

205-
impl Default for State {
206-
fn default() -> Self {
207-
Self::Idle
208-
}
209-
}
210-
211206
impl State {
212207
pub fn on_timeout(&mut self, now: Timestamp) -> Poll<()> {
213208
match self {

quic/s2n-quic-transport/src/sync/flag.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ pub trait Writer: Default {
2626
fn write_frame<W: WriteContext>(&mut self, context: &mut W) -> Option<PacketNumber>;
2727
}
2828

29-
#[derive(Debug, PartialEq)]
29+
#[derive(Debug, PartialEq, Default)]
3030
enum DeliveryState {
3131
/// The flag has not been requested
32+
#[default]
3233
Idle,
3334

3435
/// The flag needs to be transmitted
@@ -60,12 +61,6 @@ enum DeliveryState {
6061
Delivered,
6162
}
6263

63-
impl Default for DeliveryState {
64-
fn default() -> Self {
65-
Self::Idle
66-
}
67-
}
68-
6964
impl<W: Writer> Flag<W> {
7065
/// Constructs a flag with the given `writer`
7166
pub fn new(writer: W) -> Self {

tools/s2n-events/src/generate_config.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ impl GenerateConfig {
173173
};
174174

175175
#[non_exhaustive]
176-
#[derive(Clone, Debug, Eq, PartialEq)]
176+
#[derive(Clone, Debug, Default, Eq, PartialEq)]
177177
pub enum Outcome {
178178
/// Allow the connection to remain open
179+
#[default]
179180
Continue,
180181

181182
/// Close the connection and notify the peer
@@ -185,12 +186,6 @@ impl GenerateConfig {
185186
ImmediateClose { reason: &'static str },
186187
}
187188

188-
impl Default for Outcome {
189-
fn default() -> Self {
190-
Self::Continue
191-
}
192-
}
193-
194189
#[non_exhaustive]
195190
#[derive(Debug)]
196191
pub struct Context<'a> {

0 commit comments

Comments
 (0)