From b704c53b9cc76eaf8c9c6585f8444c4515d27728 Mon Sep 17 00:00:00 2001 From: bdonlan Date: Thu, 8 Oct 2020 17:14:39 -0700 Subject: chore: Fix clippy lints (#2931) Closes: #2929 Co-authored-by: Bryan Donlan --- tokio/tests/macros_select.rs | 2 +- tokio/tests/rt_common.rs | 4 ++-- tokio/tests/stream_stream_map.rs | 14 ++++++-------- tokio/tests/sync_broadcast.rs | 5 +---- 4 files changed, 10 insertions(+), 15 deletions(-) (limited to 'tokio/tests') diff --git a/tokio/tests/macros_select.rs b/tokio/tests/macros_select.rs index f971409b..f77f3f01 100644 --- a/tokio/tests/macros_select.rs +++ b/tokio/tests/macros_select.rs @@ -152,7 +152,7 @@ async fn select_streams() { } } - msgs.sort(); + msgs.sort_unstable(); assert_eq!(&msgs[..], &[1, 2, 3]); } diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs index 93d6a44e..56ab840d 100644 --- a/tokio/tests/rt_common.rs +++ b/tokio/tests/rt_common.rs @@ -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() }); diff --git a/tokio/tests/stream_stream_map.rs b/tokio/tests/stream_stream_map.rs index 6b498032..38bb0c5d 100644 --- a/tokio/tests/stream_stream_map.rs +++ b/tokio/tests/stream_stream_map.rs @@ -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::>(); - 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::>(); - 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::>(); - 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::>(); - 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::>(); - size_hints.sort(); + size_hints.sort_unstable(); assert_eq!(&size_hints[..], &[1, 2, 3]); } diff --git a/tokio/tests/sync_broadcast.rs b/tokio/tests/sync_broadcast.rs index d7e77e9d..7960eb85 100644 --- a/tokio/tests/sync_broadcast.rs +++ b/tokio/tests/sync_broadcast.rs @@ -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) } -- cgit v1.2.3