Skip to content

Commit 450d113

Browse files
committed
Fix Rust 1.64 clippy warnings and tests
1 parent cd6d181 commit 450d113

22 files changed

+139
-164
lines changed

deltachat-ffi/src/lib.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub unsafe extern "C" fn dc_context_unref(context: *mut dc_context_t) {
169169
eprintln!("ignoring careless call to dc_context_unref()");
170170
return;
171171
}
172-
Box::from_raw(context);
172+
drop(Box::from_raw(context));
173173
}
174174

175175
#[no_mangle]
@@ -463,7 +463,7 @@ pub unsafe extern "C" fn dc_event_unref(a: *mut dc_event_t) {
463463
return;
464464
}
465465

466-
Box::from_raw(a);
466+
drop(Box::from_raw(a));
467467
}
468468

469469
#[no_mangle]
@@ -687,7 +687,7 @@ pub unsafe extern "C" fn dc_event_emitter_unref(emitter: *mut dc_event_emitter_t
687687
return;
688688
}
689689

690-
Box::from_raw(emitter);
690+
drop(Box::from_raw(emitter));
691691
}
692692

693693
#[no_mangle]
@@ -2426,7 +2426,7 @@ pub unsafe extern "C" fn dc_array_unref(a: *mut dc_array::dc_array_t) {
24262426
return;
24272427
}
24282428

2429-
Box::from_raw(a);
2429+
drop(Box::from_raw(a));
24302430
}
24312431

24322432
#[no_mangle]
@@ -2607,7 +2607,7 @@ pub unsafe extern "C" fn dc_chatlist_unref(chatlist: *mut dc_chatlist_t) {
26072607
eprintln!("ignoring careless call to dc_chatlist_unref()");
26082608
return;
26092609
}
2610-
Box::from_raw(chatlist);
2610+
drop(Box::from_raw(chatlist));
26112611
}
26122612

26132613
#[no_mangle]
@@ -2752,7 +2752,7 @@ pub unsafe extern "C" fn dc_chat_unref(chat: *mut dc_chat_t) {
27522752
return;
27532753
}
27542754

2755-
Box::from_raw(chat);
2755+
drop(Box::from_raw(chat));
27562756
}
27572757

27582758
#[no_mangle]
@@ -3022,7 +3022,7 @@ pub unsafe extern "C" fn dc_msg_unref(msg: *mut dc_msg_t) {
30223022
return;
30233023
}
30243024

3025-
Box::from_raw(msg);
3025+
drop(Box::from_raw(msg));
30263026
}
30273027

30283028
#[no_mangle]
@@ -3744,7 +3744,7 @@ pub unsafe extern "C" fn dc_contact_unref(contact: *mut dc_contact_t) {
37443744
eprintln!("ignoring careless call to dc_contact_unref()");
37453745
return;
37463746
}
3747-
Box::from_raw(contact);
3747+
drop(Box::from_raw(contact));
37483748
}
37493749

37503750
#[no_mangle]
@@ -3908,7 +3908,7 @@ pub unsafe extern "C" fn dc_lot_unref(lot: *mut dc_lot_t) {
39083908
return;
39093909
}
39103910

3911-
Box::from_raw(lot);
3911+
drop(Box::from_raw(lot));
39123912
}
39133913

39143914
#[no_mangle]
@@ -4200,7 +4200,8 @@ pub unsafe extern "C" fn dc_accounts_get_account(
42004200
}
42014201

42024202
let accounts = &*accounts;
4203-
block_on(async move { accounts.read().await.get_account(id).await })
4203+
block_on(accounts.read())
4204+
.get_account(id)
42044205
.map(|ctx| Box::into_raw(Box::new(ctx)))
42054206
.unwrap_or_else(std::ptr::null_mut)
42064207
}
@@ -4215,7 +4216,8 @@ pub unsafe extern "C" fn dc_accounts_get_selected_account(
42154216
}
42164217

42174218
let accounts = &*accounts;
4218-
block_on(async move { accounts.read().await.get_selected_account().await })
4219+
block_on(accounts.read())
4220+
.get_selected_account()
42194221
.map(|ctx| Box::into_raw(Box::new(ctx)))
42204222
.unwrap_or_else(std::ptr::null_mut)
42214223
}
@@ -4360,7 +4362,7 @@ pub unsafe extern "C" fn dc_accounts_get_all(accounts: *mut dc_accounts_t) -> *m
43604362
}
43614363

43624364
let accounts = &*accounts;
4363-
let list = block_on(async move { accounts.read().await.get_all().await });
4365+
let list = block_on(accounts.read()).get_all();
43644366
let array: dc_array_t = list.into();
43654367

43664368
Box::into_raw(Box::new(array))
@@ -4430,7 +4432,7 @@ pub unsafe extern "C" fn dc_accounts_get_event_emitter(
44304432
}
44314433

44324434
let accounts = &*accounts;
4433-
let emitter = block_on(async move { accounts.read().await.get_event_emitter().await });
4435+
let emitter = block_on(accounts.read()).get_event_emitter();
44344436

44354437
Box::into_raw(Box::new(emitter))
44364438
}

deltachat-jsonrpc/src/api/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl CommandApi {
6565
.read()
6666
.await
6767
.get_account(id)
68-
.await
6968
.ok_or_else(|| anyhow!("account with id {} not found", id))?;
7069
Ok(sc)
7170
}
@@ -100,7 +99,7 @@ impl CommandApi {
10099
}
101100

102101
async fn get_all_account_ids(&self) -> Vec<u32> {
103-
self.accounts.read().await.get_all().await
102+
self.accounts.read().await.get_all()
104103
}
105104

106105
/// Select account id for internally selected state.
@@ -112,14 +111,14 @@ impl CommandApi {
112111
/// Get the selected account id of the internal state..
113112
/// TODO: Likely this is deprecated as all methods take an account id now.
114113
async fn get_selected_account_id(&self) -> Option<u32> {
115-
self.accounts.read().await.get_selected_account_id().await
114+
self.accounts.read().await.get_selected_account_id()
116115
}
117116

118117
/// Get a list of all configured accounts.
119118
async fn get_all_accounts(&self) -> Result<Vec<Account>> {
120119
let mut accounts = Vec::new();
121-
for id in self.accounts.read().await.get_all().await {
122-
let context_option = self.accounts.read().await.get_account(id).await;
120+
for id in self.accounts.read().await.get_all() {
121+
let context_option = self.accounts.read().await.get_account(id);
123122
if let Some(ctx) = context_option {
124123
accounts.push(Account::from_context(&ctx, id).await?)
125124
} else {
@@ -135,7 +134,7 @@ impl CommandApi {
135134

136135
/// Get top-level info for an account.
137136
async fn get_account_info(&self, account_id: u32) -> Result<Account> {
138-
let context_option = self.accounts.read().await.get_account(account_id).await;
137+
let context_option = self.accounts.read().await.get_account(account_id);
139138
if let Some(ctx) = context_option {
140139
Ok(Account::from_context(&ctx, account_id).await?)
141140
} else {

deltachat-jsonrpc/src/webserver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async fn handler(ws: WebSocketUpgrade, Extension(api): Extension<CommandApi>) ->
4444
let (client, out_receiver) = RpcClient::new();
4545
let session = RpcSession::new(client.clone(), api.clone());
4646
tokio::spawn(async move {
47-
let events = api.accounts.read().await.get_event_emitter().await;
47+
let events = api.accounts.read().await.get_event_emitter();
4848
while let Some(event) = events.recv().await {
4949
let event = event_to_json_rpc_notification(event);
5050
client.send_notification("event", Some(event)).await.ok();

0 commit comments

Comments
 (0)