Skip to content
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ lib*.a

### direnv ###
/.direnv/

*.code-workspace
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/bin/coreutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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");

Expand Down
14 changes: 7 additions & 7 deletions src/bin/uudoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ 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)
let about = sub_app()
.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
Expand Down Expand Up @@ -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,
}?;

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/uu/base32/src/base_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -895,7 +895,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)),
)?;
}

Expand Down
6 changes: 2 additions & 4 deletions src/uu/env/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,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");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/fold/src/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/uu/ls/src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand Down
4 changes: 1 addition & 3 deletions src/uu/mkfifo/src/mkfifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))?;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
}
}
Expand Down Expand Up @@ -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)?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/od/src/od.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,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
Expand Down
2 changes: 1 addition & 1 deletion src/uu/rm/src/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/shuf/src/random_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/uu/shuf/src/shuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
}
};

Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down
16 changes: 6 additions & 10 deletions src/uu/sort/src/buffer_hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
}
}

Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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
}
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,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;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tail/src/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ fn tail_file(
/// After opening, we clear O_NONBLOCK so subsequent reads block normally.
/// Without `--pid`, FIFOs block on open() until a writer connects (GNU behavior).
#[cfg(unix)]
fn open_file(path: &Path, use_nonblock_for_fifo: bool) -> std::io::Result<File> {
fn open_file(path: &Path, use_nonblock_for_fifo: bool) -> io::Result<File> {
use nix::fcntl::{FcntlArg, OFlag, fcntl};
use std::fs::OpenOptions;
use std::os::fd::AsFd;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/timeout/src/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn install_sigchld() {
/// We should terminate child process when receiving termination signals.
static SIGNALED: AtomicBool = AtomicBool::new(false);
/// Track which signal was received (0 = none/timeout expired naturally).
static RECEIVED_SIGNAL: std::sync::atomic::AtomicI32 = std::sync::atomic::AtomicI32::new(0);
static RECEIVED_SIGNAL: atomic::AtomicI32 = atomic::AtomicI32::new(0);

/// Install signal handlers for termination signals.
fn install_signal_handlers(term_signal: usize) {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/tsort/src/tsort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ enum TsortError {

/// Wrapper for bubbling up IO errors
#[error("{0}")]
IO(#[from] std::io::Error),
IO(#[from] io::Error),
}

// Auxiliary struct, just for printing loop nodes via show! macro
Expand Down
Loading
Loading