chore: fix clippy warnings in newer versions (#3588)

This commit is contained in:
cssivision 2021-03-10 15:42:24 +08:00 committed by GitHub
parent 8c5cde9bc3
commit bcb95db4e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 21 deletions

View File

@ -535,14 +535,14 @@ impl LengthDelimitedCodec {
Ok(Some(n)) Ok(Some(n))
} }
fn decode_data(&self, n: usize, src: &mut BytesMut) -> io::Result<Option<BytesMut>> { fn decode_data(&self, n: usize, src: &mut BytesMut) -> Option<BytesMut> {
// At this point, the buffer has already had the required capacity // At this point, the buffer has already had the required capacity
// reserved. All there is to do is read. // reserved. All there is to do is read.
if src.len() < n { if src.len() < n {
return Ok(None); return None;
} }
Ok(Some(src.split_to(n))) Some(src.split_to(n))
} }
} }
@ -562,7 +562,7 @@ impl Decoder for LengthDelimitedCodec {
DecodeState::Data(n) => n, DecodeState::Data(n) => n,
}; };
match self.decode_data(n, src)? { match self.decode_data(n, src) {
Some(data) => { Some(data) => {
// Update the decode state // Update the decode state
self.state = DecodeState::Head; self.state = DecodeState::Head;

View File

@ -126,10 +126,7 @@ impl<T: Send + 'static> PollSender<T> {
/// If this method returns `None`, then the channel is closed. (But it is /// If this method returns `None`, then the channel is closed. (But it is
/// not guaranteed to return `None` if the channel is closed.) /// not guaranteed to return `None` if the channel is closed.)
pub fn clone_inner(&self) -> Option<Sender<T>> { pub fn clone_inner(&self) -> Option<Sender<T>> {
match &self.sender { self.sender.as_ref().map(|sender| (&**sender).clone())
Some(sender) => Some((&**sender).clone()),
None => None,
}
} }
/// Access the underlying `Sender`. /// Access the underlying `Sender`.

View File

@ -443,7 +443,7 @@ cfg_io_readiness! {
// Currently ready! // Currently ready!
let tick = TICK.unpack(curr) as u8; let tick = TICK.unpack(curr) as u8;
*state = State::Done; *state = State::Done;
return Poll::Ready(ReadyEvent { ready, tick }); return Poll::Ready(ReadyEvent { tick, ready });
} }
// Wasn't ready, take the lock (and check again while locked). // Wasn't ready, take the lock (and check again while locked).
@ -462,7 +462,7 @@ cfg_io_readiness! {
// Currently ready! // Currently ready!
let tick = TICK.unpack(curr) as u8; let tick = TICK.unpack(curr) as u8;
*state = State::Done; *state = State::Done;
return Poll::Ready(ReadyEvent { ready, tick }); return Poll::Ready(ReadyEvent { tick, ready });
} }
// Not ready even after locked, insert into list... // Not ready even after locked, insert into list...

View File

@ -40,20 +40,14 @@ cfg_time! {
cfg_test_util! { cfg_test_util! {
pub(crate) fn clock() -> Option<crate::runtime::driver::Clock> { pub(crate) fn clock() -> Option<crate::runtime::driver::Clock> {
CONTEXT.with(|ctx| match *ctx.borrow() { CONTEXT.with(|ctx| (*ctx.borrow()).as_ref().map(|ctx| ctx.clock.clone()))
Some(ref ctx) => Some(ctx.clock.clone()),
None => None,
})
} }
} }
} }
cfg_rt! { cfg_rt! {
pub(crate) fn spawn_handle() -> Option<crate::runtime::Spawner> { pub(crate) fn spawn_handle() -> Option<crate::runtime::Spawner> {
CONTEXT.with(|ctx| match *ctx.borrow() { CONTEXT.with(|ctx| (*ctx.borrow()).as_ref().map(|ctx| ctx.spawner.clone()))
Some(ref ctx) => Some(ctx.spawner.clone()),
None => None,
})
} }
} }

View File

@ -827,6 +827,6 @@ impl Shared {
} }
fn ptr_eq(&self, other: &Shared) -> bool { fn ptr_eq(&self, other: &Shared) -> bool {
self as *const _ == other as *const _ std::ptr::eq(self, other)
} }
} }

View File

@ -293,7 +293,7 @@ impl<T> Clone for Receiver<T> {
// not memory access. // not memory access.
shared.ref_count_rx.fetch_add(1, Relaxed); shared.ref_count_rx.fetch_add(1, Relaxed);
Receiver { version, shared } Receiver { shared, version }
} }
} }

View File

@ -661,7 +661,7 @@ impl Shared {
} }
fn ptr_eq(&self, other: &Shared) -> bool { fn ptr_eq(&self, other: &Shared) -> bool {
self as *const _ == other as *const _ std::ptr::eq(self, other)
} }
} }