chore: Fix clippy lints (#2931)

Closes: #2929

Co-authored-by: Bryan Donlan <[email protected]>
This commit is contained in:
bdonlan
2020-10-08 17:14:39 -07:00
committed by GitHub
co-authored by Bryan Donlan
parent 066965cd59
commit b704c53b9c
9 changed files with 20 additions and 50 deletions
+2 -2
View File
@@ -59,7 +59,7 @@ async fn multi_immediate_delays() {
let entry = assert_ready!(poll!(queue));
assert!(entry.is_none());
res.sort();
res.sort_unstable();
assert_eq!("1", res[0]);
assert_eq!("2", res[1]);
@@ -438,7 +438,7 @@ async fn insert_after_ready_poll() {
queue.insert_at("foo", now + ms(500));
}
res.sort();
res.sort_unstable();
assert_eq!("1", res[0]);
assert_eq!("2", res[1]);
+1 -5
View File
@@ -13,11 +13,7 @@ pub(crate) enum EnterContext {
impl EnterContext {
pub(crate) fn is_entered(self) -> bool {
if let EnterContext::Entered { .. } = self {
true
} else {
false
}
matches!(self, EnterContext::Entered { .. })
}
}
+2 -8
View File
@@ -30,10 +30,7 @@ impl JoinError {
/// Returns true if the error was caused by the task being cancelled
pub fn is_cancelled(&self) -> bool {
match &self.repr {
Repr::Cancelled => true,
_ => false,
}
matches!(&self.repr, Repr::Cancelled)
}
/// Returns true if the error was caused by the task panicking
@@ -53,10 +50,7 @@ impl JoinError {
/// }
/// ```
pub fn is_panic(&self) -> bool {
match &self.repr {
Repr::Panic(_) => true,
_ => false,
}
matches!(&self.repr, Repr::Panic(_))
}
/// Consumes the join error, returning the object with which the task panicked.
+2 -8
View File
@@ -527,20 +527,14 @@ impl TryAcquireError {
/// Returns `true` if the error was caused by a closed semaphore.
#[allow(dead_code)] // may be used later!
pub(crate) fn is_closed(&self) -> bool {
match self {
TryAcquireError::Closed => true,
_ => false,
}
matches!(self, TryAcquireError::Closed)
}
/// Returns `true` if the error was caused by calling `try_acquire` on a
/// semaphore with no available permits.
#[allow(dead_code)] // may be used later!
pub(crate) fn is_no_permits(&self) -> bool {
match self {
TryAcquireError::NoPermits => true,
_ => false,
}
matches!(self, TryAcquireError::NoPermits)
}
}
+3 -12
View File
@@ -40,10 +40,7 @@ impl Error {
/// Returns `true` if the error was caused by the timer being shutdown.
pub fn is_shutdown(&self) -> bool {
match self.0 {
Kind::Shutdown => true,
_ => false,
}
matches!(self.0, Kind::Shutdown)
}
/// Creates an error representing a timer at capacity.
@@ -53,10 +50,7 @@ impl Error {
/// Returns `true` if the error was caused by the timer being at capacity.
pub fn is_at_capacity(&self) -> bool {
match self.0 {
Kind::AtCapacity => true,
_ => false,
}
matches!(self.0, Kind::AtCapacity)
}
/// Create an error representing a misconfigured timer.
@@ -66,10 +60,7 @@ impl Error {
/// Returns `true` if the error was caused by the timer being misconfigured.
pub fn is_invalid(&self) -> bool {
match self.0 {
Kind::Invalid => true,
_ => false,
}
matches!(self.0, Kind::Invalid)
}
pub(crate) fn as_u8(&self) -> u8 {
+1 -1
View File
@@ -152,7 +152,7 @@ async fn select_streams() {
}
}
msgs.sort();
msgs.sort_unstable();
assert_eq!(&msgs[..], &[1, 2, 3]);
}
+2 -2
View File
@@ -206,7 +206,7 @@ rt_test! {
out.push(i);
}
out.sort();
out.sort_unstable();
out
});
@@ -265,7 +265,7 @@ rt_test! {
out.push(i);
}
out.sort();
out.sort_unstable();
out
}).await.unwrap()
});
+6 -8
View File
@@ -115,7 +115,7 @@ async fn multiple_entries() {
assert_pending!(map.poll_next());
v.sort();
v.sort_unstable();
assert_eq!(v[0].0, "bar");
assert_eq!(v[0].1, 4);
assert_eq!(v[1].0, "foo");
@@ -213,8 +213,7 @@ fn new_capacity_zero() {
let map = StreamMap::<&str, stream::Pending<()>>::new();
assert_eq!(0, map.capacity());
let keys = map.keys().collect::<Vec<_>>();
assert!(keys.is_empty());
assert!(map.keys().next().is_none());
}
#[test]
@@ -222,8 +221,7 @@ fn with_capacity() {
let map = StreamMap::<&str, stream::Pending<()>>::with_capacity(10);
assert!(10 <= map.capacity());
let keys = map.keys().collect::<Vec<_>>();
assert!(keys.is_empty());
assert!(map.keys().next().is_none());
}
#[test]
@@ -235,7 +233,7 @@ fn iter_keys() {
map.insert("c", pending());
let mut keys = map.keys().collect::<Vec<_>>();
keys.sort();
keys.sort_unstable();
assert_eq!(&keys[..], &[&"a", &"b", &"c"]);
}
@@ -250,7 +248,7 @@ fn iter_values() {
let mut size_hints = map.values().map(|s| s.size_hint().0).collect::<Vec<_>>();
size_hints.sort();
size_hints.sort_unstable();
assert_eq!(&size_hints[..], &[1, 2, 3]);
}
@@ -268,7 +266,7 @@ fn iter_values_mut() {
.map(|s: &mut _| s.size_hint().0)
.collect::<Vec<_>>();
size_hints.sort();
size_hints.sort_unstable();
assert_eq!(&size_hints[..], &[1, 2, 3]);
}
+1 -4
View File
@@ -492,8 +492,5 @@ fn lagging_receiver_recovers_after_wrap_open() {
}
fn is_closed(err: broadcast::RecvError) -> bool {
match err {
broadcast::RecvError::Closed => true,
_ => false,
}
matches!(err, broadcast::RecvError::Closed)
}