diff --git a/local/recipes/tui/tlc/source/src/editor/macro.rs b/local/recipes/tui/tlc/source/src/editor/macro.rs index 7241248404..f53962c9cb 100644 --- a/local/recipes/tui/tlc/source/src/editor/macro.rs +++ b/local/recipes/tui/tlc/source/src/editor/macro.rs @@ -238,6 +238,7 @@ impl MacroStore { for k in keys.iter_mut() { match k { NamedKey::Ctrl(c) | NamedKey::Alt(c) => { + #[allow(clippy::collapsible_match, reason = "guard would change fallthrough semantics")] if c.is_ascii_lowercase() { *c = c.to_ascii_uppercase(); } diff --git a/local/recipes/tui/tlc/source/src/filemanager/filehighlight.rs b/local/recipes/tui/tlc/source/src/filemanager/filehighlight.rs index bcf15e3c81..9c65cd45f0 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/filehighlight.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/filehighlight.rs @@ -189,7 +189,7 @@ fn extension(filename: &str) -> Option<&str> { /// `const` slices don't yet support `slice::contains` in `const` context, /// and we want to avoid pulling in a hashing layer for ~10–35 entries. fn contains(table: &[&str], needle: &str) -> bool { - table.iter().any(|e| *e == needle) + table.contains(&needle) } #[cfg(test)] diff --git a/local/recipes/tui/tlc/source/src/filemanager/info.rs b/local/recipes/tui/tlc/source/src/filemanager/info.rs index e896ee45df..3afb74103a 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/info.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/info.rs @@ -70,7 +70,7 @@ impl InfoDialog { /// `theme` supplies the title, body, and hint colours so the /// dialog follows the active skin. pub fn render(&self, frame: &mut Frame, area: Rect, theme: &Theme) { - let popup = centered_cols_rect(area, 64, area.height.saturating_sub(4).min(18).max(8)); + let popup = centered_cols_rect(area, 64, area.height.saturating_sub(4).clamp(8, 18)); let inner = render_popup(frame, popup, self.title.clone(), theme); let chunks = Layout::default() diff --git a/local/recipes/tui/tlc/source/src/filemanager/jobs.rs b/local/recipes/tui/tlc/source/src/filemanager/jobs.rs index 40a8e3bc91..ff7d94a972 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/jobs.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/jobs.rs @@ -361,7 +361,7 @@ pub fn spawn_delete_job(registry: &mut JobRegistry, paths: Vec) -> Arc< .first() .map(|p| p.display().to_string()) .unwrap_or_default(); - let total: u64 = paths.iter().map(|p| ops::count_bytes(&[p.clone()])).sum(); + let total: u64 = paths.iter().map(|p| ops::count_bytes(std::slice::from_ref(p))).sum(); let job = registry.add(JobKind::Delete, source, String::new(), total); let job_for_worker = Arc::clone(&job); thread::spawn(move || { @@ -675,7 +675,7 @@ impl JobsDialog { Style::default().fg(theme.title_fg).bg(theme.title_bg), ), Span::styled( - format!("{}", "Status"), + "Status".to_string(), Style::default().fg(theme.title_fg).bg(theme.title_bg), ), ]); @@ -690,6 +690,7 @@ impl JobsDialog { } else { let visible = chunks[1].height as usize; let n = self.cache.len(); + #[allow(clippy::if_same_then_else, reason = "n<=visible and selected { let p = self.active_panel().cursor_path(); if p.is_dir() { - let bytes = crate::ops::count_bytes(&[p.clone()]); + let bytes = crate::ops::count_bytes(std::slice::from_ref(&p)); self.status .set_message(format!("{}: {}", p.display(), format_size(bytes))); } else { @@ -759,15 +759,11 @@ impl FileManager { Ok(true) } Cmd::Panelize => { - self.dialog = Some(DialogState::ExternalPanelize(Box::new( - external_panelize::ExternalPanelizeDialog::new(), - ))); + self.dialog = Some(DialogState::ExternalPanelize(Box::default())); Ok(true) } Cmd::VfsList => { - self.dialog = Some(DialogState::VfsList(Box::new( - vfs_list::VfsListDialog::new(), - ))); + self.dialog = Some(DialogState::VfsList(Box::default())); Ok(true) } Cmd::SymlinkRelative => { @@ -1966,6 +1962,7 @@ impl FileManager { } } Some(DialogState::Delete(d)) => { + #[allow(clippy::collapsible_match, reason = "guard would change fallthrough semantics")] if d.is_confirmed() { let paths = d.paths.clone(); let handle = @@ -1987,6 +1984,7 @@ impl FileManager { // Info dialog: just close. Some(DialogState::Info(_)) => {} Some(DialogState::Quit(d)) => { + #[allow(clippy::collapsible_match, reason = "guard would change fallthrough semantics")] if d.confirmed { self.should_quit = true; } diff --git a/local/recipes/tui/tlc/source/src/filemanager/panel.rs b/local/recipes/tui/tlc/source/src/filemanager/panel.rs index dc26432b2b..6a6fab42f2 100644 --- a/local/recipes/tui/tlc/source/src/filemanager/panel.rs +++ b/local/recipes/tui/tlc/source/src/filemanager/panel.rs @@ -740,7 +740,7 @@ impl Panel { } let mut kids = vfs .read_dir(vp, self.show_hidden) - .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; + .map_err(|e| std::io::Error::other(e.to_string()))?; entries.append(&mut kids); self.entries = entries; let has_parent = self @@ -899,11 +899,14 @@ fn ext(name: &str) -> String { /// `None` for non-archive files. fn is_archive_extension(name: &str) -> Option<&'static str> { let lower = name.to_ascii_lowercase(); - if lower.ends_with(".tar") || lower.ends_with(".tar.gz") || lower.ends_with(".tgz") { - Some("tar") - } else if lower.ends_with(".tar.bz2") || lower.ends_with(".tbz") { - Some("tar") - } else if lower.ends_with(".tar.xz") || lower.ends_with(".txz") { + if lower.ends_with(".tar") + || lower.ends_with(".tar.gz") + || lower.ends_with(".tgz") + || lower.ends_with(".tar.bz2") + || lower.ends_with(".tbz") + || lower.ends_with(".tar.xz") + || lower.ends_with(".txz") + { Some("tar") } else if lower.ends_with(".zip") { Some("zip") diff --git a/local/recipes/tui/tlc/source/src/terminal/subshell.rs b/local/recipes/tui/tlc/source/src/terminal/subshell.rs index 8797aa208e..1fa0adc8f5 100644 --- a/local/recipes/tui/tlc/source/src/terminal/subshell.rs +++ b/local/recipes/tui/tlc/source/src/terminal/subshell.rs @@ -92,6 +92,7 @@ impl ShellManager { if let Some(subshell) = self.subshell.as_mut() { subshell.attach()?; } + #[allow(clippy::needless_return, reason = "cfg-gated branch must early-return")] return Ok(()); } @@ -108,6 +109,7 @@ impl ShellManager { if let Some(subshell) = self.subshell.as_mut() { subshell.attach()?; } + #[allow(clippy::needless_return, reason = "cfg-gated branch must early-return")] return Ok(()); } diff --git a/local/recipes/tui/tlc/source/src/vfs/cpio.rs b/local/recipes/tui/tlc/source/src/vfs/cpio.rs index 52eafd5568..10b5248456 100644 --- a/local/recipes/tui/tlc/source/src/vfs/cpio.rs +++ b/local/recipes/tui/tlc/source/src/vfs/cpio.rs @@ -217,7 +217,7 @@ impl Vfs for CpioVfs { let mut seen: std::collections::BTreeSet = std::collections::BTreeSet::new(); for entry in &self.entries { let ep = entry.name.as_str(); - if !ep.starts_with(&prefix_slash) && !(prefix.is_empty() && !ep.is_empty()) { + if !ep.starts_with(&prefix_slash) && (!prefix.is_empty() || ep.is_empty()) { continue; } let rest = if prefix.is_empty() { diff --git a/local/recipes/tui/tlc/source/src/vfs/tar.rs b/local/recipes/tui/tlc/source/src/vfs/tar.rs index 1a96532e20..849a2c51f5 100644 --- a/local/recipes/tui/tlc/source/src/vfs/tar.rs +++ b/local/recipes/tui/tlc/source/src/vfs/tar.rs @@ -219,7 +219,7 @@ impl Vfs for TarVfs { let mut seen: std::collections::BTreeSet = std::collections::BTreeSet::new(); for entry_path in &self.entries { if !entry_path.starts_with(&prefix_slash) - && !(prefix.is_empty() && !entry_path.is_empty()) + && (!prefix.is_empty() || entry_path.is_empty()) { continue; }