From 8d83a996a69ffcfca786dbc343dc9b862a9965df Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 11 Mar 2023 12:45:09 +0100 Subject: [PATCH] Handle another new clippy lint Issue about false positives: https://github.com/rust-lang/rust-clippy/issues/10482 --- bindings/matrix-sdk-ffi/src/authentication_service.rs | 2 +- bindings/matrix-sdk-ffi/src/client.rs | 3 ++- bindings/matrix-sdk-ffi/src/room.rs | 3 ++- bindings/matrix-sdk-ffi/src/sliding_sync.rs | 4 ++-- crates/matrix-sdk-crypto/src/identities/manager.rs | 1 + crates/matrix-sdk/tests/integration/room/joined.rs | 1 + crates/matrix-sdk/tests/integration/room/timeline.rs | 1 + 7 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/authentication_service.rs b/bindings/matrix-sdk-ffi/src/authentication_service.rs index bce8f761e..b6313cdc6 100644 --- a/bindings/matrix-sdk-ffi/src/authentication_service.rs +++ b/bindings/matrix-sdk-ffi/src/authentication_service.rs @@ -147,7 +147,7 @@ impl AuthenticationService { }) .map_err(AuthenticationError::from)?; - let details = RUNTIME.block_on(async { self.details_from_client(&client).await })?; + let details = RUNTIME.block_on(self.details_from_client(&client))?; // Now we've verified that it's a valid homeserver, make sure // there's a sliding sync proxy available one way or another. diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 7176bd88a..77499e413 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -377,7 +377,8 @@ impl Client { impl Client { /// The homeserver this client is configured to use. pub fn homeserver(&self) -> String { - RUNTIME.block_on(async move { self.async_homeserver().await }) + #[allow(unknown_lints, clippy::redundant_async_block)] // false positive + RUNTIME.block_on(self.async_homeserver()) } pub fn rooms(&self) -> Vec> { diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index dc397b240..7f8ec161b 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -250,7 +250,8 @@ impl Room { .unwrap() .get_or_insert_with(|| { let room = self.room.clone(); - let timeline = RUNTIME.block_on(async move { room.timeline().await }); + #[allow(unknown_lints, clippy::redundant_async_block)] // false positive + let timeline = RUNTIME.block_on(room.timeline()); Arc::new(timeline) }) .clone(); diff --git a/bindings/matrix-sdk-ffi/src/sliding_sync.rs b/bindings/matrix-sdk-ffi/src/sliding_sync.rs index fe372da92..4a70a2695 100644 --- a/bindings/matrix-sdk-ffi/src/sliding_sync.rs +++ b/bindings/matrix-sdk-ffi/src/sliding_sync.rs @@ -194,8 +194,8 @@ impl SlidingSyncRoom { } }; - let (timeline_items, timeline_stream) = - RUNTIME.block_on(async { timeline.subscribe().await }); + #[allow(unknown_lints, clippy::redundant_async_block)] // false positive + let (timeline_items, timeline_stream) = RUNTIME.block_on(timeline.subscribe()); let handle_events = async move { let listener: Arc = listener.into(); diff --git a/crates/matrix-sdk-crypto/src/identities/manager.rs b/crates/matrix-sdk-crypto/src/identities/manager.rs index 1943e4d23..41bedaca7 100644 --- a/crates/matrix-sdk-crypto/src/identities/manager.rs +++ b/crates/matrix-sdk-crypto/src/identities/manager.rs @@ -1066,6 +1066,7 @@ pub(crate) mod tests { let listener = manager.listen_for_received_queries(); + #[allow(unknown_lints, clippy::redundant_async_block)] // false positive let task = tokio::task::spawn(async move { listener.wait(Duration::from_secs(10)).await }); manager diff --git a/crates/matrix-sdk/tests/integration/room/joined.rs b/crates/matrix-sdk/tests/integration/room/joined.rs index 9affccf8e..5df69e9c6 100644 --- a/crates/matrix-sdk/tests/integration/room/joined.rs +++ b/crates/matrix-sdk/tests/integration/room/joined.rs @@ -543,6 +543,7 @@ async fn fetch_members_deduplication() { // Create N tasks that try to fetch the members. for _ in 0..5 { + #[allow(unknown_lints, clippy::redundant_async_block)] // false positive let task = tokio::spawn({ let room = room.clone(); async move { room.sync_members().await } diff --git a/crates/matrix-sdk/tests/integration/room/timeline.rs b/crates/matrix-sdk/tests/integration/room/timeline.rs index b06fa4eb1..e56533050 100644 --- a/crates/matrix-sdk/tests/integration/room/timeline.rs +++ b/crates/matrix-sdk/tests/integration/room/timeline.rs @@ -180,6 +180,7 @@ async fn echo() { // Don't move the original timeline, it must live until the end of the test let timeline = timeline.clone(); + #[allow(unknown_lints, clippy::redundant_async_block)] // false positive let send_hdl = spawn(async move { timeline .send(RoomMessageEventContent::text_plain("Hello, World!").into(), Some(txn_id))