mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +00:00
Merge pull request #5079 from cakebaker/clippy_fix_warnings_rust_1_71_0
clippy: fix warnings introduced by Rust 1.71.0
This commit is contained in:
commit
ec1d2fba33
9 changed files with 118 additions and 123 deletions
|
@ -552,6 +552,109 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
// get the file to split
|
||||
let file_name = matches.get_one::<String>(options::FILE).unwrap();
|
||||
|
||||
// get the patterns to split on
|
||||
let patterns: Vec<String> = matches
|
||||
.get_many::<String>(options::PATTERN)
|
||||
.unwrap()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
let patterns = patterns::get_patterns(&patterns[..])?;
|
||||
let options = CsplitOptions::new(&matches);
|
||||
if file_name == "-" {
|
||||
let stdin = io::stdin();
|
||||
Ok(csplit(&options, patterns, stdin.lock())?)
|
||||
} else {
|
||||
let file = File::open(file_name)
|
||||
.map_err_context(|| format!("cannot access {}", file_name.quote()))?;
|
||||
let file_metadata = file
|
||||
.metadata()
|
||||
.map_err_context(|| format!("cannot access {}", file_name.quote()))?;
|
||||
if !file_metadata.is_file() {
|
||||
return Err(CsplitError::NotRegularFile(file_name.to_string()).into());
|
||||
}
|
||||
Ok(csplit(&options, patterns, BufReader::new(file))?)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::SUFFIX_FORMAT)
|
||||
.short('b')
|
||||
.long(options::SUFFIX_FORMAT)
|
||||
.value_name("FORMAT")
|
||||
.help("use sprintf FORMAT instead of %02d"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PREFIX)
|
||||
.short('f')
|
||||
.long(options::PREFIX)
|
||||
.value_name("PREFIX")
|
||||
.help("use PREFIX instead of 'xx'"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::KEEP_FILES)
|
||||
.short('k')
|
||||
.long(options::KEEP_FILES)
|
||||
.help("do not remove output files on errors")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::SUPPRESS_MATCHED)
|
||||
.long(options::SUPPRESS_MATCHED)
|
||||
.help("suppress the lines matching PATTERN")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::DIGITS)
|
||||
.short('n')
|
||||
.long(options::DIGITS)
|
||||
.value_name("DIGITS")
|
||||
.help("use specified number of digits instead of 2"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::QUIET)
|
||||
.short('s')
|
||||
.long(options::QUIET)
|
||||
.visible_alias("silent")
|
||||
.help("do not print counts of output file sizes")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::ELIDE_EMPTY_FILES)
|
||||
.short('z')
|
||||
.long(options::ELIDE_EMPTY_FILES)
|
||||
.help("remove empty output files")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
.hide(true)
|
||||
.required(true)
|
||||
.value_hint(clap::ValueHint::FilePath),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PATTERN)
|
||||
.hide(true)
|
||||
.action(clap::ArgAction::Append)
|
||||
.required(true),
|
||||
)
|
||||
.after_help(AFTER_HELP)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -714,106 +817,3 @@ mod tests {
|
|||
assert!(input_splitter.next().is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[uucore::main]
|
||||
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||
let args = args.collect_ignore();
|
||||
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
// get the file to split
|
||||
let file_name = matches.get_one::<String>(options::FILE).unwrap();
|
||||
|
||||
// get the patterns to split on
|
||||
let patterns: Vec<String> = matches
|
||||
.get_many::<String>(options::PATTERN)
|
||||
.unwrap()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
let patterns = patterns::get_patterns(&patterns[..])?;
|
||||
let options = CsplitOptions::new(&matches);
|
||||
if file_name == "-" {
|
||||
let stdin = io::stdin();
|
||||
Ok(csplit(&options, patterns, stdin.lock())?)
|
||||
} else {
|
||||
let file = File::open(file_name)
|
||||
.map_err_context(|| format!("cannot access {}", file_name.quote()))?;
|
||||
let file_metadata = file
|
||||
.metadata()
|
||||
.map_err_context(|| format!("cannot access {}", file_name.quote()))?;
|
||||
if !file_metadata.is_file() {
|
||||
return Err(CsplitError::NotRegularFile(file_name.to_string()).into());
|
||||
}
|
||||
Ok(csplit(&options, patterns, BufReader::new(file))?)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn uu_app() -> Command {
|
||||
Command::new(uucore::util_name())
|
||||
.version(crate_version!())
|
||||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.arg(
|
||||
Arg::new(options::SUFFIX_FORMAT)
|
||||
.short('b')
|
||||
.long(options::SUFFIX_FORMAT)
|
||||
.value_name("FORMAT")
|
||||
.help("use sprintf FORMAT instead of %02d"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PREFIX)
|
||||
.short('f')
|
||||
.long(options::PREFIX)
|
||||
.value_name("PREFIX")
|
||||
.help("use PREFIX instead of 'xx'"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::KEEP_FILES)
|
||||
.short('k')
|
||||
.long(options::KEEP_FILES)
|
||||
.help("do not remove output files on errors")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::SUPPRESS_MATCHED)
|
||||
.long(options::SUPPRESS_MATCHED)
|
||||
.help("suppress the lines matching PATTERN")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::DIGITS)
|
||||
.short('n')
|
||||
.long(options::DIGITS)
|
||||
.value_name("DIGITS")
|
||||
.help("use specified number of digits instead of 2"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::QUIET)
|
||||
.short('s')
|
||||
.long(options::QUIET)
|
||||
.visible_alias("silent")
|
||||
.help("do not print counts of output file sizes")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::ELIDE_EMPTY_FILES)
|
||||
.short('z')
|
||||
.long(options::ELIDE_EMPTY_FILES)
|
||||
.help("remove empty output files")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::FILE)
|
||||
.hide(true)
|
||||
.required(true)
|
||||
.value_hint(clap::ValueHint::FilePath),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PATTERN)
|
||||
.hide(true)
|
||||
.action(clap::ArgAction::Append)
|
||||
.required(true),
|
||||
)
|
||||
.after_help(AFTER_HELP)
|
||||
}
|
||||
|
|
|
@ -598,7 +598,7 @@ impl<'a> Iterator for WordSplit<'a> {
|
|||
self.prev_punct && (before_tab.is_some() || word_start_relative > 1);
|
||||
|
||||
// now record whether this word ends in punctuation
|
||||
self.prev_punct = match self.string[..self.position].chars().rev().next() {
|
||||
self.prev_punct = match self.string[..self.position].chars().next_back() {
|
||||
Some(ch) => WordSplit::is_punctuation(ch),
|
||||
_ => panic!("fatal: expected word not to be empty"),
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ mod platform {
|
|||
pub const DYLIB_EXT: &str = ".so";
|
||||
}
|
||||
|
||||
#[cfg(any(target_vendor = "apple"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
mod platform {
|
||||
pub const DYLIB_EXT: &str = ".dylib";
|
||||
}
|
||||
|
|
|
@ -194,15 +194,10 @@ impl MountInfo {
|
|||
}
|
||||
#[cfg(unix)]
|
||||
{
|
||||
if self.dev_name.find(':').is_some()
|
||||
self.remote = self.dev_name.find(':').is_some()
|
||||
|| (self.dev_name.starts_with("//") && self.fs_type == "smbfs"
|
||||
|| self.fs_type == "cifs")
|
||||
|| self.dev_name == "-hosts"
|
||||
{
|
||||
self.remote = true;
|
||||
} else {
|
||||
self.remote = false;
|
||||
}
|
||||
|| self.dev_name == "-hosts";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,9 +366,9 @@ extern "C" {
|
|||
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
|
||||
|
||||
#[cfg(any(
|
||||
all(target_os = "freebsd"),
|
||||
all(target_os = "netbsd"),
|
||||
all(target_os = "openbsd"),
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
all(target_vendor = "apple", target_arch = "aarch64")
|
||||
))]
|
||||
#[link_name = "getmntinfo"] // spell-checker:disable-line
|
||||
|
|
|
@ -10,7 +10,7 @@ use super::float_common::{get_primitive_dec, primitive_to_str_common, FloatAnaly
|
|||
pub struct Floatf;
|
||||
impl Floatf {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
Self
|
||||
}
|
||||
}
|
||||
impl Formatter for Floatf {
|
||||
|
|
|
@ -10,7 +10,7 @@ pub struct Scif;
|
|||
|
||||
impl Scif {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
Self
|
||||
}
|
||||
}
|
||||
impl Formatter for Scif {
|
||||
|
|
|
@ -1337,7 +1337,7 @@ fn test_cp_preserve_all_context_fails_on_non_selinux() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "android"))]
|
||||
#[cfg(target_os = "android")]
|
||||
fn test_cp_preserve_xattr_fails_on_android() {
|
||||
// Because of the SELinux extended attributes used on Android, trying to copy extended
|
||||
// attributes has to fail in this case, since we specify `--preserve=xattr` and this puts it
|
||||
|
@ -2768,7 +2768,7 @@ fn test_same_file_force() {
|
|||
}
|
||||
|
||||
/// Test that copying file to itself with forced backup succeeds.
|
||||
#[cfg(all(not(windows)))]
|
||||
#[cfg(not(windows))]
|
||||
#[test]
|
||||
fn test_same_file_force_backup() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
|
|
@ -178,7 +178,7 @@ fn test_char() {
|
|||
DEV_FORMAT_STR,
|
||||
#[cfg(target_os = "linux")]
|
||||
"/dev/pts/ptmx",
|
||||
#[cfg(any(target_vendor = "apple"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
"%a %A %b %B %d %D %f %F %g %G %h %i %m %n %o %s (/%T) %u %U %W %X %y %Y %z %Z",
|
||||
#[cfg(any(target_os = "android", target_vendor = "apple"))]
|
||||
"/dev/ptmx",
|
||||
|
@ -198,7 +198,7 @@ fn test_date() {
|
|||
"%z",
|
||||
#[cfg(target_os = "linux")]
|
||||
"/bin/sh",
|
||||
#[cfg(any(target_vendor = "apple"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
"%z",
|
||||
#[cfg(any(target_os = "android", target_vendor = "apple"))]
|
||||
"/bin/sh",
|
||||
|
@ -213,7 +213,7 @@ fn test_date() {
|
|||
"%z",
|
||||
#[cfg(target_os = "linux")]
|
||||
"/dev/ptmx",
|
||||
#[cfg(any(target_vendor = "apple"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
"%z",
|
||||
#[cfg(any(target_os = "android", target_vendor = "apple"))]
|
||||
"/dev/ptmx",
|
||||
|
|
|
@ -145,7 +145,7 @@ fn test_stdin_redirect_offset() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(not(target_vendor = "apple")))] // FIXME: for currently not working platforms
|
||||
#[cfg(not(target_vendor = "apple"))] // FIXME: for currently not working platforms
|
||||
fn test_stdin_redirect_offset2() {
|
||||
// like test_stdin_redirect_offset but with multiple files
|
||||
|
||||
|
|
Loading…
Reference in a new issue