ci: enable clippy lints (#1335)

This commit is contained in:
Taiki Endo
2019-07-26 03:47:14 +09:00
committed by GitHub
parent f311ac3d4f
commit fe021e6c00
54 changed files with 394 additions and 274 deletions
+2
View File
@@ -132,6 +132,7 @@ impl<T> Receiver<T> {
}
/// TODO: Dox
#[allow(clippy::needless_lifetimes)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3988
pub async fn recv(&mut self) -> Option<T> {
use async_util::future::poll_fn;
@@ -204,6 +205,7 @@ impl<T> Sender<T> {
/// ```
/// unimplemented!();
/// ```
#[allow(clippy::needless_lifetimes)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3988
pub async fn send(&mut self, value: T) -> Result<(), SendError> {
use async_util::future::poll_fn;
+1
View File
@@ -93,6 +93,7 @@ impl<T> UnboundedReceiver<T> {
}
/// TODO: Dox
#[allow(clippy::needless_lifetimes)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3988
pub async fn recv(&mut self) -> Option<T> {
use async_util::future::poll_fn;
+7 -6
View File
@@ -220,6 +220,7 @@ impl<T> Sender<T> {
/// ```
/// unimplemented!();
/// ```
#[allow(clippy::needless_lifetimes)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3988
pub async fn closed(&mut self) {
use async_util::future::poll_fn;
@@ -384,10 +385,10 @@ impl<T> Inner<T> {
None => Ready(Err(RecvError(()))),
}
} else {
return Pending;
Pending
}
} else {
return Pending;
Pending
}
}
}
@@ -498,7 +499,7 @@ impl State {
State(0)
}
fn is_complete(&self) -> bool {
fn is_complete(self) -> bool {
self.0 & VALUE_SENT == VALUE_SENT
}
@@ -510,7 +511,7 @@ impl State {
State(val)
}
fn is_rx_task_set(&self) -> bool {
fn is_rx_task_set(self) -> bool {
self.0 & RX_TASK_SET == RX_TASK_SET
}
@@ -524,7 +525,7 @@ impl State {
State(val & !RX_TASK_SET)
}
fn is_closed(&self) -> bool {
fn is_closed(self) -> bool {
self.0 & CLOSED == CLOSED
}
@@ -545,7 +546,7 @@ impl State {
State(val & !TX_TASK_SET)
}
fn is_tx_task_set(&self) -> bool {
fn is_tx_task_set(self) -> bool {
self.0 & TX_TASK_SET == TX_TASK_SET
}
+27 -20
View File
@@ -597,9 +597,9 @@ impl Permit {
}
match semaphore.poll_permit(Some((cx, self)))? {
Ready(v) => {
Ready(()) => {
self.state = PermitState::Acquired;
Ready(Ok(v))
Ready(Ok(()))
}
Pending => {
self.state = PermitState::Waiting;
@@ -671,6 +671,12 @@ impl Permit {
}
}
impl Default for Permit {
fn default() -> Self {
Self::new()
}
}
// ===== impl AcquireError ====
impl AcquireError {
@@ -874,8 +880,9 @@ impl WaiterNode {
NodeState::store(&self.state, Idle, Relaxed);
}
fn into_non_null(arc: Arc<WaiterNode>) -> NonNull<WaiterNode> {
let ptr = Arc::into_raw(arc);
#[allow(clippy::wrong_self_convention)] // https://github.com/rust-lang/rust-clippy/issues/4293
fn into_non_null(self: Arc<WaiterNode>) -> NonNull<WaiterNode> {
let ptr = Arc::into_raw(self);
unsafe { NonNull::new_unchecked(ptr as *mut _) }
}
}
@@ -921,7 +928,7 @@ impl SemState {
}
/// Returns the amount of remaining capacity
fn available_permits(&self) -> usize {
fn available_permits(self) -> usize {
if !self.has_available_permits() {
return 0;
}
@@ -930,11 +937,11 @@ impl SemState {
}
/// Returns true if the state has permits that can be claimed by a waiter.
fn has_available_permits(&self) -> bool {
fn has_available_permits(self) -> bool {
self.0 & NUM_FLAG == NUM_FLAG
}
fn has_waiter(&self, stub: &WaiterNode) -> bool {
fn has_waiter(self, stub: &WaiterNode) -> bool {
!self.has_available_permits() && !self.is_stub(stub)
}
@@ -978,12 +985,12 @@ impl SemState {
self.0 += permits << NUM_SHIFT;
}
fn is_waiter(&self) -> bool {
fn is_waiter(self) -> bool {
self.0 & NUM_FLAG == 0
}
/// Returns the waiter, if one is set.
fn waiter(&self) -> Option<NonNull<WaiterNode>> {
fn waiter(self) -> Option<NonNull<WaiterNode>> {
if self.is_waiter() {
let waiter = NonNull::new(self.as_ptr()).expect("null pointer stored");
@@ -994,7 +1001,7 @@ impl SemState {
}
/// Assumes `self` represents a pointer
fn as_ptr(&self) -> *mut WaiterNode {
fn as_ptr(self) -> *mut WaiterNode {
(self.0 & !CLOSED_FLAG) as *mut WaiterNode
}
@@ -1009,7 +1016,7 @@ impl SemState {
self.0 = waiter;
}
fn is_stub(&self, stub: &WaiterNode) -> bool {
fn is_stub(self, stub: &WaiterNode) -> bool {
self.as_ptr() as usize == stub as *const _ as usize
}
@@ -1021,7 +1028,7 @@ impl SemState {
}
/// Swap the values
fn swap(&self, cell: &AtomicUsize, ordering: Ordering) -> SemState {
fn swap(self, cell: &AtomicUsize, ordering: Ordering) -> SemState {
let prev = SemState(cell.swap(self.to_usize(), ordering));
debug_assert_eq!(prev.is_closed(), self.is_closed());
prev
@@ -1029,7 +1036,7 @@ impl SemState {
/// Compare and exchange the current value into the provided cell
fn compare_exchange(
&self,
self,
cell: &AtomicUsize,
prev: SemState,
success: Ordering,
@@ -1054,12 +1061,12 @@ impl SemState {
SemState(value)
}
fn is_closed(&self) -> bool {
fn is_closed(self) -> bool {
self.0 & CLOSED_FLAG == CLOSED_FLAG
}
/// Converts the state into a `usize` representation.
fn to_usize(&self) -> usize {
fn to_usize(self) -> usize {
self.0
}
}
@@ -1108,7 +1115,7 @@ impl NodeState {
}
fn compare_exchange(
&self,
self,
cell: &AtomicUsize,
prev: NodeState,
success: Ordering,
@@ -1120,16 +1127,16 @@ impl NodeState {
}
/// Returns `true` if `self` represents a queued state.
fn is_queued(&self) -> bool {
fn is_queued(self) -> bool {
use self::NodeState::*;
match *self {
match self {
Queued | QueuedWaiting => true,
_ => false,
}
}
fn to_usize(&self) -> usize {
*self as usize
fn to_usize(self) -> usize {
self as usize
}
}
+3 -1
View File
@@ -270,6 +270,7 @@ impl<T: Clone> Receiver<T> {
/// Attempts to clone the latest value sent via the channel.
///
/// This is equivalent to calling `Clone` on the value returned by `poll_ref`.
#[allow(clippy::map_clone)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3274
pub fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<T>> {
let item = ready!(self.poll_ref(cx));
Ready(item.map(|v_ref| v_ref.clone()))
@@ -280,6 +281,7 @@ impl<T: Clone> Receiver<T> {
impl<T: Clone> futures_core::Stream for Receiver<T> {
type Item = T;
#[allow(clippy::map_clone)] // false positive: https://github.com/rust-lang/rust-clippy/issues/3274
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<T>> {
let item = ready!(self.poll_ref(cx));
Ready(item.map(|v_ref| v_ref.clone()))
@@ -376,7 +378,7 @@ impl<T> futures_sink::Sink<T> for Sender<T> {
}
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> {
let _ = self.as_ref().get_ref().broadcast(item)?;
self.as_ref().get_ref().broadcast(item)?;
Ok(())
}