From ae7396996943b2a3eae15cb3051e339684ee9944 Mon Sep 17 00:00:00 2001 From: pagedmov Date: Sat, 7 Mar 2026 00:37:51 -0500 Subject: [PATCH] fixed compiler warnings --- src/builtin/autocmd.rs | 4 ++-- src/builtin/dirstack.rs | 2 +- src/builtin/map.rs | 38 ++++++++++++++++---------------- src/builtin/read.rs | 48 ++++++++++++++++++++--------------------- src/builtin/resource.rs | 3 +-- src/jobs.rs | 1 - src/procio.rs | 3 ++- src/readline/history.rs | 2 +- src/readline/term.rs | 2 +- src/testutil.rs | 4 ++-- 10 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/builtin/autocmd.rs b/src/builtin/autocmd.rs index 121c9fb..7f6fc14 100644 --- a/src/builtin/autocmd.rs +++ b/src/builtin/autocmd.rs @@ -114,7 +114,7 @@ pub fn autocmd(node: Node) -> ShResult<()> { #[cfg(test)] mod tests { - use crate::state::{self, AutoCmdKind, read_logic, write_logic}; + use crate::state::{self, AutoCmdKind, read_logic}; use crate::testutil::{TestGuard, test_input}; // ===================== Registration ===================== @@ -253,7 +253,7 @@ mod tests { "on-exit", ]; for kind in kinds { - test_input(&format!("autocmd {kind} 'true'")).unwrap(); + test_input(format!("autocmd {kind} 'true'")).unwrap(); } } diff --git a/src/builtin/dirstack.rs b/src/builtin/dirstack.rs index 9f498e3..e337194 100644 --- a/src/builtin/dirstack.rs +++ b/src/builtin/dirstack.rs @@ -5,7 +5,7 @@ use nix::{libc::STDOUT_FILENO, unistd::write}; use yansi::Color; use crate::{ - libsh::{error::{ShErr, ShErrKind, ShResult, next_color}, sys::TTY_FILENO}, + libsh::error::{ShErr, ShErrKind, ShResult, next_color}, parse::{NdRule, Node, execute::prepare_argv, lex::Span}, procio::borrow_fd, state::{self, read_meta, write_meta}, diff --git a/src/builtin/map.rs b/src/builtin/map.rs index 2c50852..ef33008 100644 --- a/src/builtin/map.rs +++ b/src/builtin/map.rs @@ -368,6 +368,25 @@ pub fn map(node: Node) -> ShResult<()> { Ok(()) } +pub fn get_map_opts(opts: Vec) -> MapOpts { + let mut map_opts = MapOpts { + flags: MapFlags::empty(), + }; + + for opt in opts { + match opt { + Opt::Short('r') => map_opts.flags |= MapFlags::REMOVE, + Opt::Short('j') => map_opts.flags |= MapFlags::JSON, + Opt::Short('k') => map_opts.flags |= MapFlags::KEYS, + Opt::Short('l') => map_opts.flags |= MapFlags::LOCAL, + Opt::Long(ref s) if s == "pretty" => map_opts.flags |= MapFlags::PRETTY, + Opt::Short('F') => map_opts.flags |= MapFlags::FUNC, + _ => unreachable!(), + } + } + map_opts +} + #[cfg(test)] mod tests { use super::{MapNode, MapFlags, get_map_opts}; @@ -601,22 +620,3 @@ mod tests { assert_eq!(state::get_status(), 0); } } - -pub fn get_map_opts(opts: Vec) -> MapOpts { - let mut map_opts = MapOpts { - flags: MapFlags::empty(), - }; - - for opt in opts { - match opt { - Opt::Short('r') => map_opts.flags |= MapFlags::REMOVE, - Opt::Short('j') => map_opts.flags |= MapFlags::JSON, - Opt::Short('k') => map_opts.flags |= MapFlags::KEYS, - Opt::Short('l') => map_opts.flags |= MapFlags::LOCAL, - Opt::Long(ref s) if s == "pretty" => map_opts.flags |= MapFlags::PRETTY, - Opt::Short('F') => map_opts.flags |= MapFlags::FUNC, - _ => unreachable!(), - } - } - map_opts -} diff --git a/src/builtin/read.rs b/src/builtin/read.rs index c84cb17..3e81bea 100644 --- a/src/builtin/read.rs +++ b/src/builtin/read.rs @@ -341,6 +341,30 @@ pub fn read_key(node: Node) -> ShResult<()> { Ok(()) } +pub fn get_read_key_opts(opts: Vec) -> ShResult { + let mut read_key_opts = ReadKeyOpts { + var_name: None, + char_whitelist: None, + char_blacklist: None, + }; + + for opt in opts { + match opt { + Opt::ShortWithArg('v', var_name) => read_key_opts.var_name = Some(var_name), + Opt::ShortWithArg('w', char_whitelist) => read_key_opts.char_whitelist = Some(char_whitelist), + Opt::ShortWithArg('b', char_blacklist) => read_key_opts.char_blacklist = Some(char_blacklist), + _ => { + return Err(ShErr::simple( + ShErrKind::ExecFail, + format!("read_key: Unexpected flag '{opt}'"), + )); + } + } + } + + Ok(read_key_opts) +} + #[cfg(test)] mod tests { use crate::state::{self, read_vars, write_vars, VarFlags, VarKind}; @@ -468,27 +492,3 @@ mod tests { assert_eq!(flags.delim, b','); } } - -pub fn get_read_key_opts(opts: Vec) -> ShResult { - let mut read_key_opts = ReadKeyOpts { - var_name: None, - char_whitelist: None, - char_blacklist: None, - }; - - for opt in opts { - match opt { - Opt::ShortWithArg('v', var_name) => read_key_opts.var_name = Some(var_name), - Opt::ShortWithArg('w', char_whitelist) => read_key_opts.char_whitelist = Some(char_whitelist), - Opt::ShortWithArg('b', char_blacklist) => read_key_opts.char_blacklist = Some(char_blacklist), - _ => { - return Err(ShErr::simple( - ShErrKind::ExecFail, - format!("read_key: Unexpected flag '{opt}'"), - )); - } - } - } - - Ok(read_key_opts) -} diff --git a/src/builtin/resource.rs b/src/builtin/resource.rs index 4ad1a7b..a3a029d 100644 --- a/src/builtin/resource.rs +++ b/src/builtin/resource.rs @@ -1,9 +1,8 @@ use ariadne::Fmt; use nix::sys::resource::{Resource, getrlimit, setrlimit}; -use yansi::Color; use crate::{ - getopt::{Opt, OptSpec, get_opts_from_tokens, get_opts_from_tokens_strict}, libsh::error::{ShErr, ShErrKind, ShResult, ShResultExt, next_color}, parse::{NdRule, Node, execute::prepare_argv}, prelude::*, state::{self} + getopt::{Opt, OptSpec, get_opts_from_tokens_strict}, libsh::error::{ShErr, ShErrKind, ShResult, ShResultExt, next_color}, parse::{NdRule, Node}, state::{self} }; fn ulimit_opt_spec() -> [OptSpec;5] { diff --git a/src/jobs.rs b/src/jobs.rs index c5276c9..958ed5a 100644 --- a/src/jobs.rs +++ b/src/jobs.rs @@ -6,7 +6,6 @@ use crate::{ libsh::{ error::{ShErr, ShErrKind, ShResult}, sys::TTY_FILENO, - term::{Style, Styled}, }, prelude::*, procio::{IoMode, borrow_fd}, diff --git a/src/procio.rs b/src/procio.rs index 24084d6..42424d5 100644 --- a/src/procio.rs +++ b/src/procio.rs @@ -333,6 +333,7 @@ pub fn borrow_fd<'f>(fd: i32) -> BorrowedFd<'f> { unsafe { BorrowedFd::borrow_raw(fd) } } +type PipeFrames = Map, Option)) -> IoFrame>; pub struct PipeGenerator { num_cmds: usize, cursor: usize, @@ -347,7 +348,7 @@ impl PipeGenerator { last_rpipe: None, } } - pub fn as_io_frames(self) -> Map, Option)) -> IoFrame> { + pub fn as_io_frames(self) -> PipeFrames { self.map(|(r, w)| { let mut frame = IoFrame::new(); if let Some(r) = r { diff --git a/src/readline/history.rs b/src/readline/history.rs index c2127cc..390c830 100644 --- a/src/readline/history.rs +++ b/src/readline/history.rs @@ -472,7 +472,7 @@ mod tests { use super::*; use crate::{state, testutil::TestGuard}; use scopeguard::guard; - use std::{env, fs, path::Path, sync::Mutex}; + use std::{env, fs, path::Path}; use tempfile::tempdir; fn with_env_var(key: &str, val: &str) -> impl Drop { diff --git a/src/readline/term.rs b/src/readline/term.rs index 9943622..c0216a5 100644 --- a/src/readline/term.rs +++ b/src/readline/term.rs @@ -4,7 +4,7 @@ use std::{ fmt::{Debug, Write}, io::{BufRead, BufReader, Read}, os::fd::{AsFd, BorrowedFd, RawFd}, - sync::Arc, time::Instant, + time::Instant, }; use nix::{ diff --git a/src/testutil.rs b/src/testutil.rs index 3868342..484264a 100644 --- a/src/testutil.rs +++ b/src/testutil.rs @@ -41,7 +41,7 @@ pub struct TestGuard { old_cwd: PathBuf, saved_env: HashMap, pty_master: OwnedFd, - pty_slave: OwnedFd, + _pty_slave: OwnedFd, cleanups: Vec> } @@ -96,7 +96,7 @@ impl TestGuard { old_cwd, saved_env, pty_master, - pty_slave, + _pty_slave: pty_slave, cleanups: vec![], } }