ran clippy fix

This commit is contained in:
2026-02-27 11:04:41 -05:00
parent c508180228
commit c559d1cc75
15 changed files with 44 additions and 69 deletions

View File

@@ -205,7 +205,7 @@ pub fn complete_builtin(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -
}
pub fn compgen_builtin(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -> ShResult<()> {
let blame = node.get_span().clone();
let _blame = node.get_span().clone();
let NdRule::Command {
assignments: _,
argv,

View File

@@ -7,7 +7,7 @@ use regex::Regex;
use crate::libsh::error::{ShErr, ShErrKind, ShResult};
use crate::parse::execute::exec_input;
use crate::parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule, is_field_sep, is_hard_sep};
use crate::parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule, is_hard_sep};
use crate::parse::{Redir, RedirType};
use crate::procio::{IoBuf, IoFrame, IoMode, IoStack};
use crate::readline::markers;

View File

@@ -6,7 +6,7 @@ use crate::{
prelude::*,
procio::{IoMode, borrow_fd},
signal::{disable_reaping, enable_reaping},
state::{self, read_jobs, set_status, write_jobs},
state::{self, set_status, write_jobs},
};
pub const SIG_EXIT_OFFSET: i32 = 128;
@@ -168,12 +168,7 @@ impl JobTab {
}
pub fn curr_job(&self) -> Option<usize> {
// Find the most recent valid job (order can have stale entries)
for &id in self.order.iter().rev() {
if self.jobs.get(id).is_some_and(|slot| slot.is_some()) {
return Some(id);
}
}
None
self.order.iter().rev().find(|&&id| self.jobs.get(id).is_some_and(|slot| slot.is_some())).copied()
}
pub fn prev_job(&self) -> Option<usize> {
// Find the second most recent valid job
@@ -794,7 +789,7 @@ pub fn attach_tty(pgid: Pid) -> ShResult<()> {
match result {
Ok(_) => Ok(()),
Err(e) => {
Err(_e) => {
tcsetpgrp(borrow_fd(0), getpgrp())?;
Ok(())
}

View File

@@ -1,7 +1,6 @@
use std::fmt::Display;
use crate::{
getopt::Opt,
libsh::term::{Style, Styled},
parse::lex::Span,
prelude::*,
@@ -423,7 +422,7 @@ impl Display for ShErrKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let output = match self {
Self::IoErr(e) => &format!("I/O Error: {e}"),
Self::InvalidOpt => &format!("Invalid option"),
Self::InvalidOpt => "Invalid option",
Self::SyntaxErr => "Syntax Error",
Self::ParseErr => "Parse Error",
Self::InternalErr => "Internal Error",

View File

@@ -84,7 +84,7 @@ impl TkVecUtils<Tk> for Vec<Tk> {
}
}
fn debug_tokens(&self) {
for token in self {}
for _token in self {}
}
fn split_at_separators(&self) -> Vec<Vec<Tk>> {
let mut splits = vec![];

View File

@@ -20,7 +20,6 @@ use crate::{
source::source,
test::double_bracket_test,
trap::{TrapTarget, trap},
true_builtin,
varcmds::{export, local, readonly, unset},
zoltraak::zoltraak,
},

View File

@@ -1281,7 +1281,7 @@ impl ParseStream {
let mut node_tks = vec![];
let mut redirs = vec![];
let mut argv = vec![];
let mut flags = NdFlags::empty();
let flags = NdFlags::empty();
let mut assignments = vec![];
while let Some(prefix_tk) = tk_iter.next() {

View File

@@ -1,25 +1,22 @@
use std::{
collections::HashSet, env, fmt::Debug, os::unix::fs::PermissionsExt, path::PathBuf, sync::Arc,
collections::HashSet, fmt::Debug, path::PathBuf, sync::Arc,
};
use crate::{
builtin::{
BUILTINS,
complete::{CompFlags, CompOptFlags, CompOpts},
},
builtin::complete::{CompFlags, CompOptFlags, CompOpts},
libsh::{
error::{ShErr, ShErrKind, ShResult},
error::ShResult,
utils::TkVecUtils,
},
parse::{
execute::{VarCtxGuard, exec_input},
lex::{self, LexFlags, Tk, TkFlags, TkRule, ends_with_unescaped},
lex::{self, LexFlags, Tk, TkRule, ends_with_unescaped},
},
readline::{
Marker, annotate_input, annotate_input_recursive, get_insertions,
Marker, annotate_input_recursive,
markers::{self, is_marker},
},
state::{VarFlags, VarKind, read_jobs, read_logic, read_meta, read_vars, write_vars},
state::{VarFlags, VarKind, read_jobs, read_meta, read_vars, write_vars},
};
pub fn complete_jobs(start: &str) -> Vec<String> {

View File

@@ -1,16 +1,15 @@
use std::{
env,
os::unix::fs::PermissionsExt,
path::{Path, PathBuf},
};
use crate::{
libsh::term::{Style, StyleSet, Styled},
libsh::term::{Style, StyleSet},
readline::{
annotate_input,
markers::{self, is_marker},
},
state::{read_logic, read_meta, read_shopts},
state::{read_meta, read_shopts},
};
/// Syntax highlighter for shell input using Unicode marker-based annotation

View File

@@ -11,10 +11,7 @@ use super::vicmd::{
ViCmd, Word,
};
use crate::{
libsh::{
error::ShResult,
term::{Style, Styled},
},
libsh::error::ShResult,
parse::lex::{LexFlags, LexStream, Tk, TkFlags, TkRule},
prelude::*,
readline::{
@@ -950,7 +947,7 @@ impl LineBuf {
| TextObj::Angle(bound) => self.text_obj_delim(count, text_obj, bound),
// Other stuff
TextObj::Tag(bound) => todo!(),
TextObj::Tag(_bound) => todo!(),
TextObj::Custom(_) => todo!(),
}
}
@@ -1027,12 +1024,12 @@ impl LineBuf {
Some((start, end))
}
pub fn text_obj_paragraph(&mut self, count: usize, bound: Bound) -> Option<(usize, usize)> {
pub fn text_obj_paragraph(&mut self, _count: usize, _bound: Bound) -> Option<(usize, usize)> {
todo!()
}
pub fn text_obj_delim(
&mut self,
count: usize,
_count: usize,
text_obj: TextObj,
bound: Bound,
) -> Option<(usize, usize)> {
@@ -1149,7 +1146,7 @@ impl LineBuf {
}
pub fn text_obj_quote(
&mut self,
count: usize,
_count: usize,
text_obj: TextObj,
bound: Bound,
) -> Option<(usize, usize)> {
@@ -2285,14 +2282,14 @@ impl LineBuf {
MotionKind::On(target_pos)
}
MotionCmd(count, Motion::ScreenLineUp) => todo!(),
MotionCmd(count, Motion::ScreenLineUpCharwise) => todo!(),
MotionCmd(count, Motion::ScreenLineDown) => todo!(),
MotionCmd(count, Motion::ScreenLineDownCharwise) => todo!(),
MotionCmd(count, Motion::BeginningOfScreenLine) => todo!(),
MotionCmd(count, Motion::FirstGraphicalOnScreenLine) => todo!(),
MotionCmd(count, Motion::HalfOfScreen) => todo!(),
MotionCmd(count, Motion::HalfOfScreenLineText) => todo!(),
MotionCmd(_count, Motion::ScreenLineUp) => todo!(),
MotionCmd(_count, Motion::ScreenLineUpCharwise) => todo!(),
MotionCmd(_count, Motion::ScreenLineDown) => todo!(),
MotionCmd(_count, Motion::ScreenLineDownCharwise) => todo!(),
MotionCmd(_count, Motion::BeginningOfScreenLine) => todo!(),
MotionCmd(_count, Motion::FirstGraphicalOnScreenLine) => todo!(),
MotionCmd(_count, Motion::HalfOfScreen) => todo!(),
MotionCmd(_count, Motion::HalfOfScreenLineText) => todo!(),
MotionCmd(_count, Motion::WholeBuffer) => {
MotionKind::Exclusive((0, self.grapheme_indices().len()))
}
@@ -2314,9 +2311,9 @@ impl LineBuf {
final_end = final_end.min(self.cursor.max);
MotionKind::Exclusive((start, final_end))
}
MotionCmd(count, Motion::RepeatMotion) => todo!(),
MotionCmd(count, Motion::RepeatMotionRev) => todo!(),
MotionCmd(count, Motion::Null) => MotionKind::Null,
MotionCmd(_count, Motion::RepeatMotion) => todo!(),
MotionCmd(_count, Motion::RepeatMotionRev) => todo!(),
MotionCmd(_count, Motion::Null) => MotionKind::Null,
};
self.set_buffer(buffer);
@@ -2380,7 +2377,7 @@ impl LineBuf {
end = self.cursor.get();
}
},
SelectMode::Block(anchor) => todo!(),
SelectMode::Block(_anchor) => todo!(),
}
if start >= end {
mode.invert_anchor();
@@ -2490,7 +2487,7 @@ impl LineBuf {
match verb {
Verb::Delete | Verb::Yank | Verb::Change => {
log::debug!("Executing verb: {verb:?} with motion: {motion:?}");
let Some((mut start, mut end)) = self.range_from_motion(&motion) else {
let Some((start, end)) = self.range_from_motion(&motion) else {
log::debug!("No range from motion, nothing to do");
return Ok(());
};

View File

@@ -1,7 +1,6 @@
use history::History;
use keys::{KeyCode, KeyEvent, ModKeys};
use linebuf::{LineBuf, SelectAnchor, SelectMode};
use nix::libc::STDOUT_FILENO;
use term::{KeyReader, Layout, LineWriter, PollReader, TermWriter, get_win_size};
use unicode_width::UnicodeWidthStr;
use vicmd::{CmdFlags, Motion, MotionCmd, RegisterName, Verb, VerbCmd, ViCmd};
@@ -14,10 +13,7 @@ use crate::prelude::*;
use crate::readline::term::{Pos, calc_str_width};
use crate::state::read_shopts;
use crate::{
libsh::{
error::ShResult,
term::{Style, Styled},
},
libsh::error::ShResult,
parse::lex::{self, LexFlags, Tk, TkFlags, TkRule},
readline::{complete::Completer, highlight::Highlighter},
};

View File

@@ -8,7 +8,7 @@ use std::{
use nix::{
errno::Errno,
libc::{self, STDIN_FILENO},
libc::{self},
poll::{self, PollFlags, PollTimeout},
sys::termios::{self, tcgetattr, tcsetattr},
unistd::isatty,
@@ -23,16 +23,14 @@ use crate::{
sys::TTY_FILENO,
},
readline::keys::{KeyCode, ModKeys},
shopt::ShedBellStyle,
state::read_shopts,
};
use crate::{
prelude::*,
procio::borrow_fd,
state::{read_meta, write_meta},
};
use super::{keys::KeyEvent, linebuf::LineBuf};
use super::keys::KeyEvent;
pub fn raw_mode() -> RawModeGuard {
let orig = termios::tcgetattr(unsafe { BorrowedFd::borrow_raw(*TTY_FILENO) })
@@ -50,7 +48,7 @@ pub fn raw_mode() -> RawModeGuard {
)
.expect("Failed to set terminal to raw mode");
let (cols, rows) = get_win_size(*TTY_FILENO);
let (_cols, _rows) = get_win_size(*TTY_FILENO);
RawModeGuard {
orig,

View File

@@ -9,7 +9,6 @@ use super::vicmd::{
Anchor, Bound, CmdFlags, Dest, Direction, Motion, MotionCmd, RegisterName, TextObj, To, Verb,
VerbCmd, ViCmd, Word,
};
use crate::prelude::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ModeReport {
@@ -995,7 +994,7 @@ impl ViNormal {
}
};
if chars.peek().is_some() {}
chars.peek().is_some();
let verb_ref = verb.as_ref().map(|v| &v.1);
let motion_ref = motion.as_ref().map(|m| &m.1);
@@ -1660,7 +1659,7 @@ impl ViVisual {
}
};
if chars.peek().is_some() {}
chars.peek().is_some();
let verb_ref = verb.as_ref().map(|v| &v.1);
let motion_ref = motion.as_ref().map(|m| &m.1);

View File

@@ -1,9 +1,6 @@
use std::{collections::HashMap, fmt::Display, str::FromStr};
use std::{fmt::Display, str::FromStr};
use crate::{
libsh::error::{Note, ShErr, ShErrKind, ShResult},
state::ShFunc,
};
use crate::libsh::error::{Note, ShErr, ShErrKind, ShResult};
#[derive(Clone, Copy, Debug)]
pub enum ShedBellStyle {

View File

@@ -1,9 +1,8 @@
use std::{
cell::RefCell,
cmp::Ordering,
collections::{HashMap, HashSet, VecDeque, hash_map::Entry},
fmt::Display,
ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Deref},
ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign},
os::unix::fs::PermissionsExt,
str::FromStr,
time::Duration,
@@ -1052,7 +1051,7 @@ impl MetaTab {
&mut self.comp_specs
}
pub fn get_comp_spec(&self, cmd: &str) -> Option<Box<dyn CompSpec>> {
self.comp_specs.get(cmd).map(|spec| spec.clone())
self.comp_specs.get(cmd).cloned()
}
pub fn set_comp_spec(&mut self, cmd: String, spec: Box<dyn CompSpec>) {
self.comp_specs.insert(cmd, spec);