diff --git a/CHANGELOG.md b/CHANGELOG.md index 806419520..fad7f1347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ ### Changes - Don't use deprecated `chrono` functions #3798 - Document accounts manager #3837 - - If a classical-email-user sends an email to a group and adds new recipients, add the new recipients as group members #3781 - Remove `pytest-async` plugin #3846 @@ -16,6 +15,7 @@ - Set read/write timeouts for IMAP over SOCKS5 #3833 - Treat attached PGP keys as peer keys with mutual encryption preference #3832 - fix migration of old databases #3842 +- Fix cargo clippy and doc errors after Rust update to 1.66 #3850 ## 1.103.0 diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index f07e4d53b..a3b772c28 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2182,7 +2182,7 @@ pub unsafe extern "C" fn dc_imex( eprintln!("ignoring careless call to dc_imex()"); return; } - let what = match imex::ImexMode::from_i32(what_raw as i32) { + let what = match imex::ImexMode::from_i32(what_raw) { Some(what) => what, None => { eprintln!("ignoring invalid argument {} to dc_imex", what_raw); @@ -2253,10 +2253,7 @@ pub unsafe extern "C" fn dc_continue_key_transfer( msg_id: u32, setup_code: *const libc::c_char, ) -> libc::c_int { - if context.is_null() - || msg_id <= constants::DC_MSG_ID_LAST_SPECIAL as u32 - || setup_code.is_null() - { + if context.is_null() || msg_id <= constants::DC_MSG_ID_LAST_SPECIAL || setup_code.is_null() { eprintln!("ignoring careless call to dc_continue_key_transfer()"); return 0; } @@ -2447,15 +2444,9 @@ pub unsafe extern "C" fn dc_get_locations( }; block_on(async move { - let res = location::get_range( - ctx, - chat_id, - contact_id, - timestamp_begin as i64, - timestamp_end as i64, - ) - .await - .unwrap_or_log_default(ctx, "Failed get_locations"); + let res = location::get_range(ctx, chat_id, contact_id, timestamp_begin, timestamp_end) + .await + .unwrap_or_log_default(ctx, "Failed get_locations"); Box::into_raw(Box::new(dc_array_t::from(res))) }) } @@ -2702,7 +2693,7 @@ pub unsafe extern "C" fn dc_chatlist_get_chat_id( } let ffi_list = &*chatlist; let ctx = &*ffi_list.context; - match ffi_list.list.get_chat_id(index as usize) { + match ffi_list.list.get_chat_id(index) { Ok(chat_id) => chat_id.to_u32(), Err(err) => { warn!(ctx, "get_chat_id failed: {}", err); @@ -2722,7 +2713,7 @@ pub unsafe extern "C" fn dc_chatlist_get_msg_id( } let ffi_list = &*chatlist; let ctx = &*ffi_list.context; - match ffi_list.list.get_msg_id(index as usize) { + match ffi_list.list.get_msg_id(index) { Ok(msg_id) => msg_id.map_or(0, |msg_id| msg_id.to_u32()), Err(err) => { warn!(ctx, "get_msg_id failed: {}", err); @@ -2753,7 +2744,7 @@ pub unsafe extern "C" fn dc_chatlist_get_summary( block_on(async move { let summary = ffi_list .list - .get_summary(ctx, index as usize, maybe_chat) + .get_summary(ctx, index, maybe_chat) .await .log_err(ctx, "get_summary failed") .unwrap_or_default(); diff --git a/src/blob.rs b/src/blob.rs index 6cbfdfa31..7b6109f2e 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -746,7 +746,7 @@ mod tests { assert!(file_size(&avatar_blob).await <= 3000); assert!(file_size(&avatar_blob).await > 2000); tokio::task::block_in_place(move || { - let img = image::open(&avatar_blob).unwrap(); + let img = image::open(avatar_blob).unwrap(); assert!(img.width() > 130); assert_eq!(img.width(), img.height()); }); diff --git a/src/chat.rs b/src/chat.rs index 1d41bb5ac..58928cf39 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -768,7 +768,7 @@ impl ChatId { paramsv![self], ) .await?; - Ok(count as usize) + Ok(count) } pub async fn get_fresh_msg_cnt(self, context: &Context) -> Result { @@ -793,7 +793,7 @@ impl ChatId { paramsv![MessageState::InFresh, self], ) .await?; - Ok(count as usize) + Ok(count) } pub(crate) async fn get_param(self, context: &Context) -> Result { @@ -1474,7 +1474,7 @@ impl Chat { new_rfc724_mid, self.id, ContactId::SELF, - to_id as i32, + to_id, timestamp, msg.viewtype, msg.state, @@ -1522,7 +1522,7 @@ impl Chat { new_rfc724_mid, self.id, ContactId::SELF, - to_id as i32, + to_id, timestamp, msg.viewtype, msg.state, @@ -3261,7 +3261,7 @@ pub(crate) async fn get_chat_cnt(context: &Context) -> Result { paramsv![], ) .await?; - Ok(count as usize) + Ok(count) } else { Ok(0) } diff --git a/src/config.rs b/src/config.rs index aea06b2a7..40cddcc8d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -204,7 +204,7 @@ impl Context { let value = match key { Config::Selfavatar => { let rel_path = self.sql.get_raw_config(key.as_ref()).await?; - rel_path.map(|p| get_abs_path(self, &p).to_string_lossy().into_owned()) + rel_path.map(|p| get_abs_path(self, p).to_string_lossy().into_owned()) } Config::SysVersion => Some((*DC_VERSION_STR).clone()), Config::SysMsgsizeMaxRecommended => Some(format!("{}", RECOMMENDED_FILE_SIZE)), diff --git a/src/contact.rs b/src/contact.rs index 79f131283..17b74987d 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -855,7 +855,7 @@ impl Contact { paramsv![ContactId::LAST_SPECIAL], ) .await?; - Ok(count as usize) + Ok(count) } /// Get blocked contacts. diff --git a/src/context.rs b/src/context.rs index a78ea833c..7e38a2106 100644 --- a/src/context.rs +++ b/src/context.rs @@ -528,10 +528,10 @@ impl Context { let l2 = LoginParam::load_configured_params(self).await?; let secondary_addrs = self.get_secondary_self_addrs().await?.join(", "); let displayname = self.get_config(Config::Displayname).await?; - let chats = get_chat_cnt(self).await? as usize; - let unblocked_msgs = message::get_unblocked_msg_cnt(self).await as usize; - let request_msgs = message::get_request_msg_cnt(self).await as usize; - let contacts = Contact::get_real_cnt(self).await? as usize; + let chats = get_chat_cnt(self).await?; + let unblocked_msgs = message::get_unblocked_msg_cnt(self).await; + let request_msgs = message::get_request_msg_cnt(self).await; + let contacts = Contact::get_real_cnt(self).await?; let is_configured = self.get_config_int(Config::Configured).await?; let socks5_enabled = self.get_config_int(Config::Socks5Enabled).await?; let dbversion = self diff --git a/src/dehtml.rs b/src/dehtml.rs index 3d39080c6..20075dbab 100644 --- a/src/dehtml.rs +++ b/src/dehtml.rs @@ -20,7 +20,7 @@ struct Dehtml { /// increased at each `
` and decreased at each `
`. This way we know when the quote ends. /// If this is > `0`, then we are inside a `
` divs_since_quote_div: u32, - /// Everything between
and
is usually metadata + /// Everything between `
` and `
` is usually metadata /// If this is > `0`, then we are inside a `
`. divs_since_quoted_content_div: u32, /// All-Inkl just puts the quote into `
`. This count is @@ -42,7 +42,7 @@ impl Dehtml { } fn get_add_text(&self) -> AddText { if self.divs_since_quote_div > 0 && self.divs_since_quoted_content_div == 0 { - AddText::No // Everything between
and
is metadata which we don't want + AddText::No // Everything between `
` and `
` is metadata which we don't want } else { self.add_text } diff --git a/src/html.rs b/src/html.rs index b112fcd2f..ac59793fc 100644 --- a/src/html.rs +++ b/src/html.rs @@ -234,7 +234,7 @@ impl HtmlMsgParser { /// Convert a mime part to a data: url as defined in [RFC 2397](https://tools.ietf.org/html/rfc2397). fn mimepart_to_data_url(mail: &mailparse::ParsedMail<'_>) -> Result { let data = mail.get_body_raw()?; - let data = base64::encode(&data); + let data = base64::encode(data); Ok(format!("data:{};base64,{}", mail.ctype.mimetype, data)) } diff --git a/src/job.rs b/src/job.rs index 0438e4494..e3b513fed 100644 --- a/src/job.rs +++ b/src/job.rs @@ -241,7 +241,7 @@ pub(crate) async fn perform_job(context: &Context, mut connection: Connection<'_ info!( context, "job #{} not succeeded on try #{}, retry in {} seconds.", - job.job_id as u32, + job.job_id, tries, time_offset ); diff --git a/src/key.rs b/src/key.rs index fc1ae4847..a67cdab43 100644 --- a/src/key.rs +++ b/src/key.rs @@ -74,7 +74,7 @@ pub trait DcKey: Serialize + Deserializable + KeyTrait + Clone { /// Serialise the key to a base64 string. fn to_base64(&self) -> String { - base64::encode(&DcKey::to_bytes(self)) + base64::encode(DcKey::to_bytes(self)) } /// Serialise the key to ASCII-armored representation. diff --git a/src/message.rs b/src/message.rs index 5c8f64435..2baef9d3f 100644 --- a/src/message.rs +++ b/src/message.rs @@ -579,8 +579,8 @@ impl Message { pub fn has_deviating_timestamp(&self) -> bool { let cnv_to_local = gm2local_offset(); - let sort_timestamp = self.get_sort_timestamp() as i64 + cnv_to_local; - let send_timestamp = self.get_timestamp() as i64 + cnv_to_local; + let sort_timestamp = self.get_sort_timestamp() + cnv_to_local; + let send_timestamp = self.get_timestamp() + cnv_to_local; sort_timestamp / 86400 != send_timestamp / 86400 } diff --git a/src/param.rs b/src/param.rs index 981a1f0dd..69e587e18 100644 --- a/src/param.rs +++ b/src/param.rs @@ -131,7 +131,7 @@ pub enum Param { /// For Chats Selftalk = b'K', - /// For Chats: On sending a new message we set the subject to "Re: ". + /// For Chats: On sending a new message we set the subject to `Re: `. /// Usually we just use the subject of the parent message, but if the parent message /// is deleted, we use the LastSubject of the chat. LastSubject = b't', diff --git a/src/sql.rs b/src/sql.rs index bed7f0063..f24008390 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -236,13 +236,13 @@ impl Sql { // When auto_vacuum is INCREMENTAL, it is possible to // use PRAGMA incremental_vacuum to return unused // database pages to the filesystem. - conn.pragma_update(None, "auto_vacuum", &"INCREMENTAL".to_string())?; + conn.pragma_update(None, "auto_vacuum", "INCREMENTAL".to_string())?; // journal_mode is persisted, it is sufficient to change it only for one handle. - conn.pragma_update(None, "journal_mode", &"WAL".to_string())?; + conn.pragma_update(None, "journal_mode", "WAL".to_string())?; // Default synchronous=FULL is much slower. NORMAL is sufficient for WAL mode. - conn.pragma_update(None, "synchronous", &"NORMAL".to_string())?; + conn.pragma_update(None, "synchronous", "NORMAL".to_string())?; Ok(()) })?; } @@ -459,7 +459,7 @@ impl Sql { let conn = self.get_conn().await?; tokio::task::block_in_place(move || { let mut exists = false; - conn.pragma(None, "table_info", &name.to_string(), |_row| { + conn.pragma(None, "table_info", name.to_string(), |_row| { // will only be executed if the info was found exists = true; Ok(()) @@ -476,7 +476,7 @@ impl Sql { let mut exists = false; // `PRAGMA table_info` returns one row per column, // each row containing 0=cid, 1=name, 2=type, 3=notnull, 4=dflt_value - conn.pragma(None, "table_info", &table_name.to_string(), |row| { + conn.pragma(None, "table_info", table_name.to_string(), |row| { let curr_name: String = row.get(1)?; if col_name == curr_name { exists = true; diff --git a/src/tools.rs b/src/tools.rs index f5500369e..187a38ae4 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -273,7 +273,7 @@ async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time /// IDs generated by this function are 66 bit wide and are returned as 11 base64 characters. /// /// Additional information when used as a message-id or group-id: -/// - for OUTGOING messages this ID is written to the header as `Chat-Group-ID:` and is added to the message ID as Gr..@ +/// - for OUTGOING messages this ID is written to the header as `Chat-Group-ID:` and is added to the message ID as `Gr..@` /// - for INCOMING messages, the ID is taken from the Chat-Group-ID-header or from the Message-ID in the In-Reply-To: or References:-Header /// - the group-id should be a string with the characters [a-zA-Z0-9\-_] pub(crate) fn create_id() -> String { @@ -361,7 +361,7 @@ pub(crate) fn get_abs_path(context: &Context, path: impl AsRef) -> PathBuf pub(crate) async fn get_filebytes(context: &Context, path: impl AsRef) -> u64 { let path_abs = get_abs_path(context, &path); match fs::metadata(&path_abs).await { - Ok(meta) => meta.len() as u64, + Ok(meta) => meta.len(), Err(_err) => 0, } } @@ -494,7 +494,7 @@ pub fn open_file_std>( let p: PathBuf = path.as_ref().into(); let path_abs = get_abs_path(context, p); - match std::fs::File::open(&path_abs) { + match std::fs::File::open(path_abs) { Ok(bytes) => Ok(bytes), Err(err) => { warn!(