Skip to content

Commit ba767ae

Browse files
committed
Warn on clippy::use_self
1 parent 3b996aa commit ba767ae

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

src/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl TlsConnector {
3131
/// If you want to use 0-RTT,
3232
/// You must also set `ClientConfig.enable_early_data` to `true`.
3333
#[cfg(feature = "early-data")]
34-
pub fn early_data(mut self, flag: bool) -> TlsConnector {
34+
pub fn early_data(mut self, flag: bool) -> Self {
3535
self.early_data = flag;
3636
self
3737
}
@@ -114,8 +114,8 @@ impl TlsConnector {
114114
}
115115

116116
impl From<Arc<ClientConfig>> for TlsConnector {
117-
fn from(inner: Arc<ClientConfig>) -> TlsConnector {
118-
TlsConnector {
117+
fn from(inner: Arc<ClientConfig>) -> Self {
118+
Self {
119119
inner,
120120
#[cfg(feature = "early-data")]
121121
early_data: false,

src/common/handshake.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ where
4545
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
4646
let this = self.get_mut();
4747

48-
let mut stream = match mem::replace(this, MidHandshake::End) {
49-
MidHandshake::Handshaking(stream) => stream,
50-
MidHandshake::SendAlert {
48+
let mut stream = match mem::replace(this, Self::End) {
49+
Self::Handshaking(stream) => stream,
50+
Self::SendAlert {
5151
mut io,
5252
mut alert,
5353
error,
5454
} => loop {
5555
match alert.write(&mut SyncWriteAdapter { io: &mut io, cx }) {
5656
Err(e) if e.kind() == io::ErrorKind::WouldBlock => {
57-
*this = MidHandshake::SendAlert { io, error, alert };
57+
*this = Self::SendAlert { io, error, alert };
5858
return Poll::Pending;
5959
}
6060
Err(_) | Ok(0) => return Poll::Ready(Err((error, io))),
6161
Ok(_) => {}
6262
};
6363
},
6464
// Starting the handshake returned an error; fail the future immediately.
65-
MidHandshake::Error { io, error } => return Poll::Ready(Err((error, io))),
65+
Self::Error { io, error } => return Poll::Ready(Err((error, io))),
6666
_ => panic!("unexpected polling after handshake"),
6767
};
6868

src/common/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,33 @@ impl TlsState {
2323
#[inline]
2424
pub(crate) fn shutdown_read(&mut self) {
2525
match *self {
26-
TlsState::WriteShutdown | TlsState::FullyShutdown => *self = TlsState::FullyShutdown,
27-
_ => *self = TlsState::ReadShutdown,
26+
Self::WriteShutdown | Self::FullyShutdown => *self = Self::FullyShutdown,
27+
_ => *self = Self::ReadShutdown,
2828
}
2929
}
3030

3131
#[inline]
3232
pub(crate) fn shutdown_write(&mut self) {
3333
match *self {
34-
TlsState::ReadShutdown | TlsState::FullyShutdown => *self = TlsState::FullyShutdown,
35-
_ => *self = TlsState::WriteShutdown,
34+
Self::ReadShutdown | Self::FullyShutdown => *self = Self::FullyShutdown,
35+
_ => *self = Self::WriteShutdown,
3636
}
3737
}
3838

3939
#[inline]
4040
pub(crate) fn writeable(&self) -> bool {
41-
!matches!(*self, TlsState::WriteShutdown | TlsState::FullyShutdown)
41+
!matches!(*self, Self::WriteShutdown | Self::FullyShutdown)
4242
}
4343

4444
#[inline]
4545
pub(crate) fn readable(&self) -> bool {
46-
!matches!(*self, TlsState::ReadShutdown | TlsState::FullyShutdown)
46+
!matches!(*self, Self::ReadShutdown | Self::FullyShutdown)
4747
}
4848

4949
#[inline]
5050
#[cfg(feature = "early-data")]
5151
pub(crate) fn is_early_data(&self) -> bool {
52-
matches!(self, TlsState::EarlyData(..))
52+
matches!(self, Self::EarlyData(..))
5353
}
5454

5555
#[inline]

src/lib.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//!
3737
//! see <https://github.com/tokio-rs/tls/issues/41>
3838
39-
#![warn(unreachable_pub)]
39+
#![warn(unreachable_pub, clippy::use_self)]
4040

4141
use std::io;
4242
#[cfg(unix)]
@@ -150,8 +150,8 @@ where
150150
buf: &mut ReadBuf<'_>,
151151
) -> Poll<io::Result<()>> {
152152
match self.get_mut() {
153-
TlsStream::Client(x) => Pin::new(x).poll_read(cx, buf),
154-
TlsStream::Server(x) => Pin::new(x).poll_read(cx, buf),
153+
Self::Client(x) => Pin::new(x).poll_read(cx, buf),
154+
Self::Server(x) => Pin::new(x).poll_read(cx, buf),
155155
}
156156
}
157157
}
@@ -163,16 +163,16 @@ where
163163
#[inline]
164164
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&[u8]>> {
165165
match self.get_mut() {
166-
TlsStream::Client(x) => Pin::new(x).poll_fill_buf(cx),
167-
TlsStream::Server(x) => Pin::new(x).poll_fill_buf(cx),
166+
Self::Client(x) => Pin::new(x).poll_fill_buf(cx),
167+
Self::Server(x) => Pin::new(x).poll_fill_buf(cx),
168168
}
169169
}
170170

171171
#[inline]
172172
fn consume(self: Pin<&mut Self>, amt: usize) {
173173
match self.get_mut() {
174-
TlsStream::Client(x) => Pin::new(x).consume(amt),
175-
TlsStream::Server(x) => Pin::new(x).consume(amt),
174+
Self::Client(x) => Pin::new(x).consume(amt),
175+
Self::Server(x) => Pin::new(x).consume(amt),
176176
}
177177
}
178178
}
@@ -188,8 +188,8 @@ where
188188
buf: &[u8],
189189
) -> Poll<io::Result<usize>> {
190190
match self.get_mut() {
191-
TlsStream::Client(x) => Pin::new(x).poll_write(cx, buf),
192-
TlsStream::Server(x) => Pin::new(x).poll_write(cx, buf),
191+
Self::Client(x) => Pin::new(x).poll_write(cx, buf),
192+
Self::Server(x) => Pin::new(x).poll_write(cx, buf),
193193
}
194194
}
195195

@@ -200,32 +200,32 @@ where
200200
bufs: &[io::IoSlice<'_>],
201201
) -> Poll<io::Result<usize>> {
202202
match self.get_mut() {
203-
TlsStream::Client(x) => Pin::new(x).poll_write_vectored(cx, bufs),
204-
TlsStream::Server(x) => Pin::new(x).poll_write_vectored(cx, bufs),
203+
Self::Client(x) => Pin::new(x).poll_write_vectored(cx, bufs),
204+
Self::Server(x) => Pin::new(x).poll_write_vectored(cx, bufs),
205205
}
206206
}
207207

208208
#[inline]
209209
fn is_write_vectored(&self) -> bool {
210210
match self {
211-
TlsStream::Client(x) => x.is_write_vectored(),
212-
TlsStream::Server(x) => x.is_write_vectored(),
211+
Self::Client(x) => x.is_write_vectored(),
212+
Self::Server(x) => x.is_write_vectored(),
213213
}
214214
}
215215

216216
#[inline]
217217
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
218218
match self.get_mut() {
219-
TlsStream::Client(x) => Pin::new(x).poll_flush(cx),
220-
TlsStream::Server(x) => Pin::new(x).poll_flush(cx),
219+
Self::Client(x) => Pin::new(x).poll_flush(cx),
220+
Self::Server(x) => Pin::new(x).poll_flush(cx),
221221
}
222222
}
223223

224224
#[inline]
225225
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
226226
match self.get_mut() {
227-
TlsStream::Client(x) => Pin::new(x).poll_shutdown(cx),
228-
TlsStream::Server(x) => Pin::new(x).poll_shutdown(cx),
227+
Self::Client(x) => Pin::new(x).poll_shutdown(cx),
228+
Self::Server(x) => Pin::new(x).poll_shutdown(cx),
229229
}
230230
}
231231
}

src/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub struct TlsAcceptor {
2121
}
2222

2323
impl From<Arc<ServerConfig>> for TlsAcceptor {
24-
fn from(inner: Arc<ServerConfig>) -> TlsAcceptor {
25-
TlsAcceptor { inner }
24+
fn from(inner: Arc<ServerConfig>) -> Self {
25+
Self { inner }
2626
}
2727
}
2828

tests/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mod utils {
8282
impl<S> FlushWrapper<S> {
8383
#[allow(dead_code)]
8484
pub(crate) fn new(stream: S) -> Self {
85-
FlushWrapper {
85+
Self {
8686
stream,
8787
buf: VecDeque::new(),
8888
queued: Vec::new(),

0 commit comments

Comments
 (0)