mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-20 14:23:53 +08:00
Fix some clippies and remove some dead code
This commit is contained in:
parent
723e5a8417
commit
642eff9e1f
|
@ -52,9 +52,8 @@ pub fn fg(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> Optio
|
||||||
// try to locate the job $argv[1], since we need to determine which error message to
|
// try to locate the job $argv[1], since we need to determine which error message to
|
||||||
// emit (ambigous job specification vs malformed job id).
|
// emit (ambigous job specification vs malformed job id).
|
||||||
let mut found_job = false;
|
let mut found_job = false;
|
||||||
match fish_wcstoi(argv[optind]).map(Pid::new) {
|
if let Ok(Some(pid)) = fish_wcstoi(argv[optind]).map(Pid::new) {
|
||||||
Ok(Some(pid)) => found_job = parser.job_get_from_pid(pid).is_some(),
|
found_job = parser.job_get_from_pid(pid).is_some();
|
||||||
_ => (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if found_job {
|
if found_job {
|
||||||
|
|
|
@ -380,7 +380,7 @@ pub fn get_desc(parser: &Parser, evt: &Event) -> WString {
|
||||||
format!("signal handler for {} ({})", signal.name(), signal.desc(),)
|
format!("signal handler for {} ({})", signal.name(), signal.desc(),)
|
||||||
}
|
}
|
||||||
EventDescription::Variable { name } => format!("handler for variable '{name}'"),
|
EventDescription::Variable { name } => format!("handler for variable '{name}'"),
|
||||||
EventDescription::ProcessExit { pid: None } => format!("exit handler for any process"),
|
EventDescription::ProcessExit { pid: None } => "exit handler for any process".to_string(),
|
||||||
EventDescription::ProcessExit { pid: Some(pid) } => {
|
EventDescription::ProcessExit { pid: Some(pid) } => {
|
||||||
format!("exit handler for process {pid}")
|
format!("exit handler for process {pid}")
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ pub fn get_desc(parser: &Parser, evt: &Event) -> WString {
|
||||||
format!("exit handler for job with pid {pid}")
|
format!("exit handler for job with pid {pid}")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
format!("exit handler for any job")
|
"exit handler for any job".to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EventDescription::CallerExit { .. } => {
|
EventDescription::CallerExit { .. } => {
|
||||||
|
|
20
src/proc.rs
20
src/proc.rs
|
@ -517,13 +517,10 @@ pub struct Pid(NonZeroU32);
|
||||||
|
|
||||||
impl Pid {
|
impl Pid {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn new<P: Into<i32>>(pid: P) -> Option<Pid> {
|
pub fn new(pid: i32) -> Option<Pid> {
|
||||||
let pid = pid.into();
|
// Construct a pid from an i32, which must be at least zero.
|
||||||
assert!(pid >= 0, "Invalid negative PID value!");
|
assert!(pid >= 0, "Pid must be at least zero");
|
||||||
match NonZeroU32::new(pid as u32) {
|
NonZeroU32::new(pid as u32).map(Pid)
|
||||||
Some(x) => Some(Pid(x)),
|
|
||||||
None => None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn get(&self) -> i32 {
|
pub fn get(&self) -> i32 {
|
||||||
|
@ -536,13 +533,6 @@ impl Pid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Pid> for u32 {
|
|
||||||
#[inline(always)]
|
|
||||||
fn into(self) -> Pid {
|
|
||||||
Pid::new(self as i32).unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for Pid {
|
impl std::fmt::Display for Pid {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
std::fmt::Display::fmt(&self.get(), f)
|
std::fmt::Display::fmt(&self.get(), f)
|
||||||
|
@ -557,7 +547,7 @@ impl ToWString for Pid {
|
||||||
|
|
||||||
impl fish_printf::ToArg<'static> for Pid {
|
impl fish_printf::ToArg<'static> for Pid {
|
||||||
fn to_arg(self) -> fish_printf::Arg<'static> {
|
fn to_arg(self) -> fish_printf::Arg<'static> {
|
||||||
fish_printf::Arg::UInt(self.get() as u64)
|
self.get().to_arg()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ impl DirIter {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.entry.reset();
|
self.entry.reset();
|
||||||
self.entry.name = cstr2wcstring(&d_name);
|
self.entry.name = cstr2wcstring(d_name);
|
||||||
#[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
#[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
||||||
{
|
{
|
||||||
self.entry.inode = dent.d_fileno;
|
self.entry.inode = dent.d_fileno;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user