From 5af3cd2670c2312ce6821a149ed70ebd1bdf5d01 Mon Sep 17 00:00:00 2001 From: Ray Kohler Date: Mon, 11 Aug 2025 16:30:31 -0400 Subject: fix: clean up new rustc and clippy warnings on Rust 1.89 --- crates/atuin-client/src/database.rs | 5 ++--- crates/atuin-client/src/import/xonsh.rs | 5 ++--- crates/atuin-client/src/import/zsh.rs | 2 +- crates/atuin-client/src/record/sqlite_store.rs | 5 ++--- crates/atuin-common/src/utils.rs | 2 +- crates/atuin-kv/src/database.rs | 5 ++--- crates/atuin-scripts/src/database.rs | 5 ++--- crates/atuin-scripts/src/execution.rs | 2 +- crates/atuin/src/command/client/history.rs | 2 +- crates/atuin/src/command/client/search/interactive.rs | 15 +++++++-------- crates/atuin/src/command/client/store/pull.rs | 5 ++--- crates/atuin/src/command/client/store/push.rs | 5 ++--- 12 files changed, 25 insertions(+), 33 deletions(-) (limited to 'crates') diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs index 952b80e5..15f4fff1 100644 --- a/crates/atuin-client/src/database.rs +++ b/crates/atuin-client/src/database.rs @@ -142,11 +142,10 @@ impl Sqlite { std::process::exit(1); } - if !path.exists() { - if let Some(dir) = path.parent() { + if !path.exists() + && let Some(dir) = path.parent() { fs::create_dir_all(dir)?; } - } let opts = SqliteConnectOptions::from_str(path.as_os_str().to_str().unwrap())? .journal_mode(SqliteJournalMode::Wal) diff --git a/crates/atuin-client/src/import/xonsh.rs b/crates/atuin-client/src/import/xonsh.rs index 201cad15..a9e6449d 100644 --- a/crates/atuin-client/src/import/xonsh.rs +++ b/crates/atuin-client/src/import/xonsh.rs @@ -66,11 +66,10 @@ fn load_sessions(hist_dir: &Path) -> Result> { for entry in fs::read_dir(hist_dir)? { let p = entry?.path(); let ext = p.extension().and_then(|e| e.to_str()); - if p.is_file() && ext == Some("json") { - if let Some(data) = load_session(&p)? { + if p.is_file() && ext == Some("json") + && let Some(data) = load_session(&p)? { sessions.push(data); } - } } Ok(sessions) } diff --git a/crates/atuin-client/src/import/zsh.rs b/crates/atuin-client/src/import/zsh.rs index 694a9aa8..b65e2608 100644 --- a/crates/atuin-client/src/import/zsh.rs +++ b/crates/atuin-client/src/import/zsh.rs @@ -118,7 +118,7 @@ fn parse_extended(line: &str, counter: i64) -> History { imported.build().into() } -fn unmetafy(line: &[u8]) -> Option> { +fn unmetafy(line: &[u8]) -> Option> { if line.contains(&0x83) { let mut s = Vec::with_capacity(line.len()); let mut is_meta = false; diff --git a/crates/atuin-client/src/record/sqlite_store.rs b/crates/atuin-client/src/record/sqlite_store.rs index a3e7228b..03b5e448 100644 --- a/crates/atuin-client/src/record/sqlite_store.rs +++ b/crates/atuin-client/src/record/sqlite_store.rs @@ -41,11 +41,10 @@ impl SqliteStore { std::process::exit(1); } - if !path.exists() { - if let Some(dir) = path.parent() { + if !path.exists() + && let Some(dir) = path.parent() { fs::create_dir_all(dir)?; } - } let opts = SqliteConnectOptions::from_str(path.as_os_str().to_str().unwrap())? .journal_mode(SqliteJournalMode::Wal) diff --git a/crates/atuin-common/src/utils.rs b/crates/atuin-common/src/utils.rs index f4756263..056412dd 100644 --- a/crates/atuin-common/src/utils.rs +++ b/crates/atuin-common/src/utils.rs @@ -145,7 +145,7 @@ pub fn is_xonsh() -> bool { /// printing history as well as to ensure the commands that appear in the interactive search /// reflect the actual command run rather than just the printable characters. pub trait Escapable: AsRef { - fn escape_control(&self) -> Cow { + fn escape_control(&self) -> Cow<'_, str> { if !self.as_ref().contains(|c: char| c.is_ascii_control()) { self.as_ref().into() } else { diff --git a/crates/atuin-kv/src/database.rs b/crates/atuin-kv/src/database.rs index ad9226de..b0aa4bd2 100644 --- a/crates/atuin-kv/src/database.rs +++ b/crates/atuin-kv/src/database.rs @@ -30,11 +30,10 @@ impl Database { std::process::exit(1); } - if !path.exists() { - if let Some(dir) = path.parent() { + if !path.exists() + && let Some(dir) = path.parent() { fs::create_dir_all(dir).await?; } - } let opts = SqliteConnectOptions::from_str(path.as_os_str().to_str().unwrap())? .journal_mode(SqliteJournalMode::Wal) diff --git a/crates/atuin-scripts/src/database.rs b/crates/atuin-scripts/src/database.rs index 71da69ff..4833f6ee 100644 --- a/crates/atuin-scripts/src/database.rs +++ b/crates/atuin-scripts/src/database.rs @@ -31,11 +31,10 @@ impl Database { std::process::exit(1); } - if !path.exists() { - if let Some(dir) = path.parent() { + if !path.exists() + && let Some(dir) = path.parent() { fs::create_dir_all(dir).await?; } - } let opts = SqliteConnectOptions::from_str(path.as_os_str().to_str().unwrap())? .journal_mode(SqliteJournalMode::Wal) diff --git a/crates/atuin-scripts/src/execution.rs b/crates/atuin-scripts/src/execution.rs index bb7f4227..5bf94aaa 100644 --- a/crates/atuin-scripts/src/execution.rs +++ b/crates/atuin-scripts/src/execution.rs @@ -40,7 +40,7 @@ impl ScriptSession { } } -fn setup_template(script: &Script) -> Result { +fn setup_template(script: &Script) -> Result> { let mut env = minijinja::Environment::new(); env.set_trim_blocks(true); env.add_template("script", script.script.as_str())?; diff --git a/crates/atuin/src/command/client/history.rs b/crates/atuin/src/command/client/history.rs index 1879c1d7..afa0f3bc 100644 --- a/crates/atuin/src/command/client/history.rs +++ b/crates/atuin/src/command/client/history.rs @@ -321,7 +321,7 @@ impl FormatKey for FmtHistory<'_> { } } -fn parse_fmt(format: &str) -> ParsedFmt { +fn parse_fmt(format: &str) -> ParsedFmt<'_> { match ParsedFmt::new(format) { Ok(fmt) => fmt, Err(err) => { diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index 6990c3e8..57ddaca9 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -169,12 +169,11 @@ impl State { } .or_else(|| self.current_cursor.map(|_| CursorStyle::DefaultUserShape)); - if cursor_style != self.current_cursor { - if let Some(style) = cursor_style { + if cursor_style != self.current_cursor + && let Some(style) = cursor_style { self.current_cursor = cursor_style; let _ = execute!(stdout(), Self::cast_cursor_style(style)); } - } } pub fn initialize_keymap_cursor(&mut self, settings: &Settings) { @@ -820,7 +819,7 @@ impl State { } } - fn build_title(&self, theme: &Theme) -> Paragraph { + fn build_title(&self, theme: &Theme) -> Paragraph<'_> { let title = if self.update_needed.is_some() { let error_style: Style = theme.get_error().into(); Paragraph::new(Text::from(Span::styled( @@ -838,7 +837,7 @@ impl State { } #[allow(clippy::unused_self)] - fn build_help(&self, settings: &Settings, theme: &Theme) -> Paragraph { + fn build_help(&self, settings: &Settings, theme: &Theme) -> Paragraph<'_> { match self.tab_index { // search 0 => Paragraph::new(Text::from(Line::from(vec![ @@ -876,7 +875,7 @@ impl State { .alignment(Alignment::Center) } - fn build_stats(&self, theme: &Theme) -> Paragraph { + fn build_stats(&self, theme: &Theme) -> Paragraph<'_> { Paragraph::new(Text::from(Span::raw(format!( "history count: {}", self.history_count, @@ -922,7 +921,7 @@ impl State { } } - fn build_input(&self, style: StyleState) -> Paragraph { + fn build_input(&self, style: StyleState) -> Paragraph<'_> { /// Max width of the UI box showing current mode const MAX_WIDTH: usize = 14; let (pref, mode) = if self.switched_search_mode { @@ -960,7 +959,7 @@ impl State { preview_width: u16, chunk_width: usize, theme: &Theme, - ) -> Paragraph { + ) -> Paragraph<'_> { let selected = self.results_state.selected(); let command = if results.is_empty() { String::new() diff --git a/crates/atuin/src/command/client/store/pull.rs b/crates/atuin/src/command/client/store/pull.rs index 36450fbf..c701a1eb 100644 --- a/crates/atuin/src/command/client/store/pull.rs +++ b/crates/atuin/src/command/client/store/pull.rs @@ -56,11 +56,10 @@ impl Pull { return true; } - if let Some(t) = self.tag.clone() { - if t != *tag { + if let Some(t) = self.tag.clone() + && t != *tag { return false; } - } true } diff --git a/crates/atuin/src/command/client/store/push.rs b/crates/atuin/src/command/client/store/push.rs index e1d80ef7..fff378f0 100644 --- a/crates/atuin/src/command/client/store/push.rs +++ b/crates/atuin/src/command/client/store/push.rs @@ -76,11 +76,10 @@ impl Push { return false; } - if let Some(t) = self.tag.clone() { - if t != *tag { + if let Some(t) = self.tag.clone() + && t != *tag { return false; } - } true } -- cgit v1.3.1