Re-enable unused_qualifications lint (#10571)

This commit is contained in:
✿ Fleur de Blue
2026-02-04 04:55:21 +08:00
committed by GitHub
parent a3eab5cc98
commit 2a2cafdbd4
51 changed files with 157 additions and 185 deletions
+2
View File
@@ -21,3 +21,5 @@ lib*.a
### direnv ###
/.direnv/
*.code-workspace
+1 -1
View File
@@ -641,7 +641,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(fuzzing)',
'cfg(target_os, values("cygwin"))',
] }
#unused_qualifications = "warn" // TODO: fix warnings in uucore, then re-enable this lint
unused_qualifications = "warn"
[workspace.lints.clippy]
# The counts were generated with this command:
+1 -1
View File
@@ -66,7 +66,7 @@ pub fn main() {
\n\
#[allow(clippy::too_many_lines)]
#[allow(clippy::unreadable_literal)]
fn util_map<T: uucore::Args>() -> UtilityMap<T> {\n"
fn util_map<T: Args>() -> UtilityMap<T> {\n"
.as_bytes(),
)
.unwrap();
+1
View File
@@ -10,6 +10,7 @@ use std::cmp;
use std::ffi::OsString;
use std::io::{self, Write};
use std::process;
use uucore::Args;
const VERSION: &str = env!("CARGO_PKG_VERSION");
+7 -7
View File
@@ -45,8 +45,8 @@ fn usage<T: Args>(utils: &UtilityMap<T>) {
}
/// Generates the coreutils app for the utility map
fn gen_coreutils_app<T: Args>(util_map: &UtilityMap<T>) -> clap::Command {
let mut command = clap::Command::new("coreutils");
fn gen_coreutils_app<T: Args>(util_map: &UtilityMap<T>) -> Command {
let mut command = Command::new("coreutils");
for (name, (_, sub_app)) in util_map {
// Recreate a small subcommand with only the relevant info
// (name & short description)
@@ -54,7 +54,7 @@ fn gen_coreutils_app<T: Args>(util_map: &UtilityMap<T>) -> clap::Command {
.get_about()
.expect("Could not get the 'about'")
.to_string();
let sub_app = clap::Command::new(name).about(about);
let sub_app = Command::new(name).about(about);
command = command.subcommand(sub_app);
}
command
@@ -172,7 +172,7 @@ fn main() -> io::Result<()> {
}
let utils = util_map::<Box<dyn Iterator<Item = OsString>>>();
match std::fs::create_dir("docs/src/utils/") {
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => Ok(()),
Err(e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
x => x,
}?;
@@ -202,7 +202,7 @@ fn main() -> io::Result<()> {
let mut map = HashMap::new();
for platform in ["unix", "macos", "windows", "unix_android"] {
let platform_utils: Vec<String> = String::from_utf8(
std::process::Command::new("./util/show-utils.sh")
process::Command::new("./util/show-utils.sh")
.arg(format!("--features=feat_os_{platform}"))
.output()?
.stdout,
@@ -217,7 +217,7 @@ fn main() -> io::Result<()> {
// Linux is a special case because it can support selinux
let platform_utils: Vec<String> = String::from_utf8(
std::process::Command::new("./util/show-utils.sh")
process::Command::new("./util/show-utils.sh")
.arg("--features=feat_os_unix feat_selinux")
.output()?
.stdout,
@@ -547,7 +547,7 @@ fn write_zip_examples(
};
match format_examples(content, output_markdown) {
Err(e) => Err(std::io::Error::other(format!(
Err(e) => Err(io::Error::other(format!(
"Failed to format the tldr examples of {name}: {e}"
))),
Ok(s) => Ok(s),
+1 -1
View File
@@ -925,7 +925,7 @@ fn format_read_error(error: &io::Error) -> String {
/// Determines if the input buffer contains any padding ('=') ignoring trailing whitespace.
#[cfg(test)]
fn read_and_has_padding<R: std::io::Read>(input: &mut R) -> UResult<(bool, Vec<u8>)> {
fn read_and_has_padding<R: io::Read>(input: &mut R) -> UResult<(bool, Vec<u8>)> {
let mut buf = Vec::new();
input
.read_to_end(&mut buf)
+2 -2
View File
@@ -17,7 +17,7 @@ use crate::bufferedoutput::BufferedOutput;
use blocks::conv_block_unblock_helper;
use datastructures::*;
#[cfg(any(target_os = "linux", target_os = "android"))]
use nix::fcntl::FcntlArg::F_SETFL;
use nix::fcntl::FcntlArg;
#[cfg(any(target_os = "linux", target_os = "android"))]
use nix::fcntl::OFlag;
use parseargs::Parser;
@@ -897,7 +897,7 @@ impl<'a> Output<'a> {
if let Some(libc_flags) = make_linux_oflags(&settings.oflags) {
nix::fcntl::fcntl(
fx.as_raw().as_fd(),
F_SETFL(OFlag::from_bits_retain(libc_flags)),
FcntlArg::F_SETFL(OFlag::from_bits_retain(libc_flags)),
)?;
}
+2 -4
View File
@@ -1027,11 +1027,9 @@ where
// Set environment variable to communicate to Rust child processes
// that SIGPIPE should be default (not ignored)
if matches!(action_kind, SignalActionKind::Default)
&& sig_value == nix::libc::SIGPIPE as usize
{
if matches!(action_kind, SignalActionKind::Default) && sig_value == libc::SIGPIPE as usize {
unsafe {
std::env::set_var("RUST_SIGPIPE", "default");
env::set_var("RUST_SIGPIPE", "default");
}
}
+1 -1
View File
@@ -514,7 +514,7 @@ fn process_utf8_chars<W: Write>(line: &str, ctx: &mut FoldContext<'_, W>) -> URe
// not coalesce zero-width scalars there.
if ctx.mode == WidthMode::Columns {
while let Some(&(_, next_ch)) = iter.peek() {
if unicode_width::UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 {
if UnicodeWidthChar::width(next_ch).unwrap_or(1) == 0 {
iter.next();
} else {
break;
+2 -2
View File
@@ -478,7 +478,7 @@ impl<'a> StyleManager<'a> {
}
#[cfg(unix)]
fn indicator_for_special_file(&self, file_type: &std::fs::FileType) -> Option<Indicator> {
fn indicator_for_special_file(&self, file_type: &fs::FileType) -> Option<Indicator> {
if file_type.is_fifo() && self.has_indicator_style(Indicator::FIFO) {
return Some(Indicator::FIFO);
}
@@ -495,7 +495,7 @@ impl<'a> StyleManager<'a> {
}
#[cfg(not(unix))]
fn indicator_for_special_file(&self, _file_type: &std::fs::FileType) -> Option<Indicator> {
fn indicator_for_special_file(&self, _file_type: &fs::FileType) -> Option<Indicator> {
None
}
+1 -1
View File
@@ -3574,7 +3574,7 @@ fn get_security_context<'a>(
// For SMACK, use the path to get the label
// If must_dereference is true, we follow the symlink
let target_path = if must_dereference {
std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf())
fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf())
} else {
path.to_path_buf()
};
+1 -3
View File
@@ -88,9 +88,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let set_security_context = matches.get_flag(options::SECURITY_CONTEXT);
let context = matches.get_one::<String>(options::CONTEXT);
if set_security_context || context.is_some() {
uucore::smack::set_smack_label_and_cleanup(&f, context, |p| {
std::fs::remove_file(p)
})?;
uucore::smack::set_smack_label_and_cleanup(&f, context, |p| fs::remove_file(p))?;
}
}
}
+2 -2
View File
@@ -431,7 +431,7 @@ fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()>
OverwriteMode::Force => {}
OverwriteMode::Default => {
let (writable, mode) = is_writable(target);
if !writable && std::io::stdin().is_terminal() {
if !writable && io::stdin().is_terminal() {
prompt_overwrite(target, mode)?;
}
}
@@ -741,7 +741,7 @@ fn rename(
OverwriteMode::Default => {
// GNU mv prompts when stdin is a TTY and target is not writable
let (writable, mode) = is_writable(to);
if !writable && std::io::stdin().is_terminal() {
if !writable && io::stdin().is_terminal() {
prompt_overwrite(to, mode)?;
}
}
+1 -1
View File
@@ -591,7 +591,7 @@ fn extract_strings_from_input(
// Apply skip_bytes by reading and discarding
let mut skipped = 0u64;
while skipped < skip_bytes {
let to_skip = std::cmp::min(8192, skip_bytes - skipped);
let to_skip = cmp::min(8192, skip_bytes - skipped);
let mut skip_buf = vec![0u8; to_skip as usize];
match mf.read(&mut skip_buf) {
Ok(0) => break, // EOF reached
+1 -1
View File
@@ -72,7 +72,7 @@ fn verbose_removed_directory(path: &Path, options: &Options) {
}
/// Helper function to show error with context and return error status
fn show_removal_error(error: std::io::Error, path: &Path) -> bool {
fn show_removal_error(error: io::Error, path: &Path) -> bool {
if error.kind() == io::ErrorKind::PermissionDenied {
show_error!("cannot remove {}: Permission denied", path.quote());
} else {
+1 -1
View File
@@ -67,7 +67,7 @@ impl SeededRng {
hasher.update(seed.as_bytes());
let seed = hasher.finalize();
let seed = seed.as_slice().try_into().unwrap();
Self(Box::new(rand_chacha::ChaCha12Rng::from_seed(seed)))
Self(Box::new(ChaCha12Rng::from_seed(seed)))
}
#[allow(clippy::many_single_char_names)] // use original lemire names for easy comparison
+7 -7
View File
@@ -7,7 +7,7 @@
use std::ffi::{OsStr, OsString};
use std::fs::File;
use std::io::{BufReader, BufWriter, Error, Read, Write, stdin, stdout};
use std::io::{self, BufReader, BufWriter, Read, Write, stdin, stdout};
use std::ops::RangeInclusive;
use std::path::{Path, PathBuf};
use std::str::FromStr;
@@ -149,7 +149,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|| translate!("shuf-error-failed-to-open-random-source", "file" => r.quote()),
)?;
let file = BufReader::new(file);
WrappedRng::File(compat_random_source::RandomSourceAdapter::new(file))
WrappedRng::File(RandomSourceAdapter::new(file))
}
};
@@ -362,24 +362,24 @@ impl Shufable for RangeInclusive<u64> {
}
trait Writable {
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), Error>;
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), io::Error>;
}
impl Writable for &[u8] {
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), Error> {
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), io::Error> {
output.write_all(self)
}
}
impl Writable for &OsStr {
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), Error> {
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), io::Error> {
output.write_all_os(self)
}
}
impl Writable for u64 {
#[inline]
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), Error> {
fn write_all_to(&self, output: &mut impl OsWrite) -> Result<(), io::Error> {
// The itoa crate is surprisingly much more efficient than a formatted write.
// It speeds up `shuf -r -n1000000 -i1-1024` by 1.8×.
let mut buf = itoa::Buffer::new();
@@ -389,7 +389,7 @@ impl Writable for u64 {
#[cold]
#[inline(never)]
fn handle_write_error(e: std::io::Error) -> Box<dyn uucore::error::UError> {
fn handle_write_error(e: io::Error) -> Box<dyn uucore::error::UError> {
use uucore::error::FromIo;
let ctx = translate!("shuf-error-write-failed");
e.map_err_context(move || ctx)
+6 -10
View File
@@ -6,10 +6,6 @@
//! Heuristics for determining buffer size for external sorting.
use std::ffi::OsString;
use crate::{
FALLBACK_AUTOMATIC_BUF_SIZE, MAX_AUTOMATIC_BUF_SIZE, MIN_AUTOMATIC_BUF_SIZE, STDIN_FILE,
};
// Heuristics to size the external sort buffer without overcommit memory.
pub(crate) fn automatic_buffer_size(files: &[OsString]) -> usize {
let file_hint = file_size_hint(files);
@@ -20,7 +16,7 @@ pub(crate) fn automatic_buffer_size(files: &[OsString]) -> usize {
(Some(file), Some(mem)) => file.min(mem),
(Some(file), None) => file,
(None, Some(mem)) => mem,
(None, None) => FALLBACK_AUTOMATIC_BUF_SIZE,
(None, None) => crate::FALLBACK_AUTOMATIC_BUF_SIZE,
}
}
@@ -29,7 +25,7 @@ fn file_size_hint(files: &[OsString]) -> Option<usize> {
let mut total_bytes: u128 = 0;
for file in files {
if file == STDIN_FILE {
if file == crate::STDIN_FILE {
continue;
}
@@ -43,7 +39,7 @@ fn file_size_hint(files: &[OsString]) -> Option<usize> {
total_bytes = total_bytes.saturating_add(metadata.len() as u128);
if total_bytes >= (MAX_AUTOMATIC_BUF_SIZE as u128) * 8 {
if total_bytes >= (crate::MAX_AUTOMATIC_BUF_SIZE as u128) * 8 {
break;
}
}
@@ -66,8 +62,8 @@ fn available_memory_hint() -> Option<usize> {
}
fn clamp_hint(bytes: u128) -> usize {
let min = MIN_AUTOMATIC_BUF_SIZE as u128;
let max = MAX_AUTOMATIC_BUF_SIZE as u128;
let min = crate::MIN_AUTOMATIC_BUF_SIZE as u128;
let max = crate::MAX_AUTOMATIC_BUF_SIZE as u128;
let clamped = bytes.clamp(min, max);
clamped.min(usize::MAX as u128) as usize
}
@@ -77,7 +73,7 @@ fn desired_file_buffer_bytes(total_bytes: u128) -> u128 {
return 0;
}
let max = MAX_AUTOMATIC_BUF_SIZE as u128;
let max = crate::MAX_AUTOMATIC_BUF_SIZE as u128;
if total_bytes <= max {
return total_bytes.saturating_mul(12).clamp(total_bytes, max);
+1 -1
View File
@@ -24,7 +24,7 @@ use crate::{
};
const MAX_TOKEN_BUFFER_BYTES: usize = 4 * 1024 * 1024;
const MAX_TOKEN_BUFFER_ELEMS: usize = MAX_TOKEN_BUFFER_BYTES / std::mem::size_of::<Range<usize>>();
const MAX_TOKEN_BUFFER_ELEMS: usize = MAX_TOKEN_BUFFER_BYTES / size_of::<Range<usize>>();
self_cell!(
/// The chunk that is passed around between threads.
+1 -1
View File
@@ -2306,7 +2306,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// Initialize locale collation if needed (UTF-8 locales)
// This MUST happen before init_precomputed() to avoid the performance regression
#[cfg(feature = "i18n-collator")]
let needs_locale_collation = uucore::i18n::collator::init_locale_collation();
let needs_locale_collation = i18n::collator::init_locale_collation();
#[cfg(not(feature = "i18n-collator"))]
let needs_locale_collation = false;

Some files were not shown because too many files have changed in this diff Show More