Skip to content

Commit 5bfbc30

Browse files
authored
Merge pull request #7715 from nyurik/unused_qualifications
Enable and fix `unused_qualifications` lint
2 parents 1bfe656 + 76b1b68 commit 5bfbc30

File tree

45 files changed

+218
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+218
-242
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ pedantic = { level = "deny", priority = -1 }
594594
# Eventually the clippy settings from the `[lints]` section should be moved here.
595595
# In order to use these, all crates have `[lints] workspace = true` section.
596596
[workspace.lints.rust]
597-
# unused_qualifications = "warn"
597+
unused_qualifications = "warn"
598598

599599
[workspace.lints.clippy]
600600
all = { level = "deny", priority = -1 }

src/uu/base32/src/base_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
139139
.arg(
140140
Arg::new(options::FILE)
141141
.index(1)
142-
.action(clap::ArgAction::Append)
142+
.action(ArgAction::Append)
143143
.value_hint(clap::ValueHint::FilePath),
144144
)
145145
}

src/uu/basename/src/basename.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn uu_app() -> Command {
9090
)
9191
.arg(
9292
Arg::new(options::NAME)
93-
.action(clap::ArgAction::Append)
93+
.action(ArgAction::Append)
9494
.value_hint(clap::ValueHint::AnyPath)
9595
.hide(true)
9696
.trailing_var_arg(true),

src/uu/cat/src/cat.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl LineNumber {
8686
}
8787
}
8888

89-
fn write(&self, writer: &mut impl Write) -> std::io::Result<()> {
89+
fn write(&self, writer: &mut impl Write) -> io::Result<()> {
9090
writer.write_all(&self.buf)
9191
}
9292
}
@@ -288,7 +288,7 @@ pub fn uu_app() -> Command {
288288
.arg(
289289
Arg::new(options::FILE)
290290
.hide(true)
291-
.action(clap::ArgAction::Append)
291+
.action(ArgAction::Append)
292292
.value_hint(clap::ValueHint::FilePath),
293293
)
294294
.arg(
@@ -377,7 +377,7 @@ fn cat_handle<R: FdReadable>(
377377
/// Whether this process is appending to stdout.
378378
#[cfg(unix)]
379379
fn is_appending() -> bool {
380-
let stdout = std::io::stdout();
380+
let stdout = io::stdout();
381381
let flags = match fcntl(stdout.as_raw_fd(), FcntlArg::F_GETFL) {
382382
Ok(flags) => flags,
383383
Err(_) => return false,
@@ -404,7 +404,7 @@ fn cat_path(
404404
let in_info = FileInformation::from_file(&stdin)?;
405405
let mut handle = InputHandle {
406406
reader: stdin,
407-
is_interactive: std::io::stdin().is_terminal(),
407+
is_interactive: io::stdin().is_terminal(),
408408
};
409409
if let Some(out_info) = out_info {
410410
if in_info == *out_info && is_appending() {
@@ -445,7 +445,7 @@ fn cat_path(
445445
}
446446

447447
fn cat_files(files: &[String], options: &OutputOptions) -> UResult<()> {
448-
let out_info = FileInformation::from_file(&std::io::stdout()).ok();
448+
let out_info = FileInformation::from_file(&io::stdout()).ok();
449449

450450
let mut state = OutputState {
451451
line_number: LineNumber::new(),

src/uu/chcon/src/chcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ struct Options {
312312
files: Vec<PathBuf>,
313313
}
314314

315-
fn parse_command_line(config: clap::Command, args: impl uucore::Args) -> Result<Options> {
315+
fn parse_command_line(config: Command, args: impl uucore::Args) -> Result<Options> {
316316
let matches = config.try_get_matches_from(args)?;
317317

318318
let verbose = matches.get_flag(options::VERBOSE);

src/uu/chcon/src/fts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::ffi::{CStr, CString, OsStr};
88
use std::marker::PhantomData;
99
use std::os::raw::{c_int, c_long, c_short};
1010
use std::path::Path;
11-
use std::ptr::NonNull;
1211
use std::{io, iter, ptr, slice};
1312

1413
use crate::errors::{Error, Result};
@@ -71,7 +70,7 @@ impl FTS {
7170
// pointer assumed to be valid.
7271
let new_entry = unsafe { fts_sys::fts_read(self.fts.as_ptr()) };
7372

74-
self.entry = NonNull::new(new_entry);
73+
self.entry = ptr::NonNull::new(new_entry);
7574
if self.entry.is_none() {
7675
let r = io::Error::last_os_error();
7776
if let Some(0) = r.raw_os_error() {
@@ -161,7 +160,7 @@ impl<'fts> EntryRef<'fts> {
161160
return None;
162161
}
163162

164-
NonNull::new(entry.fts_path)
163+
ptr::NonNull::new(entry.fts_path)
165164
.map(|path_ptr| {
166165
let path_size = usize::from(entry.fts_pathlen).saturating_add(1);
167166

src/uu/cksum/src/cksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ pub fn uu_app() -> Command {
350350
.arg(
351351
Arg::new(options::FILE)
352352
.hide(true)
353-
.action(clap::ArgAction::Append)
353+
.action(ArgAction::Append)
354354
.value_parser(ValueParser::os_string())
355355
.value_hint(clap::ValueHint::FilePath),
356356
)

src/uu/comm/src/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ impl OrderChecker {
118118
// Check if two files are identical by comparing their contents
119119
pub fn are_files_identical(path1: &str, path2: &str) -> io::Result<bool> {
120120
// First compare file sizes
121-
let metadata1 = std::fs::metadata(path1)?;
122-
let metadata2 = std::fs::metadata(path2)?;
121+
let metadata1 = metadata(path1)?;
122+
let metadata2 = metadata(path2)?;
123123

124124
if metadata1.len() != metadata2.len() {
125125
return Ok(false);

src/uu/cp/src/copydir.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct Context<'a> {
101101
}
102102

103103
impl<'a> Context<'a> {
104-
fn new(root: &'a Path, target: &'a Path) -> std::io::Result<Self> {
104+
fn new(root: &'a Path, target: &'a Path) -> io::Result<Self> {
105105
let current_dir = env::current_dir()?;
106106
let root_path = current_dir.join(root);
107107
let root_parent = if target.exists() && !root.to_str().unwrap().ends_with("/.") {
@@ -181,7 +181,7 @@ impl Entry {
181181
if no_target_dir {
182182
let source_is_dir = source.is_dir();
183183
if path_ends_with_terminator(context.target) && source_is_dir {
184-
if let Err(e) = std::fs::create_dir_all(context.target) {
184+
if let Err(e) = fs::create_dir_all(context.target) {
185185
eprintln!("Failed to create directory: {e}");
186186
}
187187
} else {
@@ -305,9 +305,7 @@ fn copy_direntry(
305305
false,
306306
) {
307307
Ok(_) => {}
308-
Err(Error::IoErrContext(e, _))
309-
if e.kind() == std::io::ErrorKind::PermissionDenied =>
310-
{
308+
Err(Error::IoErrContext(e, _)) if e.kind() == io::ErrorKind::PermissionDenied => {
311309
show!(uio_error!(
312310
e,
313311
"cannot open {} for reading",
@@ -580,14 +578,13 @@ fn build_dir(
580578
// we need to allow trivial casts here because some systems like linux have u32 constants in
581579
// in libc while others don't.
582580
#[allow(clippy::unnecessary_cast)]
583-
let mut excluded_perms =
584-
if matches!(options.attributes.ownership, crate::Preserve::Yes { .. }) {
585-
libc::S_IRWXG | libc::S_IRWXO // exclude rwx for group and other
586-
} else if matches!(options.attributes.mode, crate::Preserve::Yes { .. }) {
587-
libc::S_IWGRP | libc::S_IWOTH //exclude w for group and other
588-
} else {
589-
0
590-
} as u32;
581+
let mut excluded_perms = if matches!(options.attributes.ownership, Preserve::Yes { .. }) {
582+
libc::S_IRWXG | libc::S_IRWXO // exclude rwx for group and other
583+
} else if matches!(options.attributes.mode, Preserve::Yes { .. }) {
584+
libc::S_IWGRP | libc::S_IWOTH //exclude w for group and other
585+
} else {
586+
0
587+
} as u32;
591588

592589
let umask = if copy_attributes_from.is_some()
593590
&& matches!(options.attributes.mode, Preserve::Yes { .. })

src/uu/cp/src/cp.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ pub fn uu_app() -> Command {
737737
Arg::new(options::PROGRESS_BAR)
738738
.long(options::PROGRESS_BAR)
739739
.short('g')
740-
.action(clap::ArgAction::SetTrue)
740+
.action(ArgAction::SetTrue)
741741
.help(
742742
"Display a progress bar. \n\
743743
Note: this feature is not supported by GNU coreutils.",
@@ -2081,7 +2081,7 @@ fn handle_copy_mode(
20812081
CopyMode::Update => {
20822082
if dest.exists() {
20832083
match options.update {
2084-
update_control::UpdateMode::ReplaceAll => {
2084+
UpdateMode::ReplaceAll => {
20852085
copy_helper(
20862086
source,
20872087
dest,
@@ -2094,17 +2094,17 @@ fn handle_copy_mode(
20942094
source_is_stream,
20952095
)?;
20962096
}
2097-
update_control::UpdateMode::ReplaceNone => {
2097+
UpdateMode::ReplaceNone => {
20982098
if options.debug {
20992099
println!("skipped {}", dest.quote());
21002100
}
21012101

21022102
return Ok(PerformedAction::Skipped);
21032103
}
2104-
update_control::UpdateMode::ReplaceNoneFail => {
2104+
UpdateMode::ReplaceNoneFail => {
21052105
return Err(Error::Error(format!("not replacing '{}'", dest.display())));
21062106
}
2107-
update_control::UpdateMode::ReplaceIfOlder => {
2107+
UpdateMode::ReplaceIfOlder => {
21082108
let dest_metadata = fs::symlink_metadata(dest)?;
21092109

21102110
let src_time = source_metadata.modified()?;
@@ -2335,7 +2335,7 @@ fn copy_file(
23352335
&FileInformation::from_path(source, options.dereference(source_in_command_line))
23362336
.context(format!("cannot stat {}", source.quote()))?,
23372337
) {
2338-
std::fs::hard_link(new_source, dest)?;
2338+
fs::hard_link(new_source, dest)?;
23392339

23402340
if options.verbose {
23412341
print_verbose_output(options.parents, progress_bar, source, dest);

0 commit comments

Comments
 (0)