Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clippy: disallow useless asyncs #3513

Merged
merged 26 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f9ed57b
crypto: remove unused async for check_own_device_signature
bnjbvr Jun 5, 2024
f809af6
crypto: remove unused async for Identity::verification_request_content
bnjbvr Jun 5, 2024
2a25495
crypto: remove unused async for add_withheld_info
bnjbvr Jun 5, 2024
0b5ca5e
crypto: remove unused async for Account::rehydrate
bnjbvr Jun 5, 2024
f2d46bf
crypto: remove unused async for ... from_pickle
bnjbvr Jun 5, 2024
d9db7f0
handle_withheld_devices
bnjbvr Jun 5, 2024
4d88595
request_verification et al.
bnjbvr Jun 5, 2024
132bf18
get_sas_pair
bnjbvr Jun 5, 2024
933ed6b
update_push_room_context
bnjbvr Jun 5, 2024
7b92729
response_with_room
bnjbvr Jun 5, 2024
cf4d832
false positives in indexeddb
bnjbvr Jun 5, 2024
15dc2d6
false positive utd_event_handler (it's an event handler)
bnjbvr Jun 5, 2024
3b92198
run_initialization_tasks
bnjbvr Jun 5, 2024
2fe5fa2
!!!rename run_initialization_tasks to spawn_initialization_task
bnjbvr Jun 5, 2024
1d7b504
set_idle_state
bnjbvr Jun 5, 2024
0518eff
append_events_locked_impl
bnjbvr Jun 5, 2024
2b2a5f2
FrozenSlidingSync::new
bnjbvr Jun 5, 2024
2c9fdc6
does clippy notice this new error only because the function isn't asy…
bnjbvr Jun 5, 2024
f3cd97c
multiverse's back_paginate
bnjbvr Jun 5, 2024
c69156f
that little test helper innocently duplicated
bnjbvr Jun 5, 2024
8803c6a
that's it, i'm killing that third copy of response_with_room
bnjbvr Jun 5, 2024
845f2fe
remove some unused async in FFI too
bnjbvr Jun 5, 2024
810438b
full_room (+ improve comment)
bnjbvr Jun 5, 2024
7ecb40d
clippy: add unused_async to the list of checks
bnjbvr Jun 5, 2024
7fc98c4
add an extra false positive when building on wazeum
bnjbvr Jun 5, 2024
515b3c9
algorithm() uses await when experimental-algorithms is enabled
bnjbvr Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ rustflags = [
"-Wclippy::nonstandard_macro_braces",
"-Wclippy::str_to_string",
"-Wclippy::todo",
"-Wclippy::unused_async",
]

[target.'cfg(target_arch = "wasm32")']
Expand Down
12 changes: 3 additions & 9 deletions bindings/matrix-sdk-crypto-ffi/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,7 @@ impl OlmMachine {
let methods = methods.into_iter().map(VerificationMethod::from).collect();

Ok(if let Some(identity) = identity.and_then(|i| i.other()) {
let content =
self.runtime.block_on(identity.verification_request_content(Some(methods)));
let content = identity.verification_request_content(Some(methods));
Some(serde_json::to_string(&content)?)
} else {
None
Expand Down Expand Up @@ -1202,11 +1201,7 @@ impl OlmMachine {
let methods = methods.into_iter().map(VerificationMethod::from).collect();

Ok(if let Some(identity) = identity.and_then(|i| i.other()) {
let request = self.runtime.block_on(identity.request_verification(
&room_id,
&event_id,
Some(methods),
));
let request = identity.request_verification(&room_id, &event_id, Some(methods));

Some(
VerificationRequest { inner: request, runtime: self.runtime.handle().to_owned() }
Expand Down Expand Up @@ -1243,8 +1238,7 @@ impl OlmMachine {
if let Some(device) =
self.runtime.block_on(self.inner.get_device(&user_id, device_id, None))?
{
let (verification, request) =
self.runtime.block_on(device.request_verification_with_methods(methods));
let (verification, request) = device.request_verification_with_methods(methods);

Some(RequestVerificationResult {
verification: VerificationRequest {
Expand Down
8 changes: 4 additions & 4 deletions bindings/matrix-sdk-ffi/src/authentication_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl AuthenticationService {

let oidc_metadata: VerifiedClientMetadata = configuration.try_into()?;

if self.load_client_registration(oidc, issuer.clone(), oidc_metadata.clone()).await {
if self.load_client_registration(oidc, issuer.clone(), oidc_metadata.clone()) {
tracing::info!("OIDC configuration loaded from disk.");
return Ok(());
}
Expand All @@ -472,14 +472,14 @@ impl AuthenticationService {
oidc.restore_registered_client(issuer, oidc_metadata, credentials);

tracing::info!("Persisting OIDC registration data.");
self.store_client_registration(oidc).await?;
self.store_client_registration(oidc)?;

Ok(())
}

/// Stores the current OIDC dynamic client registration so it can be re-used
/// if we ever log in via the same issuer again.
async fn store_client_registration(&self, oidc: &Oidc) -> Result<(), AuthenticationError> {
fn store_client_registration(&self, oidc: &Oidc) -> Result<(), AuthenticationError> {
let issuer = Url::parse(oidc.issuer().ok_or(AuthenticationError::OidcNotSupported)?)
.map_err(|_| AuthenticationError::OidcError {
message: String::from("Failed to parse issuer URL."),
Expand Down Expand Up @@ -508,7 +508,7 @@ impl AuthenticationService {

/// Attempts to load an existing OIDC dynamic client registration for the
/// currently configured issuer.
async fn load_client_registration(
fn load_client_registration(
&self,
oidc: &Oidc,
issuer: String,
Expand Down
14 changes: 6 additions & 8 deletions bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ impl Client {
let session_delegate = session_delegate.clone();
Box::new(move |client| {
let session_delegate = session_delegate.clone();
Box::pin(
async move { Ok(Self::save_session(session_delegate, client).await?) },
)
Ok(Self::save_session(session_delegate, client)?)
})
},
)?;
Expand Down Expand Up @@ -415,8 +413,8 @@ impl Client {
})
}

pub async fn session(&self) -> Result<Session, ClientError> {
Self::session_inner((*self.inner).clone()).await
pub fn session(&self) -> Result<Session, ClientError> {
Self::session_inner((*self.inner).clone())
}

pub async fn account_url(
Expand Down Expand Up @@ -968,7 +966,7 @@ impl Client {
}
}

async fn session_inner(client: matrix_sdk::Client) -> Result<Session, ClientError> {
fn session_inner(client: matrix_sdk::Client) -> Result<Session, ClientError> {
let auth_api = client.auth_api().context("Missing authentication API")?;

let homeserver_url = client.homeserver().into();
Expand All @@ -977,11 +975,11 @@ impl Client {
Session::new(auth_api, homeserver_url, sliding_sync_proxy)
}

async fn save_session(
fn save_session(
session_delegate: Arc<dyn ClientSessionDelegate>,
client: matrix_sdk::Client,
) -> anyhow::Result<()> {
let session = Self::session_inner(client).await?;
let session = Self::session_inner(client)?;
session_delegate.save_session_in_keychain(session);
Ok(())
}
Expand Down
7 changes: 4 additions & 3 deletions bindings/matrix-sdk-ffi/src/room_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,10 @@ impl RoomListItem {
Ok(RoomInfo::new(self.inner.inner_room(), latest_event).await?)
}

/// Building a `Room`. If its internal timeline hasn't been initialized
/// it'll fail.
async fn full_room(&self) -> Result<Arc<Room>, RoomListError> {
/// Build a full `Room` FFI object, filling its associated timeline.
///
/// If its internal timeline hasn't been initialized, it'll fail.
fn full_room(&self) -> Result<Arc<Room>, RoomListError> {
if let Some(timeline) = self.inner.timeline() {
Ok(Arc::new(Room::with_timeline(
self.inner.inner_room().clone(),
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk-base/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ impl BaseClient {
room_info,
changes,
)
.await;
} else {
push_context = self.get_push_room_context(room, room_info, changes).await?;
}
Expand Down Expand Up @@ -1409,7 +1408,7 @@ impl BaseClient {
/// Update the push context for the given room.
///
/// Updates the context data from `changes` or `room_info`.
pub async fn update_push_room_context(
pub fn update_push_room_context(
&self,
push_rules: &mut PushConditionRoomCtx,
user_id: &UserId,
Expand Down
Loading
Loading