Skip to content

Commit

Permalink
ci: update to Rust 1.75.0 and fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Jan 8, 2024
1 parent b9a58bf commit 2f8a8f9
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
name: Lint Rust
runs-on: ubuntu-latest
env:
RUSTUP_TOOLCHAIN: 1.74.1
RUSTUP_TOOLCHAIN: 1.75.0
steps:
- uses: actions/checkout@v3
- name: Install rustfmt and clippy
Expand Down Expand Up @@ -76,11 +76,11 @@ jobs:
matrix:
include:
- os: ubuntu-latest
rust: 1.74.1
rust: 1.75.0
- os: windows-latest
rust: 1.74.1
rust: 1.75.0
- os: macos-latest
rust: 1.74.1
rust: 1.75.0

# Minimum Supported Rust Version = 1.70.0
- os: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion deltachat-jsonrpc/src/api/types/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl FullChat {
let can_send = chat.can_send(context).await?;

let was_seen_recently = if chat.get_type() == Chattype::Single {
match contact_ids.get(0) {
match contact_ids.first() {
Some(contact) => Contact::get_by_id(context, *contact)
.await
.context("failed to load contact for was_seen_recently")?
Expand Down
2 changes: 1 addition & 1 deletion deltachat-jsonrpc/src/api/types/chat_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub(crate) async fn get_chat_list_item_by_id(
let self_in_group = chat_contacts.contains(&ContactId::SELF);

let (dm_chat_contact, was_seen_recently) = if chat.get_type() == Chattype::Single {
let contact = chat_contacts.get(0);
let contact = chat_contacts.first();
let was_seen_recently = match contact {
Some(contact) => Contact::get_by_id(ctx, *contact)
.await
Expand Down
8 changes: 6 additions & 2 deletions src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,12 @@ impl Config {
}
if self.inner.selected_account == id {
// reset selected account
self.inner.selected_account =
self.inner.accounts.get(0).map(|e| e.id).unwrap_or_default();
self.inner.selected_account = self
.inner
.accounts
.first()
.map(|e| e.id)
.unwrap_or_default();
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1885,12 +1885,12 @@ mod tests {
// Search by name.
let contacts = Contact::get_all(&context.ctx, 0, Some("bob")).await?;
assert_eq!(contacts.len(), 1);
assert_eq!(contacts.get(0), Some(&id));
assert_eq!(contacts.first(), Some(&id));

// Search by address.
let contacts = Contact::get_all(&context.ctx, 0, Some("user")).await?;
assert_eq!(contacts.len(), 1);
assert_eq!(contacts.get(0), Some(&id));
assert_eq!(contacts.first(), Some(&id));

let contacts = Contact::get_all(&context.ctx, 0, Some("alice")).await?;
assert_eq!(contacts.len(), 0);
Expand All @@ -1917,7 +1917,7 @@ mod tests {
// Search by display name (same as manually set name).
let contacts = Contact::get_all(&context.ctx, 0, Some("someone")).await?;
assert_eq!(contacts.len(), 1);
assert_eq!(contacts.get(0), Some(&id));
assert_eq!(contacts.first(), Some(&id));

Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ mod tests {
assert_eq!(res.len(), 2);

// Message added later is returned first.
assert_eq!(res.get(0), Some(&msg2.id));
assert_eq!(res.first(), Some(&msg2.id));
assert_eq!(res.get(1), Some(&msg1.id));

// Global search with longer text does not find any message.
Expand Down Expand Up @@ -1587,7 +1587,7 @@ mod tests {

let bob_next_msg_ids = bob.get_next_msgs().await?;
assert_eq!(bob_next_msg_ids.len(), 1);
assert_eq!(bob_next_msg_ids.get(0), Some(&received_msg.id));
assert_eq!(bob_next_msg_ids.first(), Some(&received_msg.id));

bob.set_config_u32(Config::LastMsgId, received_msg.id.to_u32())
.await?;
Expand All @@ -1596,7 +1596,7 @@ mod tests {
// Next messages include self-sent messages.
let alice_next_msg_ids = alice.get_next_msgs().await?;
assert_eq!(alice_next_msg_ids.len(), 1);
assert_eq!(alice_next_msg_ids.get(0), Some(&sent_msg.sender_msg_id));
assert_eq!(alice_next_msg_ids.first(), Some(&sent_msg.sender_msg_id));

alice
.set_config_u32(Config::LastMsgId, sent_msg.sender_msg_id.to_u32())
Expand Down
2 changes: 1 addition & 1 deletion src/imex/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ mod tests {
let self_chat = ctx1.get_self_chat().await;
let msgs = get_chat_msgs(&ctx1, self_chat.id).await.unwrap();
assert_eq!(msgs.len(), 2);
let msgid = match msgs.get(0).unwrap() {
let msgid = match msgs.first().unwrap() {
ChatItem::Message { msg_id } => msg_id,
_ => panic!("wrong chat item"),
};
Expand Down
2 changes: 1 addition & 1 deletion src/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ Content-Disposition: attachment; filename="location.kml"
assert!(msg.chat_id == bob_chat_id);
assert_eq!(msg.msg_ids.len(), 1);

let bob_msg = Message::load_from_db(&bob, *msg.msg_ids.get(0).unwrap()).await?;
let bob_msg = Message::load_from_db(&bob, *msg.msg_ids.first().unwrap()).await?;
assert_eq!(bob_msg.chat_id, bob_chat_id);
assert_eq!(bob_msg.viewtype, Viewtype::Image);

Expand Down
4 changes: 2 additions & 2 deletions src/mimeparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ impl MimeMessage {
skip the rest. (see
<https://k9mail.app/2016/11/24/OpenPGP-Considerations-Part-I.html>
for background information why we use encrypted+signed) */
if let Some(first) = mail.subparts.get(0) {
if let Some(first) = mail.subparts.first() {
any_part_added = self
.parse_mime_recursive(context, first, is_related)
.await?;
Expand Down Expand Up @@ -970,7 +970,7 @@ impl MimeMessage {
}
}
Some(_) => {
if let Some(first) = mail.subparts.get(0) {
if let Some(first) = mail.subparts.first() {
any_part_added = self
.parse_mime_recursive(context, first, is_related)
.await?;
Expand Down
8 changes: 4 additions & 4 deletions src/reaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ Content-Disposition: reaction\n\
let contacts = reactions.contacts();
assert_eq!(contacts.len(), 1);

assert_eq!(contacts.get(0), Some(&bob_id));
assert_eq!(contacts.first(), Some(&bob_id));
let bob_reaction = reactions.get(bob_id);
assert_eq!(bob_reaction.is_empty(), false);
assert_eq!(bob_reaction.emojis(), vec!["👍"]);
Expand Down Expand Up @@ -526,7 +526,7 @@ Here's my footer -- [email protected]"
assert_eq!(reactions.to_string(), "👍1");
let contacts = reactions.contacts();
assert_eq!(contacts.len(), 1);
let bob_id = contacts.get(0).unwrap();
let bob_id = contacts.first().unwrap();
let bob_reaction = reactions.get(*bob_id);
assert_eq!(bob_reaction.is_empty(), false);
assert_eq!(bob_reaction.emojis(), vec!["👍"]);
Expand Down Expand Up @@ -578,13 +578,13 @@ Here's my footer -- [email protected]"
)
.await?
.unwrap();
let alice_msg_id = *alice_received_message.msg_ids.get(0).unwrap();
let alice_msg_id = *alice_received_message.msg_ids.first().unwrap();

// Bob downloads own message on the other device.
let bob_received_message = receive_imf(&bob, msg_full.as_bytes(), false)
.await?
.unwrap();
let bob_msg_id = *bob_received_message.msg_ids.get(0).unwrap();
let bob_msg_id = *bob_received_message.msg_ids.first().unwrap();

// Bob reacts to own message.
send_reaction(&bob, bob_msg_id, "👍").await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub(crate) async fn receive_imf_inner(
mime_parser.decryption_info.peerstate =
Peerstate::from_addr(context, contact.get_addr()).await?;
} else {
let to_id = to_ids.get(0).copied().unwrap_or_default();
let to_id = to_ids.first().copied().unwrap_or_default();
// handshake may mark contacts as verified and must be processed before chats are created
res = observe_securejoin_on_other_device(context, &mime_parser, to_id)
.await
Expand Down Expand Up @@ -919,7 +919,7 @@ async fn add_parts(
// the mail is on the IMAP server, probably it is also delivered.
// We cannot recreate other states (read, error).
state = MessageState::OutDelivered;
to_id = to_ids.get(0).copied().unwrap_or_default();
to_id = to_ids.first().copied().unwrap_or_default();

let self_sent =
from_id == ContactId::SELF && to_ids.len() == 1 && to_ids.contains(&ContactId::SELF);
Expand Down
4 changes: 2 additions & 2 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ mod tests {
)?;
assert_eq!(sync_items.items.len(), 1);
let SyncDataOrUnknown::SyncData(AlterChat { id, action }) =
&sync_items.items.get(0).unwrap().data
&sync_items.items.first().unwrap().data
else {
bail!("bad item");
};
Expand Down Expand Up @@ -491,7 +491,7 @@ mod tests {

assert_eq!(sync_items.items.len(), 1);
if let SyncDataOrUnknown::SyncData(AddQrToken(token)) =
&sync_items.items.get(0).unwrap().data
&sync_items.items.first().unwrap().data
{
assert_eq!(token.invitenumber, "in");
assert_eq!(token.auth, "yip");
Expand Down
2 changes: 1 addition & 1 deletion src/webxdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ mod tests {
)
.await?
.unwrap();
assert_eq!(*received_msg.msg_ids.get(0).unwrap(), bob_instance.id);
assert_eq!(*received_msg.msg_ids.first().unwrap(), bob_instance.id);
let bob_instance = bob.get_last_msg().await;
assert_eq!(bob_instance.viewtype, Viewtype::Webxdc);
assert_eq!(bob_instance.download_state, DownloadState::Done);
Expand Down

0 comments on commit 2f8a8f9

Please sign in to comment.