From 1da04a4d0c7284cbc36a37242444f6b4e9f78d8a Mon Sep 17 00:00:00 2001 From: pagedmov Date: Fri, 27 Feb 2026 11:08:10 -0500 Subject: [PATCH] cleaned up all compiler warnings --- src/libsh/sys.rs | 29 ----------------------------- src/parse/lex.rs | 1 - src/readline/highlight.rs | 6 ++++++ src/readline/history.rs | 7 ++----- src/readline/term.rs | 3 --- src/readline/vimode.rs | 5 ++--- 6 files changed, 10 insertions(+), 41 deletions(-) diff --git a/src/libsh/sys.rs b/src/libsh/sys.rs index 48d68b0..0a3e440 100644 --- a/src/libsh/sys.rs +++ b/src/libsh/sys.rs @@ -3,35 +3,6 @@ use std::sync::LazyLock; use termios::{LocalFlags, Termios}; use crate::prelude::*; -/// -/// The previous state of the terminal options. -/// -/// This variable stores the terminal settings at the start of the program and -/// restores them when the program exits. It is initialized exactly once at the -/// start of the program and accessed exactly once at the end of the program. It -/// will not be mutated or accessed under any other circumstances. -/// -/// This ended up being necessary because wrapping Termios in a thread-safe way -/// was unreasonably tricky. -/// -/// The possible states of this variable are: -/// - `None`: The terminal options have not been set yet (before -/// initialization). -/// - `Some(None)`: There were no terminal options to save (i.e., no terminal -/// input detected). -/// - `Some(Some(Termios))`: The terminal options (as `Termios`) have been -/// saved. -/// -/// **Important:** This static variable is mutable and accessed via unsafe code. -/// It is only safe to use because: -/// - It is set once during program startup and accessed once during program -/// exit. -/// - It is not mutated or accessed after the initial setup and final read. -/// -/// **Caution:** Future changes to this code should respect these constraints to -/// ensure safety. Modifying or accessing this variable outside the defined -/// lifecycle could lead to undefined behavior. -pub(crate) static mut SAVED_TERMIOS: Option> = None; pub static TTY_FILENO: LazyLock = LazyLock::new(|| { open("/dev/tty", OFlag::O_RDWR, Mode::empty()).expect("Failed to open /dev/tty") diff --git a/src/parse/lex.rs b/src/parse/lex.rs index b53933f..0ef1edb 100644 --- a/src/parse/lex.rs +++ b/src/parse/lex.rs @@ -15,7 +15,6 @@ use crate::{ error::{ShErr, ShErrKind, ShResult}, utils::CharDequeUtils, }, - prelude::*, }; pub const KEYWORDS: [&str; 16] = [ diff --git a/src/readline/highlight.rs b/src/readline/highlight.rs index de6f2f6..b265648 100644 --- a/src/readline/highlight.rs +++ b/src/readline/highlight.rs @@ -441,3 +441,9 @@ impl Highlighter { .replace(markers::OPERATOR, "\x1b[35m"); } } + +impl Default for Highlighter { + fn default() -> Self { + Self::new() + } +} diff --git a/src/readline/history.rs b/src/readline/history.rs index 322862b..0d6c1a5 100644 --- a/src/readline/history.rs +++ b/src/readline/history.rs @@ -9,14 +9,11 @@ use std::{ time::{Duration, SystemTime, UNIX_EPOCH}, }; -use crate::prelude::*; use crate::{ libsh::error::{ShErr, ShErrKind, ShResult}, readline::linebuf::LineBuf, }; -use super::vicmd::Direction; // surprisingly useful - #[derive(Default, Clone, Copy, Debug)] pub enum SearchKind { Fuzzy, @@ -215,7 +212,7 @@ pub struct History { search_mask: Vec, no_matches: bool, pub cursor: usize, - search_direction: Direction, + //search_direction: Direction, ignore_dups: bool, max_size: Option, } @@ -242,7 +239,7 @@ impl History { search_mask, no_matches: false, cursor, - search_direction: Direction::Backward, + //search_direction: Direction::Backward, ignore_dups, max_size: Some(max_hist as u32), }) diff --git a/src/readline/term.rs b/src/readline/term.rs index b039e47..c62f02a 100644 --- a/src/readline/term.rs +++ b/src/readline/term.rs @@ -857,18 +857,15 @@ pub struct TermWriter { out: RawFd, pub t_cols: Col, // terminal width buffer: String, - w_calc: Box, } impl TermWriter { pub fn new(out: RawFd) -> Self { - let w_calc = width_calculator(); let (t_cols, _) = get_win_size(out); Self { out, t_cols, buffer: String::new(), - w_calc, } } pub fn get_cursor_movement(&self, old: Pos, new: Pos) -> ShResult { diff --git a/src/readline/vimode.rs b/src/readline/vimode.rs index 284c716..23b8d43 100644 --- a/src/readline/vimode.rs +++ b/src/readline/vimode.rs @@ -1,7 +1,6 @@ use std::iter::Peekable; use std::str::Chars; -use nix::NixPath; use unicode_segmentation::UnicodeSegmentation; use super::keys::{KeyCode as K, KeyEvent as E, ModKeys as M}; @@ -994,7 +993,7 @@ impl ViNormal { } }; - chars.peek().is_some(); + let _ = chars; // suppresses unused warnings, creates an error if we decide to use chars later let verb_ref = verb.as_ref().map(|v| &v.1); let motion_ref = motion.as_ref().map(|m| &m.1); @@ -1659,7 +1658,7 @@ impl ViVisual { } }; - chars.peek().is_some(); + let _ = chars; // suppresses unused warnings, creates an error if we decide to use chars later let verb_ref = verb.as_ref().map(|v| &v.1); let motion_ref = motion.as_ref().map(|m| &m.1);