8000 clippy: fix warnings introduced by Rust 1.71.0 by cakebaker · Pull Request #5079 · uutils/coreutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

clippy: fix warnings introduced by Rust 1.71.0 #5079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 103 additions & 103 deletions src/uu/csplit/src/csplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion src/uu/fmt/src/parasplit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
};
Expand Down
2 changes: 1 addition & 1 deletion src/uu/stdbuf/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
15 changes: 5 additions & 10 deletions src/uucore/src/lib/features/fsext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Scif;

impl Scif {
pub fn new() -> Self {
Self::default()
Self
}
}
impl Formatter for Scif {
Expand Down
4 changes: 2 additions & 2 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!();
Expand Down
6 changes: 3 additions & 3 deletions tests/by-util/test_stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
0