mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-19 05:13:44 +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
|
||||
// emit (ambigous job specification vs malformed job id).
|
||||
let mut found_job = false;
|
||||
match fish_wcstoi(argv[optind]).map(Pid::new) {
|
||||
Ok(Some(pid)) => found_job = parser.job_get_from_pid(pid).is_some(),
|
||||
_ => (),
|
||||
if let Ok(Some(pid)) = fish_wcstoi(argv[optind]).map(Pid::new) {
|
||||
found_job = parser.job_get_from_pid(pid).is_some();
|
||||
};
|
||||
|
||||
if found_job {
|
||||
|
|
|
@ -380,7 +380,7 @@ pub fn get_desc(parser: &Parser, evt: &Event) -> WString {
|
|||
format!("signal handler for {} ({})", signal.name(), signal.desc(),)
|
||||
}
|
||||
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) } => {
|
||||
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}")
|
||||
}
|
||||
} else {
|
||||
format!("exit handler for any job")
|
||||
"exit handler for any job".to_string()
|
||||
}
|
||||
}
|
||||
EventDescription::CallerExit { .. } => {
|
||||
|
|
20
src/proc.rs
20
src/proc.rs
|
@ -517,13 +517,10 @@ pub struct Pid(NonZeroU32);
|
|||
|
||||
impl Pid {
|
||||
#[inline(always)]
|
||||
pub fn new<P: Into<i32>>(pid: P) -> Option<Pid> {
|
||||
let pid = pid.into();
|
||||
assert!(pid >= 0, "Invalid negative PID value!");
|
||||
match NonZeroU32::new(pid as u32) {
|
||||
Some(x) => Some(Pid(x)),
|
||||
None => None,
|
||||
}
|
||||
pub fn new(pid: i32) -> Option<Pid> {
|
||||
// Construct a pid from an i32, which must be at least zero.
|
||||
assert!(pid >= 0, "Pid must be at least zero");
|
||||
NonZeroU32::new(pid as u32).map(Pid)
|
||||
}
|
||||
#[inline(always)]
|
||||
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 {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(&self.get(), f)
|
||||
|
@ -557,7 +547,7 @@ impl ToWString for Pid {
|
|||
|
||||
impl fish_printf::ToArg<'static> for Pid {
|
||||
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.name = cstr2wcstring(&d_name);
|
||||
self.entry.name = cstr2wcstring(d_name);
|
||||
#[cfg(any(target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
||||
{
|
||||
self.entry.inode = dent.d_fileno;
|
||||
|
|
Loading…
Reference in New Issue
Block a user