Fixed some clippy warnings

This commit is contained in:
huntc 2021-07-07 00:12:58 +10:00
parent a156f72bfb
commit 1b49acc2f7

View File

@ -98,9 +98,7 @@ unsafe impl<'ch, T> Sync for Receiver<'ch, T> {}
/// mpsc::split(&channel) /// mpsc::split(&channel)
/// }; /// };
/// ``` /// ```
pub fn split<'ch, T>( pub fn split<T>(channel: &UnsafeCell<dyn ChannelLike<T>>) -> (Sender<T>, Receiver<T>) {
channel: &'ch UnsafeCell<dyn ChannelLike<T>>,
) -> (Sender<'ch, T>, Receiver<'ch, T>) {
let sender = Sender { channel: &channel }; let sender = Sender { channel: &channel };
let receiver = Receiver { channel: &channel }; let receiver = Receiver { channel: &channel };
{ {
@ -296,6 +294,7 @@ impl<'ch, T> Drop for Sender<'ch, T> {
} }
impl<'ch, T> Clone for Sender<'ch, T> { impl<'ch, T> Clone for Sender<'ch, T> {
#[allow(clippy::clone_double_ref)]
fn clone(&self) -> Self { fn clone(&self) -> Self {
unsafe { &mut *self.channel.get() }.register_sender(); unsafe { &mut *self.channel.get() }.register_sender();
Sender { Sender {
@ -577,7 +576,7 @@ where
fn register_sender(&mut self) { fn register_sender(&mut self) {
let state = &mut self.state; let state = &mut self.state;
self.mutex.lock(|_| { self.mutex.lock(|_| {
state.senders_registered = state.senders_registered + 1; state.senders_registered += 1;
}) })
} }
@ -585,7 +584,7 @@ where
let state = &mut self.state; let state = &mut self.state;
self.mutex.lock(|_| { self.mutex.lock(|_| {
assert!(state.senders_registered > 0); assert!(state.senders_registered > 0);
state.senders_registered = state.senders_registered - 1; state.senders_registered -= 1;
if state.senders_registered == 0 { if state.senders_registered == 0 {
if let Some(w) = state.receiver_waker.take() { if let Some(w) = state.receiver_waker.take() {
w.wake(); w.wake();