diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 8854cc92e..4527b8db1 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -554,7 +554,11 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu sql::housekeeping(&context).await.ok_or_log(&context); } "listchats" | "listarchived" | "chats" => { - let listflags = if arg0 == "listarchived" { 0x01 } else { 0 }; + let listflags = if arg0 == "listarchived" { + DC_GCL_ARCHIVED_ONLY + } else { + 0 + }; let time_start = std::time::SystemTime::now(); let chatlist = Chatlist::try_load( &context, diff --git a/examples/repl/main.rs b/examples/repl/main.rs index f9403d064..d0b45f975 100644 --- a/examples/repl/main.rs +++ b/examples/repl/main.rs @@ -446,7 +446,7 @@ async fn handle_cmd( } println!("{}", qr); let output = Command::new("qrencode") - .args(&["-t", "ansiutf8", qr.as_str(), "-o", "-"]) + .args(["-t", "ansiutf8", qr.as_str(), "-o", "-"]) .output() .expect("failed to execute process"); io::stdout().write_all(&output.stdout).unwrap(); diff --git a/src/chat.rs b/src/chat.rs index b281d757d..7bda1598b 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2439,7 +2439,7 @@ pub async fn get_chat_media( AND hidden=0 ORDER BY timestamp, id;", paramsv![ - if chat_id.is_none() { 1i32 } else { 0i32 }, + chat_id.is_none(), chat_id.unwrap_or_else(|| ChatId::new(0)), msg_type, if msg_type2 != Viewtype::Unknown { diff --git a/src/html.rs b/src/html.rs index 53044becf..b112fcd2f 100644 --- a/src/html.rs +++ b/src/html.rs @@ -94,7 +94,7 @@ impl HtmlMsgParser { let parsedmail = mailparse::parse_mail(rawmime)?; - parser.collect_texts_recursive(context, &parsedmail).await?; + parser.collect_texts_recursive(&parsedmail).await?; if parser.html.is_empty() { if let Some(plain) = &parser.plain { @@ -117,7 +117,6 @@ impl HtmlMsgParser { /// therefore we use the first one. fn collect_texts_recursive<'a>( &'a mut self, - context: &'a Context, mail: &'a mailparse::ParsedMail<'a>, ) -> Pin> + 'a + Send>> { // Boxed future to deal with recursion @@ -125,7 +124,7 @@ impl HtmlMsgParser { match get_mime_multipart_type(&mail.ctype) { MimeMultipartType::Multiple => { for cur_data in mail.subparts.iter() { - self.collect_texts_recursive(context, cur_data).await? + self.collect_texts_recursive(cur_data).await? } Ok(()) } @@ -135,7 +134,7 @@ impl HtmlMsgParser { return Ok(()); } let mail = mailparse::parse_mail(&raw).context("failed to parse mail")?; - self.collect_texts_recursive(context, &mail).await + self.collect_texts_recursive(&mail).await } MimeMultipartType::Single => { let mimetype = mail.ctype.mimetype.parse::()?; @@ -207,7 +206,7 @@ impl HtmlMsgParser { Ok(re) => { self.html = re .replace_all( - &*self.html, + &self.html, format!("${{1}}{}${{3}}", replacement).as_str(), ) .as_ref() diff --git a/src/lib.rs b/src/lib.rs index 8912edacd..af53d0839 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,11 @@ clippy::mixed_read_write_in_expression, clippy::bool_assert_comparison, clippy::manual_split_once, - clippy::format_push_string + clippy::format_push_string, + clippy::bool_to_int_with_if, + // This lint can be re-enabled once we don't target + // Rust 1.56 anymore: + clippy::collapsible_str_replace )] #[macro_use] diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 90c22044c..b6f0fef04 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1311,7 +1311,7 @@ impl<'a> MimeFactory<'a> { /// This line length limit is an /// [RFC5322 requirement](https://tools.ietf.org/html/rfc5322#section-2.1.1). fn wrapped_base64_encode(buf: &[u8]) -> String { - let base64 = base64::encode(&buf); + let base64 = base64::encode(buf); let mut chars = base64.chars(); std::iter::repeat_with(|| chars.by_ref().take(78).collect::()) .take_while(|s| !s.is_empty()) diff --git a/src/plaintext.rs b/src/plaintext.rs index 738413e1d..fd3ba1675 100644 --- a/src/plaintext.rs +++ b/src/plaintext.rs @@ -44,12 +44,12 @@ impl PlainText { let line = line.to_string().replace('\r', ""); let mut line = LINKIFY_MAIL_RE - .replace_all(&*line, "\rLTa href=\rQUOTmailto:$1\rQUOT\rGT$1\rLT/a\rGT") + .replace_all(&line, "\rLTa href=\rQUOTmailto:$1\rQUOT\rGT$1\rLT/a\rGT") .as_ref() .to_string(); line = LINKIFY_URL_RE - .replace_all(&*line, "\rLTa href=\rQUOT$1\rQUOT\rGT$1\rLT/a\rGT") + .replace_all(&line, "\rLTa href=\rQUOT$1\rQUOT\rGT$1\rLT/a\rGT") .as_ref() .to_string(); diff --git a/src/qr.rs b/src/qr.rs index 80724953c..800eb4872 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -230,7 +230,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result { .await .with_context(|| format!("can't check if address {:?} is our address", addr))? { - if token::exists(context, token::Namespace::InviteNumber, &*invitenumber).await { + if token::exists(context, token::Namespace::InviteNumber, &invitenumber).await { Ok(Qr::WithdrawVerifyGroup { grpname, grpid, @@ -260,7 +260,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result { }) } } else if context.is_self_addr(addr).await? { - if token::exists(context, token::Namespace::InviteNumber, &*invitenumber).await { + if token::exists(context, token::Namespace::InviteNumber, &invitenumber).await { Ok(Qr::WithdrawVerifyContact { contact_id, fingerprint, diff --git a/src/reaction.rs b/src/reaction.rs index f463e3f00..72a096030 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -57,7 +57,7 @@ impl From<&str> for Reaction { .split_ascii_whitespace() .filter(|&emoji| emoji.len() < 30) .collect(); - emojis.sort(); + emojis.sort_unstable(); emojis.dedup(); let reaction = emojis.join(" "); Self { reaction } @@ -84,7 +84,7 @@ impl Reaction { pub fn add(&self, other: Self) -> Self { let mut emojis: Vec<&str> = self.emojis(); emojis.append(&mut other.emojis()); - emojis.sort(); + emojis.sort_unstable(); emojis.dedup(); let reaction = emojis.join(" "); Self { reaction } diff --git a/src/receive_imf.rs b/src/receive_imf.rs index d01fd7146..3d078b91a 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1904,7 +1904,7 @@ async fn apply_mailinglist_changes( Contact::add_or_lookup(context, "", list_post, Origin::Hidden).await?; let mut contact = Contact::load_from_db(context, contact_id).await?; if contact.param.get(Param::ListId) != Some(listid) { - contact.param.set(Param::ListId, &listid); + contact.param.set(Param::ListId, listid); contact.update_param(context).await?; } diff --git a/src/scheduler/connectivity.rs b/src/scheduler/connectivity.rs index 880c2760a..ac2300ad1 100644 --- a/src/scheduler/connectivity.rs +++ b/src/scheduler/connectivity.rs @@ -405,7 +405,7 @@ impl Context { ret += " "; ret += &*escaper::encode_minimal(&foldername); ret += ": "; - ret += &*escaper::encode_minimal(&*detailed.to_string_imap(self).await); + ret += &*escaper::encode_minimal(&detailed.to_string_imap(self).await); ret += ""; folder_added = true; diff --git a/src/tools.rs b/src/tools.rs index d52b6d854..e3a29bc59 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -272,7 +272,7 @@ pub(crate) fn create_id() -> String { rng.fill(&mut arr[..]); // Take 11 base64 characters containing 66 random bits. - base64::encode_config(&arr, base64::URL_SAFE) + base64::encode_config(arr, base64::URL_SAFE) .chars() .take(11) .collect() diff --git a/src/webxdc.rs b/src/webxdc.rs index 9baf25f76..4806dcb1e 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -496,7 +496,7 @@ impl Context { for update_item in updates.updates { self.create_status_update_record( &mut instance, - &*serde_json::to_string(&update_item)?, + &serde_json::to_string(&update_item)?, timestamp, can_info_msg, from_id, @@ -545,7 +545,7 @@ impl Context { let (update_item_str, serial) = row; let update_item = StatusUpdateItemAndSerial { - item: serde_json::from_str(&*update_item_str)?, + item: serde_json::from_str(&update_item_str)?, serial, max_serial, }; @@ -553,7 +553,7 @@ impl Context { if !json.is_empty() { json.push_str(",\n"); } - json.push_str(&*serde_json::to_string(&update_item)?); + json.push_str(&serde_json::to_string(&update_item)?); } Ok(json) }, @@ -1825,7 +1825,7 @@ sth_for_the = "future""# let instance = t.get_last_msg().await; let html = instance.get_webxdc_blob(&t, "index.html").await?; - assert!(String::from_utf8_lossy(&*html).contains("requires a newer Delta Chat version")); + assert!(String::from_utf8_lossy(&html).contains("requires a newer Delta Chat version")); Ok(()) }