Run cargo fmt on the tree

This commit is contained in:
Sylvestre Ledru
2025-03-24 21:04:32 +01:00
parent 36dd968c9a
commit a85539f530
189 changed files with 841 additions and 782 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ pub fn main() {
match krate.as_ref() {
"default" | "macos" | "unix" | "windows" | "selinux" | "zip" => continue, // common/standard feature names
"nightly" | "test_unimplemented" | "expensive_tests" | "test_risky_names" => {
continue
continue;
} // crate-local custom features
"uudoc" => continue, // is not a utility
"test" => continue, // over-ridden with 'uu_test' to avoid collision with rust core crate 'test'
+3 -1
View File
@@ -23,7 +23,9 @@ fn main() -> io::Result<()> {
if tldr_zip.is_none() {
println!("Warning: No tldr archive found, so the documentation will not include examples.");
println!("To include examples in the documentation, download the tldr archive and put it in the docs/ folder.");
println!(
"To include examples in the documentation, download the tldr archive and put it in the docs/ folder."
);
println!();
println!(" curl https://tldr.sh/assets/tldr.zip -o docs/tldr.zip");
println!();
+3 -3
View File
@@ -11,8 +11,8 @@ use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use uucore::display::Quotable;
use uucore::encoding::{
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64URL, BASE64_NOPAD, HEXUPPER_PERMISSIVE},
Format, Z85Wrapper, BASE2LSBF, BASE2MSBF,
BASE2LSBF, BASE2MSBF, Format, Z85Wrapper,
for_base_common::{BASE32, BASE32HEX, BASE64, BASE64_NOPAD, BASE64URL, HEXUPPER_PERMISSIVE},
};
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
@@ -291,7 +291,7 @@ pub fn get_supports_fast_decode_and_encode(
}
pub mod fast_encode {
use crate::base_common::{format_read_error, WRAP_DEFAULT};
use crate::base_common::{WRAP_DEFAULT, format_read_error};
use std::{
collections::VecDeque,
io::{self, ErrorKind, Read, Write},
+1 -1
View File
@@ -6,7 +6,7 @@
// spell-checker:ignore (ToDO) fullname
use clap::{Arg, ArgAction, Command};
use std::path::{is_separator, PathBuf};
use std::path::{PathBuf, is_separator};
use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError};
use uucore::line_ending::LineEnding;
+1 -1
View File
@@ -6,7 +6,7 @@
// spell-checker:ignore lsbf msbf
use clap::{Arg, ArgAction, Command};
use uu_base32::base_common::{self, Config, BASE_CMD_PARSE_ERROR};
use uu_base32::base_common::{self, BASE_CMD_PARSE_ERROR, Config};
use uucore::error::UClapError;
use uucore::{
encoding::Format,
+5 -13
View File
@@ -4,7 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore (ToDO) nonprint nonblank nonprinting ELOOP
use std::fs::{metadata, File};
use std::fs::{File, metadata};
use std::io::{self, BufWriter, IsTerminal, Read, Write};
/// Unix domain socket support
#[cfg(unix)]
@@ -18,7 +18,7 @@ use std::os::unix::net::UnixStream;
use clap::{Arg, ArgAction, Command};
#[cfg(unix)]
use nix::fcntl::{fcntl, FcntlArg};
use nix::fcntl::{FcntlArg, fcntl};
use thiserror::Error;
use uucore::display::Quotable;
use uucore::error::UResult;
@@ -83,19 +83,11 @@ struct OutputOptions {
impl OutputOptions {
fn tab(&self) -> &'static str {
if self.show_tabs {
"^I"
} else {
"\t"
}
if self.show_tabs { "^I" } else { "\t" }
}
fn end_of_line(&self) -> &'static str {
if self.show_ends {
"$\n"
} else {
"\n"
}
if self.show_ends { "$\n" } else { "\n" }
}
/// We can write fast if we can simply copy the contents of the file to
@@ -694,7 +686,7 @@ fn write_end_of_line<W: Write>(
#[cfg(test)]
mod tests {
use std::io::{stdout, BufWriter};
use std::io::{BufWriter, stdout};
#[test]
fn test_write_nonprint_to_end_new_line() {
+2 -2
View File
@@ -8,7 +8,7 @@
use uucore::display::Quotable;
pub use uucore::entries;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::perms::{chown_base, options, GidUidOwnerFilter, IfFrom};
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
use uucore::{format_usage, help_about, help_usage};
use clap::{Arg, ArgAction, ArgMatches, Command};
@@ -76,7 +76,7 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
return Err(USimpleError::new(
1,
format!("invalid user: '{}'", from_group),
))
));
}
}
} else {
+4 -4
View File
@@ -11,12 +11,12 @@ use std::fs;
use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, ExitCode, UResult, USimpleError, UUsageError};
use uucore::error::{ExitCode, UResult, USimpleError, UUsageError, set_exit_code};
use uucore::fs::display_permissions_unix;
use uucore::libc::mode_t;
#[cfg(not(windows))]
use uucore::mode;
use uucore::perms::{configure_symlink_and_recursion, TraverseSymlinks};
use uucore::perms::{TraverseSymlinks, configure_symlink_and_recursion};
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
const ABOUT: &str = help_about!("chmod.md");
@@ -107,7 +107,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
return Err(USimpleError::new(
1,
format!("cannot stat attributes of {}: {}", fref.quote(), err),
))
));
}
},
None => None,
@@ -298,7 +298,7 @@ impl Chmoder {
format!(
"it is dangerous to operate recursively on {}\nchmod: use --no-preserve-root to override this failsafe",
filename.quote()
)
),
));
}
if self.recursive {
+1 -1
View File
@@ -7,7 +7,7 @@
use uucore::display::Quotable;
pub use uucore::entries::{self, Group, Locate, Passwd};
use uucore::perms::{chown_base, options, GidUidOwnerFilter, IfFrom};
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
use uucore::{format_usage, help_about, help_usage};
use uucore::error::{FromIo, UResult, USimpleError};
+4 -4
View File
@@ -13,9 +13,9 @@ use std::io::Error;
use std::os::unix::prelude::OsStrExt;
use std::path::{Path, PathBuf};
use std::process;
use uucore::entries::{grp2gid, usr2uid, Locate, Passwd};
use uucore::error::{set_exit_code, UClapError, UResult, UUsageError};
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
use uucore::entries::{Locate, Passwd, grp2gid, usr2uid};
use uucore::error::{UClapError, UResult, UUsageError, set_exit_code};
use uucore::fs::{MissingHandling, ResolveMode, canonicalize};
use uucore::libc::{self, chroot, setgid, setgroups, setuid};
use uucore::{format_usage, help_about, help_usage, show};
@@ -224,7 +224,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} else {
ChrootError::CommandFailed(command[0].to_string(), e)
}
.into())
.into());
}
};
+6 -6
View File
@@ -5,17 +5,17 @@
// spell-checker:ignore (ToDO) fname, algo
use clap::builder::ValueParser;
use clap::{value_parser, Arg, ArgAction, Command};
use clap::{Arg, ArgAction, Command, value_parser};
use std::ffi::{OsStr, OsString};
use std::fs::File;
use std::io::{self, stdin, stdout, BufReader, Read, Write};
use std::io::{self, BufReader, Read, Write, stdin, stdout};
use std::iter;
use std::path::Path;
use uucore::checksum::{
calculate_blake2b_length, detect_algo, digest_reader, perform_checksum_validation,
ChecksumError, ChecksumOptions, ChecksumVerbose, ALGORITHM_OPTIONS_BLAKE2B,
ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC, ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV,
SUPPORTED_ALGORITHMS,
ALGORITHM_OPTIONS_BLAKE2B, ALGORITHM_OPTIONS_BSD, ALGORITHM_OPTIONS_CRC,
ALGORITHM_OPTIONS_CRC32B, ALGORITHM_OPTIONS_SYSV, ChecksumError, ChecksumOptions,
ChecksumVerbose, SUPPORTED_ALGORITHMS, calculate_blake2b_length, detect_algo, digest_reader,
perform_checksum_validation,
};
use uucore::{
encoding,
+2 -2
View File
@@ -6,8 +6,8 @@
// spell-checker:ignore (ToDO) delim mkdelim pairable
use std::cmp::Ordering;
use std::fs::{metadata, File};
use std::io::{self, stdin, BufRead, BufReader, Read, Stdin};
use std::fs::{File, metadata};
use std::io::{self, BufRead, BufReader, Read, Stdin, stdin};
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::fs::paths_refer_to_same_file;
use uucore::line_ending::LineEnding;
+3 -3
View File
@@ -18,7 +18,7 @@ use indicatif::ProgressBar;
use uucore::display::Quotable;
use uucore::error::UIoError;
use uucore::fs::{
canonicalize, path_ends_with_terminator, FileInformation, MissingHandling, ResolveMode,
FileInformation, MissingHandling, ResolveMode, canonicalize, path_ends_with_terminator,
};
use uucore::show;
use uucore::show_error;
@@ -26,8 +26,8 @@ use uucore::uio_error;
use walkdir::{DirEntry, WalkDir};
use crate::{
aligned_ancestors, context_for, copy_attributes, copy_file, copy_link, CopyResult, Error,
Options,
CopyResult, Error, Options, aligned_ancestors, context_for, copy_attributes, copy_file,
copy_link,
};
/// Ensure a Windows path starts with a `\\?`.
+8 -8
View File
@@ -20,7 +20,7 @@ use std::path::{Path, PathBuf, StripPrefixError};
#[cfg(all(unix, not(target_os = "android")))]
use uucore::fsxattr::copy_xattrs;
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
use filetime::FileTime;
use indicatif::{ProgressBar, ProgressStyle};
#[cfg(unix)]
@@ -29,11 +29,11 @@ use quick_error::ResultExt;
use platform::copy_on_write;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, UClapError, UError, UResult, UUsageError};
use uucore::error::{UClapError, UError, UResult, UUsageError, set_exit_code};
use uucore::fs::{
are_hardlinks_to_same_file, canonicalize, get_filename, is_symlink_loop, normalize_path,
path_ends_with_terminator, paths_refer_to_same_file, FileInformation, MissingHandling,
ResolveMode,
FileInformation, MissingHandling, ResolveMode, are_hardlinks_to_same_file, canonicalize,
get_filename, is_symlink_loop, normalize_path, path_ends_with_terminator,
paths_refer_to_same_file,
};
use uucore::{backup_control, update_control};
// These are exposed for projects (e.g. nushell) that want to create an `Options` value, which
@@ -1498,7 +1498,7 @@ fn file_mode_for_interactive_overwrite(
{
#[cfg(unix)]
{
use libc::{mode_t, S_IWUSR};
use libc::{S_IWUSR, mode_t};
use std::os::unix::prelude::MetadataExt;
match path.metadata() {
@@ -1631,9 +1631,9 @@ pub(crate) fn copy_attributes(
#[cfg(unix)]
handle_preserve(&attributes.ownership, || -> CopyResult<()> {
use std::os::unix::prelude::MetadataExt;
use uucore::perms::wrap_chown;
use uucore::perms::Verbosity;
use uucore::perms::VerbosityLevel;
use uucore::perms::wrap_chown;
let dest_uid = source_metadata.uid();
let dest_gid = source_metadata.gid();
@@ -2627,7 +2627,7 @@ fn disk_usage_directory(p: &Path) -> io::Result<u64> {
#[cfg(test)]
mod tests {
use crate::{aligned_ancestors, localize_to_target, Attributes, Preserve};
use crate::{Attributes, Preserve, aligned_ancestors, localize_to_target};
use std::path::Path;
#[test]
+4 -4
View File
@@ -340,7 +340,7 @@ pub(crate) fn copy_on_write(
}
(ReflinkMode::Auto, SparseMode::Always) => {
copy_debug.sparse_detection = SparseDebug::Zeros; // Default SparseDebug val for
// SparseMode::Always
// SparseMode::Always
if source_is_stream {
copy_debug.offload = OffloadReflinkDebug::Avoided;
copy_stream(source, dest, source_is_fifo).map(|_| ())
@@ -401,7 +401,7 @@ pub(crate) fn copy_on_write(
clone(source, dest, CloneFallback::Error)
}
(ReflinkMode::Always, _) => {
return Err("`--reflink=always` can be used only with --sparse=auto".into())
return Err("`--reflink=always` can be used only with --sparse=auto".into());
}
};
result.context(context)?;
@@ -524,7 +524,7 @@ fn handle_reflink_auto_sparse_auto(
} else {
copy_method = CopyMethod::SparseCopyWithoutHole;
} // Since sparse_flag is true, sparse_detection shall be SeekHole for any non virtual
// regular sparse file and the file will be sparsely copied
// regular sparse file and the file will be sparsely copied
copy_debug.sparse_detection = SparseDebug::SeekHole;
}
@@ -557,7 +557,7 @@ fn handle_reflink_never_sparse_auto(
if sparse_flag {
if blocks == 0 && data_flag {
copy_method = CopyMethod::FSCopy; // Handles virtual files which have size > 0 but no
// disk allocation
// disk allocation
} else {
copy_method = CopyMethod::SparseCopyWithoutHole; // Handles regular sparse-files
}
+1 -1
View File
@@ -84,7 +84,7 @@ pub(crate) fn copy_on_write(
// support COW).
match reflink_mode {
ReflinkMode::Always => {
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into())
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into());
}
_ => {
copy_debug.reflink = OffloadReflinkDebug::Yes;
+1 -1
View File
@@ -8,7 +8,7 @@
use std::cmp::Ordering;
use std::io::{self, BufReader};
use std::{
fs::{remove_file, File},
fs::{File, remove_file},
io::{BufRead, BufWriter, Write},
};
+1 -1
View File
@@ -4,7 +4,7 @@
// file that was distributed with this source code.
// spell-checker:ignore (regex) diuox
use uucore::format::{num_format::UnsignedInt, Format, FormatError};
use uucore::format::{Format, FormatError, num_format::UnsignedInt};
use crate::csplit_error::CsplitError;
+14 -12
View File
@@ -6,13 +6,13 @@
// spell-checker:ignore (ToDO) delim sourcefiles
use bstr::io::BufReadExt;
use clap::{builder::ValueParser, Arg, ArgAction, ArgMatches, Command};
use clap::{Arg, ArgAction, ArgMatches, Command, builder::ValueParser};
use std::ffi::OsString;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, IsTerminal, Read, Write};
use std::io::{BufRead, BufReader, BufWriter, IsTerminal, Read, Write, stdin, stdout};
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
use uucore::error::{FromIo, UResult, USimpleError, set_exit_code};
use uucore::line_ending::LineEnding;
use uucore::os_str_as_bytes;
@@ -370,16 +370,18 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
continue;
}
show_if_err!(File::open(path)
.map_err_context(|| filename.maybe_quote().to_string())
.and_then(|file| {
match &mode {
Mode::Bytes(ranges, opts) | Mode::Characters(ranges, opts) => {
cut_bytes(file, ranges, opts)
show_if_err!(
File::open(path)
.map_err_context(|| filename.maybe_quote().to_string())
.and_then(|file| {
match &mode {
Mode::Bytes(ranges, opts) | Mode::Characters(ranges, opts) => {
cut_bytes(file, ranges, opts)
}
Mode::Fields(ranges, opts) => cut_fields(file, ranges, opts),
}
Mode::Fields(ranges, opts) => cut_fields(file, ranges, opts),
}
}));
})
);
}
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ use chrono::{DateTime, FixedOffset, Local, Offset, TimeDelta, Utc};
use chrono::{Datelike, Timelike};
use clap::{Arg, ArgAction, Command};
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "redox")))]
use libc::{clock_settime, timespec, CLOCK_REALTIME};
use libc::{CLOCK_REALTIME, clock_settime, timespec};
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;

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