From b11ad35680ee5ea1ca38d9db071fd1bcf0709697 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sat, 15 Aug 2026 20:06:13 +0800 Subject: [PATCH] refactor: drop eight #[allow(dead_code)] that no longer allow anything Each of these sits on an item the code does use: ssh_config's import_profiles, merge_imported and jump_alias, SshConnection's key field and key(), NativeSshSpec::without_secrets, CmdEditor::cursor, and Pane::ssh_connection. Verified by removing every dead_code allow in the workspace and reading back what the compiler then reported -- none of these appeared, in either a production-only or an all-targets build. A stale allow is worse than no allow. It reads as "this is dead, on purpose", so the next person leaves it alone, and it goes on covering the item after the code around it changes -- at which point the item really can die without anyone hearing about it. cursor_byte is the one that is genuinely unused outside tests, so it moves to the house idiom #[cfg_attr(not(test), allow(dead_code))], which still reports it if the tests stop using it too. --- crates/tty7-core/src/daemon/pane.rs | 1 - crates/tty7-core/src/daemon/protocol.rs | 1 - crates/tty7-core/src/daemon/ssh/session.rs | 2 -- src/core/ssh_config.rs | 3 --- src/terminal/cmd_editor.rs | 3 +-- 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/tty7-core/src/daemon/pane.rs b/crates/tty7-core/src/daemon/pane.rs index a712d9e1..0713badc 100644 --- a/crates/tty7-core/src/daemon/pane.rs +++ b/crates/tty7-core/src/daemon/pane.rs @@ -1670,7 +1670,6 @@ impl DaemonPane { } } - #[allow(dead_code)] pub fn ssh_connection(&self) -> Option> { match &self.backend { PaneBackend::NativeSsh(b) => b.connection.lock().unwrap().upgrade(), diff --git a/crates/tty7-core/src/daemon/protocol.rs b/crates/tty7-core/src/daemon/protocol.rs index 3eda0452..4348a757 100644 --- a/crates/tty7-core/src/daemon/protocol.rs +++ b/crates/tty7-core/src/daemon/protocol.rs @@ -531,7 +531,6 @@ pub enum SshTestNeed { } impl NativeSshSpec { - #[allow(dead_code)] pub fn without_secrets(&self) -> NativeSshSpec { NativeSshSpec { password: None, diff --git a/crates/tty7-core/src/daemon/ssh/session.rs b/crates/tty7-core/src/daemon/ssh/session.rs index 4855442f..ee70c78a 100644 --- a/crates/tty7-core/src/daemon/ssh/session.rs +++ b/crates/tty7-core/src/daemon/ssh/session.rs @@ -160,7 +160,6 @@ pub async fn drive_channel( pub struct SshConnection { handle: tokio::sync::Mutex>, - #[allow(dead_code)] key: ConnectionKey, remote_forwards: RemoteForwardTable, alive: AtomicBool, @@ -182,7 +181,6 @@ impl SshConnection { }) } - #[allow(dead_code)] pub fn key(&self) -> &ConnectionKey { &self.key } diff --git a/src/core/ssh_config.rs b/src/core/ssh_config.rs index fec3b576..c76644ca 100644 --- a/src/core/ssh_config.rs +++ b/src/core/ssh_config.rs @@ -202,7 +202,6 @@ pub struct ImportReport { pub files_read: usize, } -#[allow(dead_code)] pub fn import_profiles() -> Vec { let Some(home) = home_dir() else { return Vec::new(); @@ -424,7 +423,6 @@ pub struct MergeStats { pub unchanged: usize, } -#[allow(dead_code)] pub fn merge_imported( existing: &mut Vec, imported: Vec, @@ -486,7 +484,6 @@ pub fn merge_imported( stats } -#[allow(dead_code)] fn jump_alias(raw: &str) -> Option { let first = raw.split(',').next().unwrap_or(raw).trim(); if first.is_empty() { diff --git a/src/terminal/cmd_editor.rs b/src/terminal/cmd_editor.rs index 69f795c2..b8e5ec15 100644 --- a/src/terminal/cmd_editor.rs +++ b/src/terminal/cmd_editor.rs @@ -27,12 +27,11 @@ impl CmdEditor { self.chars.len() } - #[allow(dead_code)] pub fn cursor(&self) -> usize { self.cursor } - #[allow(dead_code)] + #[cfg_attr(not(test), allow(dead_code))] pub fn cursor_byte(&self) -> usize { self.chars[..self.cursor].iter().map(|c| c.len_utf8()).sum() }