Skip to content

Commit a7a0347

Browse files
committed
clippy: Fix lints in other platforms
1 parent 80d5005 commit a7a0347

14 files changed

Lines changed: 46 additions & 76 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ lib*.a
2121

2222
### direnv ###
2323
/.direnv/
24+
25+
*.code-workspace

src/bin/uudoc.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ fn usage<T: Args>(utils: &UtilityMap<T>) {
4545
}
4646

4747
/// Generates the coreutils app for the utility map
48-
fn gen_coreutils_app<T: Args>(util_map: &UtilityMap<T>) -> clap::Command {
49-
let mut command = clap::Command::new("coreutils");
48+
fn gen_coreutils_app<T: Args>(util_map: &UtilityMap<T>) -> Command {
49+
let mut command = Command::new("coreutils");
5050
for (name, (_, sub_app)) in util_map {
5151
// Recreate a small subcommand with only the relevant info
5252
// (name & short description)
5353
let about = sub_app()
5454
.get_about()
5555
.expect("Could not get the 'about'")
5656
.to_string();
57-
let sub_app = clap::Command::new(name).about(about);
57+
let sub_app = Command::new(name).about(about);
5858
command = command.subcommand(sub_app);
5959
}
6060
command
@@ -172,7 +172,7 @@ fn main() -> io::Result<()> {
172172
}
173173
let utils = util_map::<Box<dyn Iterator<Item = OsString>>>();
174174
match std::fs::create_dir("docs/src/utils/") {
175-
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => Ok(()),
175+
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
176176
x => x,
177177
}?;
178178

@@ -202,7 +202,7 @@ fn main() -> io::Result<()> {
202202
let mut map = HashMap::new();
203203
for platform in ["unix", "macos", "windows", "unix_android"] {
204204
let platform_utils: Vec<String> = String::from_utf8(
205-
std::process::Command::new("./util/show-utils.sh")
205+
process::Command::new("./util/show-utils.sh")
206206
.arg(format!("--features=feat_os_{platform}"))
207207
.output()?
208208
.stdout,
@@ -217,7 +217,7 @@ fn main() -> io::Result<()> {
217217

218218
// Linux is a special case because it can support selinux
219219
let platform_utils: Vec<String> = String::from_utf8(
220-
std::process::Command::new("./util/show-utils.sh")
220+
process::Command::new("./util/show-utils.sh")
221221
.arg("--features=feat_os_unix feat_selinux")
222222
.output()?
223223
.stdout,
@@ -547,7 +547,7 @@ fn write_zip_examples(
547547
};
548548

549549
match format_examples(content, output_markdown) {
550-
Err(e) => Err(std::io::Error::other(format!(
550+
Err(e) => Err(io::Error::other(format!(
551551
"Failed to format the tldr examples of {name}: {e}"
552552
))),
553553
Ok(s) => Ok(s),

src/uu/env/src/env.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,7 @@ where
10231023

10241024
// Set environment variable to communicate to Rust child processes
10251025
// that SIGPIPE should be default (not ignored)
1026-
if matches!(action_kind, SignalActionKind::Default)
1027-
&& sig_value == libc::SIGPIPE as usize
1028-
{
1026+
if matches!(action_kind, SignalActionKind::Default) && sig_value == libc::SIGPIPE as usize {
10291027
unsafe {
10301028
env::set_var("RUST_SIGPIPE", "default");
10311029
}

src/uu/ls/src/colors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'a> StyleManager<'a> {
495495
}
496496

497497
#[cfg(not(unix))]
498-
fn indicator_for_special_file(&self, _file_type: &std::fs::FileType) -> Option<Indicator> {
498+
fn indicator_for_special_file(&self, _file_type: &fs::FileType) -> Option<Indicator> {
499499
None
500500
}
501501

src/uu/ls/src/ls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3574,7 +3574,7 @@ fn get_security_context<'a>(
35743574
// For SMACK, use the path to get the label
35753575
// If must_dereference is true, we follow the symlink
35763576
let target_path = if must_dereference {
3577-
std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf())
3577+
fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf())
35783578
} else {
35793579
path.to_path_buf()
35803580
};

src/uu/mkfifo/src/mkfifo.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
8888
let set_security_context = matches.get_flag(options::SECURITY_CONTEXT);
8989
let context = matches.get_one::<String>(options::CONTEXT);
9090
if set_security_context || context.is_some() {
91-
uucore::smack::set_smack_label_and_cleanup(&f, context, |p| {
92-
std::fs::remove_file(p)
93-
})?;
91+
uucore::smack::set_smack_label_and_cleanup(&f, context, |p| fs::remove_file(p))?;
9492
}
9593
}
9694
}

src/uucore/src/lib/features/checksum/validate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ fn compute_and_check_digest_from_file(
687687
}));
688688

689689
write_file_report(
690-
std::io::stdout(),
690+
io::stdout(),
691691
filename,
692692
FileChecksumResult::CantOpen,
693693
prefix,

src/uucore/src/lib/features/proc_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ mod tests {
479479

480480
#[test]
481481
fn test_thread_ids() {
482-
let main_tid = unsafe { crate::libc::gettid() };
482+
let main_tid = unsafe { libc::gettid() };
483483
std::thread::spawn(move || {
484484
let mut pid_entry = ProcessInformation::try_new(
485485
PathBuf::from_str(&format!("/proc/{}", current_pid())).unwrap(),
@@ -489,7 +489,7 @@ mod tests {
489489

490490
assert!(thread_ids.contains(&(main_tid as usize)));
491491

492-
let new_thread_tid = unsafe { crate::libc::gettid() };
492+
let new_thread_tid = unsafe { libc::gettid() };
493493
assert!(thread_ids.contains(&(new_thread_tid as usize)));
494494
})
495495
.join()

src/uucore/src/lib/features/sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl Write for DigestWriter<'_> {
474474
}
475475

476476
#[cfg(windows)]
477-
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
477+
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
478478
if self.binary {
479479
self.digest.hash_update(buf);
480480
return Ok(buf.len());

src/uucore/src/lib/features/systemd_logind.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::mem::MaybeUninit;
1717
use std::time::{SystemTime, UNIX_EPOCH};
1818

1919
use crate::error::{UResult, USimpleError};
20-
use crate::utmpx;
2120

2221
/// FFI bindings for libsystemd login and D-Bus functions
2322
mod ffi {
@@ -304,18 +303,18 @@ impl SystemdLoginRecord {
304303
}
305304

306305
/// Get login time as time::OffsetDateTime compatible with utmpx
307-
pub fn login_time_offset(&self) -> utmpx::time::OffsetDateTime {
306+
pub fn login_time_offset(&self) -> time::OffsetDateTime {
308307
let duration = self
309308
.login_time
310309
.duration_since(UNIX_EPOCH)
311310
.unwrap_or_default();
312311
let ts_nanos: i128 = (duration.as_nanos()).try_into().unwrap_or(0);
313-
let local_offset = utmpx::time::OffsetDateTime::now_local()
314-
.map_or_else(|_| utmpx::time::UtcOffset::UTC, |v| v.offset());
315-
utmpx::time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
312+
let local_offset =
313+
time::OffsetDateTime::now_local().map_or_else(|_| time::UtcOffset::UTC, |v| v.offset());
314+
time::OffsetDateTime::from_unix_timestamp_nanos(ts_nanos)
316315
.unwrap_or_else(|_| {
317-
utmpx::time::OffsetDateTime::now_local()
318-
.unwrap_or_else(|_| utmpx::time::OffsetDateTime::now_utc())
316+
time::OffsetDateTime::now_local()
317+
.unwrap_or_else(|_| time::OffsetDateTime::now_utc())
319318
})
320319
.to_offset(local_offset)
321320
}
@@ -566,7 +565,7 @@ impl SystemdUtmpxCompat {
566565
}
567566

568567
/// Login time
569-
pub fn login_time(&self) -> utmpx::time::OffsetDateTime {
568+
pub fn login_time(&self) -> time::OffsetDateTime {
570569
self.record.login_time_offset()
571570
}
572571

@@ -681,7 +680,7 @@ mod tests {
681680
seat_or_tty: "tty1".to_string(),
682681
raw_device: "tty1".to_string(),
683682
host: "host1".to_string(),
684-
login_time: std::time::UNIX_EPOCH,
683+
login_time: UNIX_EPOCH,
685684
pid: 1234,
686685
session_leader_pid: 1234,
687686
record_type: SystemdRecordType::UserProcess,
@@ -692,7 +691,7 @@ mod tests {
692691
seat_or_tty: "pts/0".to_string(),
693692
raw_device: "pts/0".to_string(),
694693
host: "host2".to_string(),
695-
login_time: std::time::UNIX_EPOCH,
694+
login_time: UNIX_EPOCH,
696695
pid: 5678,
697696
session_leader_pid: 5678,
698697
record_type: SystemdRecordType::UserProcess,
@@ -729,7 +728,7 @@ mod tests {
729728
seat_or_tty: "tty1".to_string(),
730729
raw_device: "tty1".to_string(),
731730
host: "host1".to_string(),
732-
login_time: std::time::UNIX_EPOCH,
731+
login_time: UNIX_EPOCH,
733732
pid: 1234,
734733
session_leader_pid: 1234,
735734
record_type: SystemdRecordType::UserProcess,
@@ -753,7 +752,7 @@ mod tests {
753752
seat_or_tty: "seat0".to_string(),
754753
raw_device: "seat0".to_string(),
755754
host: "localhost".to_string(),
756-
login_time: std::time::UNIX_EPOCH + std::time::Duration::from_secs(1000),
755+
login_time: UNIX_EPOCH + std::time::Duration::from_secs(1000),
757756
pid: 9999,
758757
session_leader_pid: 9999,
759758
record_type: SystemdRecordType::UserProcess,

0 commit comments

Comments
 (0)