From 688e39a67e6a467ca649acbe20b1f368fbc1e9f0 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 19 Nov 2023 14:42:07 +0200 Subject: [PATCH] Fix clippy lints Signed-off-by: Manos Pitsidianakis --- meli/src/jobs_view.rs | 2 +- meli/src/mail/compose.rs | 2 +- meli/src/subcommands.rs | 2 +- meli/src/terminal/embed/grid.rs | 5 ++--- meli/src/utilities/tables.rs | 8 ++++---- melib/src/email/mailto.rs | 4 ++-- melib/src/gpgme/mod.rs | 8 ++------ melib/src/imap/mod.rs | 4 ++-- melib/src/utils/mod.rs | 4 ++-- 9 files changed, 17 insertions(+), 22 deletions(-) diff --git a/meli/src/jobs_view.rs b/meli/src/jobs_view.rs index 6a4abfe3..b2157124 100644 --- a/meli/src/jobs_view.rs +++ b/meli/src/jobs_view.rs @@ -78,7 +78,7 @@ impl std::fmt::Display for JobManager { } impl JobManager { - const HEADERS: [&str; 5] = ["id", "desc", "started", "finished", "succeeded"]; + const HEADERS: [&'static str; 5] = ["id", "desc", "started", "finished", "succeeded"]; pub fn new(context: &Context) -> Self { let theme_default = crate::conf::value(context, "theme_default"); diff --git a/meli/src/mail/compose.rs b/meli/src/mail/compose.rs index 31b366ec..1d3560f4 100644 --- a/meli/src/mail/compose.rs +++ b/meli/src/mail/compose.rs @@ -1899,7 +1899,7 @@ impl Component for Composer { ); let f = create_temp_file( - self.draft.to_edit_string().as_str().as_bytes(), + self.draft.to_edit_string().as_bytes(), None, None, Some("eml"), diff --git a/meli/src/subcommands.rs b/meli/src/subcommands.rs index 7c0f516d..a314b0c5 100644 --- a/meli/src/subcommands.rs +++ b/meli/src/subcommands.rs @@ -57,7 +57,7 @@ pub fn edit_config() -> Result<()> { })?; let config_path = crate::conf::get_config_file()?; - let mut cmd = Command::new(&editor); + let mut cmd = Command::new(editor); let mut handle = &mut cmd; for c in crate::conf::get_included_configs(config_path)? { diff --git a/meli/src/terminal/embed/grid.rs b/meli/src/terminal/embed/grid.rs index 9feba192..5b4f2792 100644 --- a/meli/src/terminal/embed/grid.rs +++ b/meli/src/terminal/embed/grid.rs @@ -265,7 +265,7 @@ impl EmbedGrid { ref mut scroll_region, ref mut terminal_size, ref mut alternate_screen, - ref mut state, + state: _, ref mut fg_color, ref mut bg_color, ref mut attrs, @@ -347,8 +347,7 @@ impl EmbedGrid { }; } - #[allow(clippy::redundant_locals)] - let mut state = state; + let mut state = &mut self.state; match (byte, &mut state) { (b'\x1b', State::Normal) => { *state = State::ExpectingControlChar; diff --git a/meli/src/utilities/tables.rs b/meli/src/utilities/tables.rs index 1b340794..0f8c187a 100644 --- a/meli/src/utilities/tables.rs +++ b/meli/src/utilities/tables.rs @@ -158,10 +158,10 @@ impl Default for DataColumns { } impl DataColumns { - pub const ARROW_UP: &str = "🠉"; - pub const ARROW_DOWN: &str = "🠋"; - pub const ARROW_UP_ASCII: &str = "^"; - pub const ARROW_DOWN_ASCII: &str = "v"; + pub const ARROW_UP: &'static str = "🠉"; + pub const ARROW_DOWN: &'static str = "🠋"; + pub const ARROW_UP_ASCII: &'static str = "^"; + pub const ARROW_DOWN_ASCII: &'static str = "v"; // const ARROW_UP_1: &str = "↑"; // const ARROW_DOWN_1: &str = "↓"; // const ARROW_UP_3: &str = "▲"; diff --git a/melib/src/email/mailto.rs b/melib/src/email/mailto.rs index 3d587d3b..3666bc55 100644 --- a/melib/src/email/mailto.rs +++ b/melib/src/email/mailto.rs @@ -40,7 +40,7 @@ pub struct Mailto { } impl Mailto { - pub const IGNORE_HEADERS: &[HeaderName] = &[ + pub const IGNORE_HEADERS: &'static [HeaderName] = &[ HeaderName::FROM, HeaderName::DATE, HeaderName::MESSAGE_ID, @@ -97,7 +97,7 @@ impl Mailto { HeaderName::USER_AGENT, ]; - pub const MAILTO_CHARSET: &AsciiSet = &CONTROLS + pub const MAILTO_CHARSET: &'static AsciiSet = &CONTROLS .add(b' ') .add(b'"') .add(b'"') diff --git a/melib/src/gpgme/mod.rs b/melib/src/gpgme/mod.rs index eff9842f..4d21dbd3 100644 --- a/melib/src/gpgme/mod.rs +++ b/melib/src/gpgme/mod.rs @@ -1188,12 +1188,8 @@ unsafe impl Sync for Data {} impl Drop for Data { #[inline] fn drop(&mut self) { - if !self.inner.as_ptr().is_null() { - match self.kind { - DataKind::Memory => unsafe { - call!(self.lib, gpgme_data_release)(self.inner.as_mut()) - }, - } + match self.kind { + DataKind::Memory => unsafe { call!(self.lib, gpgme_data_release)(self.inner.as_mut()) }, } } } diff --git a/melib/src/imap/mod.rs b/melib/src/imap/mod.rs index c6f3dddb..380cada6 100644 --- a/melib/src/imap/mod.rs +++ b/melib/src/imap/mod.rs @@ -975,7 +975,7 @@ impl MailBackend for ImapType { } let ret: Result<()> = ImapResponse::try_from(response.as_slice())?.into(); ret?; - let new_hash = MailboxHash::from_bytes(path.as_str().as_bytes()); + let new_hash = MailboxHash::from_bytes(path.as_bytes()); uid_store.mailboxes.lock().await.clear(); Ok(( new_hash, @@ -1141,7 +1141,7 @@ impl MailBackend for ImapType { .read_response(&mut response, RequiredResponses::empty()) .await?; } - let new_hash = MailboxHash::from_bytes(new_path.as_str().as_bytes()); + let new_hash = MailboxHash::from_bytes(new_path.as_bytes()); let ret: Result<()> = ImapResponse::try_from(response.as_slice())?.into(); ret?; uid_store.mailboxes.lock().await.clear(); diff --git a/melib/src/utils/mod.rs b/melib/src/utils/mod.rs index 970e7f6a..77b26b89 100644 --- a/melib/src/utils/mod.rs +++ b/melib/src/utils/mod.rs @@ -61,8 +61,8 @@ pub mod html_escape { } impl HtmlEntity { - pub const ALL: [&str; 4] = ["<", ">", "&", """]; - pub const GLYPHS: [&str; 4] = ["<", ">", "&", "\""]; + pub const ALL: [&'static str; 4] = ["<", ">", "&", """]; + pub const GLYPHS: [&'static str; 4] = ["<", ">", "&", "\""]; pub const fn glyph(self) -> char { match self {