diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index 24d089df4..31f0e9238 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -62,8 +62,8 @@ enum LineReader { impl LineReader { fn read_line(&mut self, buf: &mut String) -> io::Result { match *self { - LineReader::Stdin(ref mut r) => r.read_line(buf), - LineReader::FileIn(ref mut r) => r.read_line(buf), + Self::Stdin(ref mut r) => r.read_line(buf), + Self::FileIn(ref mut r) => r.read_line(buf), } } } diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs index d8520956d..b609657fb 100644 --- a/src/uu/cp/src/cp.rs +++ b/src/uu/cp/src/cp.rs @@ -1519,7 +1519,7 @@ fn copy_link( } dest.into() }; - symlink_file(&link, &dest, &*context_for(&link, &dest), symlinked_files) + symlink_file(&link, &dest, &context_for(&link, &dest), symlinked_files) } /// Copies `source` to `dest` using copy-on-write if possible. diff --git a/src/uu/csplit/src/patterns.rs b/src/uu/csplit/src/patterns.rs index 0346ed381..ee5852ee8 100644 --- a/src/uu/csplit/src/patterns.rs +++ b/src/uu/csplit/src/patterns.rs @@ -23,11 +23,11 @@ pub enum Pattern { impl ToString for Pattern { fn to_string(&self) -> String { match self { - Pattern::UpToLine(n, _) => n.to_string(), - Pattern::UpToMatch(regex, 0, _) => format!("/{}/", regex.as_str()), - Pattern::UpToMatch(regex, offset, _) => format!("/{}/{:+}", regex.as_str(), offset), - Pattern::SkipToMatch(regex, 0, _) => format!("%{}%", regex.as_str()), - Pattern::SkipToMatch(regex, offset, _) => format!("%{}%{:+}", regex.as_str(), offset), + Self::UpToLine(n, _) => n.to_string(), + Self::UpToMatch(regex, 0, _) => format!("/{}/", regex.as_str()), + Self::UpToMatch(regex, offset, _) => format!("/{}/{:+}", regex.as_str(), offset), + Self::SkipToMatch(regex, 0, _) => format!("%{}%", regex.as_str()), + Self::SkipToMatch(regex, offset, _) => format!("%{}%{:+}", regex.as_str(), offset), } } } diff --git a/src/uu/dd/src/datastructures.rs b/src/uu/dd/src/datastructures.rs index ffcee4cb1..72532b8ae 100644 --- a/src/uu/dd/src/datastructures.rs +++ b/src/uu/dd/src/datastructures.rs @@ -41,7 +41,7 @@ pub(crate) struct IConvFlags { } /// Stores all Conv Flags that apply to the output -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Eq)] pub struct OConvFlags { pub sparse: bool, pub excl: bool, @@ -52,7 +52,7 @@ pub struct OConvFlags { } /// Stores all Flags that apply to the input -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Eq)] pub struct IFlags { pub cio: bool, pub direct: bool, @@ -73,7 +73,7 @@ pub struct IFlags { } /// Stores all Flags that apply to the output -#[derive(Debug, Default, PartialEq)] +#[derive(Debug, Default, PartialEq, Eq)] pub struct OFlags { pub append: bool, pub cio: bool, @@ -96,7 +96,7 @@ pub struct OFlags { /// Defaults to Reads(N) /// if iflag=count_bytes /// then becomes Bytes(N) -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum CountType { Reads(u64), Bytes(u64), diff --git a/src/uu/dd/src/parseargs.rs b/src/uu/dd/src/parseargs.rs index 53adce3f3..a0475477e 100644 --- a/src/uu/dd/src/parseargs.rs +++ b/src/uu/dd/src/parseargs.rs @@ -18,7 +18,7 @@ use uucore::show_warning; pub type Matches = ArgMatches; /// Parser Errors describe errors with parser input -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ParseError { MultipleFmtTable, MultipleUCaseLCase, diff --git a/src/uu/dircolors/src/dircolors.rs b/src/uu/dircolors/src/dircolors.rs index 903fdd945..b557478fb 100644 --- a/src/uu/dircolors/src/dircolors.rs +++ b/src/uu/dircolors/src/dircolors.rs @@ -36,7 +36,7 @@ static LONG_HELP: &str = " mod colors; use self::colors::INTERNAL_DB; -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum OutputFmt { Shell, CShell, diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index bcc66c005..275118248 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -432,15 +432,15 @@ enum DuError { impl Display for DuError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - DuError::InvalidMaxDepthArg(s) => write!(f, "invalid maximum depth {}", s.quote()), - DuError::SummarizeDepthConflict(s) => { + Self::InvalidMaxDepthArg(s) => write!(f, "invalid maximum depth {}", s.quote()), + Self::SummarizeDepthConflict(s) => { write!( f, "summarizing conflicts with --max-depth={}", s.maybe_quote() ) } - DuError::InvalidTimeStyleArg(s) => write!( + Self::InvalidTimeStyleArg(s) => write!( f, "invalid argument {} for 'time style' Valid arguments are: @@ -451,13 +451,13 @@ Try '{} --help' for more information.", s.quote(), uucore::execution_phrase() ), - DuError::InvalidTimeArg(s) => write!( + Self::InvalidTimeArg(s) => write!( f, "Invalid argument {} for --time. 'birth' and 'creation' arguments are not supported on this platform.", s.quote() ), - DuError::InvalidGlob(s) => write!(f, "Invalid exclude syntax: {}", s), + Self::InvalidGlob(s) => write!(f, "Invalid exclude syntax: {}", s), } } } diff --git a/src/uu/expr/src/syntax_tree.rs b/src/uu/expr/src/syntax_tree.rs index 4dafffbf0..8c96684b8 100644 --- a/src/uu/expr/src/syntax_tree.rs +++ b/src/uu/expr/src/syntax_tree.rs @@ -42,13 +42,13 @@ impl AstNode { print!("\t",); } match self { - AstNode::Leaf { token_idx, value } => println!( + Self::Leaf { token_idx, value } => println!( "Leaf( {} ) at #{} ( evaluate -> {:?} )", value, token_idx, self.evaluate() ), - AstNode::Node { + Self::Node { token_idx, op_type, operands, @@ -157,7 +157,7 @@ impl AstNode { } } pub fn operand_values(&self) -> Result, String> { - if let AstNode::Node { operands, .. } = self { + if let Self::Node { operands, .. } = self { let mut out = Vec::with_capacity(operands.len()); for operand in operands { let value = operand.evaluate()?; diff --git a/src/uu/factor/sieve.rs b/src/uu/factor/sieve.rs index e7d499151..2c637fad1 100644 --- a/src/uu/factor/sieve.rs +++ b/src/uu/factor/sieve.rs @@ -135,7 +135,7 @@ struct PrimeHeap { impl PrimeHeap { fn peek(&self) -> Option<(u64, u64)> { - if let Some(&(x, y)) = self.data.get(0) { + if let Some(&(x, y)) = self.data.first() { Some((x, y)) } else { None diff --git a/src/uu/factor/src/cli.rs b/src/uu/factor/src/cli.rs index f78e410ba..ff248dd47 100644 --- a/src/uu/factor/src/cli.rs +++ b/src/uu/factor/src/cli.rs @@ -11,7 +11,8 @@ extern crate uucore; use std::error::Error; use std::fmt::Write as FmtWrite; -use std::io::{self, stdin, stdout, BufRead, Write}; +use std::io::BufRead; +use std::io::{self, stdin, stdout, Write}; mod factor; use clap::{crate_version, Arg, Command}; diff --git a/src/uu/factor/src/numeric/montgomery.rs b/src/uu/factor/src/numeric/montgomery.rs index 2a6782a02..368a71182 100644 --- a/src/uu/factor/src/numeric/montgomery.rs +++ b/src/uu/factor/src/numeric/montgomery.rs @@ -70,7 +70,7 @@ impl Montgomery { debug_assert!(x < (self.n.as_double_width()) << t_bits); // TODO: optimize - let Montgomery { a, n } = self; + let Self { a, n } = self; let m = T::from_double_width(x).wrapping_mul(a); let nm = (n.as_double_width()) * (m.as_double_width()); let (xnm, overflow) = x.overflowing_add(&nm); // x + n*m diff --git a/src/uu/fmt/src/parasplit.rs b/src/uu/fmt/src/parasplit.rs index 71b5f62ec..ec1c5dabb 100644 --- a/src/uu/fmt/src/parasplit.rs +++ b/src/uu/fmt/src/parasplit.rs @@ -40,16 +40,16 @@ impl Line { // when we know that it's a FormatLine, as in the ParagraphStream iterator fn get_formatline(self) -> FileLine { match self { - Line::FormatLine(fl) => fl, - Line::NoFormatLine(..) => panic!("Found NoFormatLine when expecting FormatLine"), + Self::FormatLine(fl) => fl, + Self::NoFormatLine(..) => panic!("Found NoFormatLine when expecting FormatLine"), } } // when we know that it's a NoFormatLine, as in the ParagraphStream iterator fn get_noformatline(self) -> (String, bool) { match self { - Line::NoFormatLine(s, b) => (s, b), - Line::FormatLine(..) => panic!("Found FormatLine when expecting NoFormatLine"), + Self::NoFormatLine(s, b) => (s, b), + Self::FormatLine(..) => panic!("Found FormatLine when expecting NoFormatLine"), } } } diff --git a/src/uu/head/src/parse.rs b/src/uu/head/src/parse.rs index ea731ba29..3b7c718ab 100644 --- a/src/uu/head/src/parse.rs +++ b/src/uu/head/src/parse.rs @@ -6,7 +6,7 @@ use std::ffi::OsString; use uucore::parse_size::{parse_size, ParseSizeError}; -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum ParseError { Syntax, Overflow, diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 786477846..5dcd21e0c 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -73,7 +73,7 @@ enum InstallError { impl UError for InstallError { fn code(&self) -> i32 { match self { - InstallError::Unimplemented(_) => 2, + Self::Unimplemented(_) => 2, _ => 1, } } @@ -87,41 +87,40 @@ impl Error for InstallError {} impl Display for InstallError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - use InstallError as IE; match self { - IE::Unimplemented(opt) => write!(f, "Unimplemented feature: {}", opt), - IE::DirNeedsArg() => { + Self::Unimplemented(opt) => write!(f, "Unimplemented feature: {}", opt), + Self::DirNeedsArg() => { write!( f, "{} with -d requires at least one argument.", uucore::util_name() ) } - IE::CreateDirFailed(dir, e) => { + Self::CreateDirFailed(dir, e) => { Display::fmt(&uio_error!(e, "failed to create {}", dir.quote()), f) } - IE::ChmodFailed(file) => write!(f, "failed to chmod {}", file.quote()), - IE::InvalidTarget(target) => write!( + Self::ChmodFailed(file) => write!(f, "failed to chmod {}", file.quote()), + Self::InvalidTarget(target) => write!( f, "invalid target {}: No such file or directory", target.quote() ), - IE::TargetDirIsntDir(target) => { + Self::TargetDirIsntDir(target) => { write!(f, "target {} is not a directory", target.quote()) } - IE::BackupFailed(from, to, e) => Display::fmt( + Self::BackupFailed(from, to, e) => Display::fmt( &uio_error!(e, "cannot backup {} to {}", from.quote(), to.quote()), f, ), - IE::InstallFailed(from, to, e) => Display::fmt( + Self::InstallFailed(from, to, e) => Display::fmt( &uio_error!(e, "cannot install {} to {}", from.quote(), to.quote()), f, ), - IE::StripProgramFailed(msg) => write!(f, "strip program failed: {}", msg), - IE::MetadataFailed(e) => Display::fmt(&uio_error!(e, ""), f), - IE::NoSuchUser(user) => write!(f, "no such user: {}", user.maybe_quote()), - IE::NoSuchGroup(group) => write!(f, "no such group: {}", group.maybe_quote()), - IE::OmittingDirectory(dir) => write!(f, "omitting directory {}", dir.quote()), + Self::StripProgramFailed(msg) => write!(f, "strip program failed: {}", msg), + Self::MetadataFailed(e) => Display::fmt(&uio_error!(e, ""), f), + Self::NoSuchUser(user) => write!(f, "no such user: {}", user.maybe_quote()), + Self::NoSuchGroup(group) => write!(f, "no such group: {}", group.maybe_quote()), + Self::OmittingDirectory(dir) => write!(f, "omitting directory {}", dir.quote()), } } } diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 20a8cbd28..f887d045d 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -43,8 +43,8 @@ impl Error for JoinError {} impl Display for JoinError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - JoinError::IOError(e) => write!(f, "io error: {}", e), - JoinError::UnorderedInput(e) => f.write_str(e), + Self::IOError(e) => write!(f, "io error: {}", e), + Self::UnorderedInput(e) => f.write_str(e), } } } diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs index fb748b489..d06bfe360 100644 --- a/src/uu/ls/src/ls.rs +++ b/src/uu/ls/src/ls.rs @@ -155,11 +155,11 @@ enum LsError { impl UError for LsError { fn code(&self) -> i32 { match self { - LsError::InvalidLineWidth(_) => 2, - LsError::IOError(_) => 1, - LsError::IOErrorContext(_, _) => 1, - LsError::BlockSizeParseError(_) => 1, - LsError::AlreadyListedError(_) => 2, + Self::InvalidLineWidth(_) => 2, + Self::IOError(_) => 1, + Self::IOErrorContext(_, _) => 1, + Self::BlockSizeParseError(_) => 1, + Self::AlreadyListedError(_) => 2, } } } @@ -169,12 +169,12 @@ impl Error for LsError {} impl Display for LsError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - LsError::BlockSizeParseError(s) => { + Self::BlockSizeParseError(s) => { write!(f, "invalid --block-size argument {}", s.quote()) } - LsError::InvalidLineWidth(s) => write!(f, "invalid line width: {}", s.quote()), - LsError::IOError(e) => write!(f, "general io error: {}", e), - LsError::IOErrorContext(e, p) => { + Self::InvalidLineWidth(s) => write!(f, "invalid line width: {}", s.quote()), + Self::IOError(e) => write!(f, "general io error: {}", e), + Self::IOErrorContext(e, p) => { let error_kind = e.kind(); let errno = e.raw_os_error().unwrap_or(1i32); @@ -236,7 +236,7 @@ impl Display for LsError { }, } } - LsError::AlreadyListedError(path) => { + Self::AlreadyListedError(path) => { write!( f, "{}: not listing already-listed directory", diff --git a/src/uu/mv/src/error.rs b/src/uu/mv/src/error.rs index 6a605626e..77f777836 100644 --- a/src/uu/mv/src/error.rs +++ b/src/uu/mv/src/error.rs @@ -22,22 +22,22 @@ impl UError for MvError {} impl Display for MvError { fn fmt(&self, f: &mut Formatter) -> Result { match self { - MvError::NoSuchFile(s) => write!(f, "cannot stat {}: No such file or directory", s), - MvError::SameFile(s, t) => write!(f, "{} and {} are the same file", s, t), - MvError::SelfSubdirectory(s) => write!( + Self::NoSuchFile(s) => write!(f, "cannot stat {}: No such file or directory", s), + Self::SameFile(s, t) => write!(f, "{} and {} are the same file", s, t), + Self::SelfSubdirectory(s) => write!( f, "cannot move '{s}' to a subdirectory of itself, '{s}/{s}'", s = s ), - MvError::DirectoryToNonDirectory(t) => { + Self::DirectoryToNonDirectory(t) => { write!(f, "cannot overwrite directory {} with non-directory", t) } - MvError::NonDirectoryToDirectory(s, t) => write!( + Self::NonDirectoryToDirectory(s, t) => write!( f, "cannot overwrite non-directory {} with directory {}", t, s ), - MvError::NotADirectory(t) => write!(f, "target {} is not a directory", t), + Self::NotADirectory(t) => write!(f, "target {} is not a directory", t), } } } diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 6f605ac4f..0f05e6eab 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -72,7 +72,7 @@ impl Display for NohupError { Self::OpenFailed(_, e) => { write!(f, "failed to open {}: {}", NOHUP_OUT.quote(), e) } - NohupError::OpenFailed2(_, e1, s, e2) => write!( + Self::OpenFailed2(_, e1, s, e2) => write!( f, "failed to open {}: {}\nfailed to open {}: {}", NOHUP_OUT.quote(), diff --git a/src/uu/numfmt/src/errors.rs b/src/uu/numfmt/src/errors.rs index af7de9caa..c9f63f921 100644 --- a/src/uu/numfmt/src/errors.rs +++ b/src/uu/numfmt/src/errors.rs @@ -19,9 +19,9 @@ pub enum NumfmtError { impl UError for NumfmtError { fn code(&self) -> i32 { match self { - NumfmtError::IoError(_) => 1, - NumfmtError::IllegalArgument(_) => 1, - NumfmtError::FormattingError(_) => 2, + Self::IoError(_) => 1, + Self::IllegalArgument(_) => 1, + Self::FormattingError(_) => 2, } } } @@ -31,9 +31,9 @@ impl Error for NumfmtError {} impl Display for NumfmtError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - NumfmtError::IoError(s) - | NumfmtError::IllegalArgument(s) - | NumfmtError::FormattingError(s) => write!(f, "{}", s), + Self::IoError(s) | Self::IllegalArgument(s) | Self::FormattingError(s) => { + write!(f, "{}", s) + } } } } diff --git a/src/uu/numfmt/src/units.rs b/src/uu/numfmt/src/units.rs index 8a2895ab7..a2c7b3568 100644 --- a/src/uu/numfmt/src/units.rs +++ b/src/uu/numfmt/src/units.rs @@ -44,7 +44,7 @@ pub struct DisplayableSuffix(pub Suffix); impl fmt::Display for DisplayableSuffix { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let DisplayableSuffix((ref raw_suffix, ref with_i)) = *self; + let Self((ref raw_suffix, ref with_i)) = *self; match raw_suffix { RawSuffix::K => write!(f, "K"), RawSuffix::M => write!(f, "M"), diff --git a/src/uu/od/src/formatteriteminfo.rs b/src/uu/od/src/formatteriteminfo.rs index 9778b68f4..6d51fa3a3 100644 --- a/src/uu/od/src/formatteriteminfo.rs +++ b/src/uu/od/src/formatteriteminfo.rs @@ -35,15 +35,15 @@ impl Eq for FormatWriter {} impl fmt::Debug for FormatWriter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - FormatWriter::IntWriter(ref p) => { + Self::IntWriter(ref p) => { f.write_str("IntWriter:")?; fmt::Pointer::fmt(p, f) } - FormatWriter::FloatWriter(ref p) => { + Self::FloatWriter(ref p) => { f.write_str("FloatWriter:")?; fmt::Pointer::fmt(p, f) } - FormatWriter::MultibyteWriter(ref p) => { + Self::MultibyteWriter(ref p) => { f.write_str("MultibyteWriter:")?; fmt::Pointer::fmt(&(*p as *const ()), f) } diff --git a/src/uu/od/src/od.rs b/src/uu/od/src/od.rs index 73917b99f..314c98dce 100644 --- a/src/uu/od/src/od.rs +++ b/src/uu/od/src/od.rs @@ -218,8 +218,10 @@ impl OdOptions { "Radix must be one of [d, o, n, x]".to_string(), )); } else { - let radix: char = - *(st.get(0).expect("byte string of length 1 lacks a 0th elem")) as char; + let radix: char = *(st + .first() + .expect("byte string of length 1 lacks a 0th elem")) + as char; match radix { 'd' => Radix::Decimal, 'x' => Radix::Hexadecimal, diff --git a/src/uu/od/src/parse_inputs.rs b/src/uu/od/src/parse_inputs.rs index 80b0d974f..4c3463c02 100644 --- a/src/uu/od/src/parse_inputs.rs +++ b/src/uu/od/src/parse_inputs.rs @@ -29,7 +29,7 @@ impl CommandLineOpts for ArgMatches { /// and an optional label. Offset and label are specified in bytes. /// `FileAndOffset` will be only used if an offset is specified, /// but it might be 0. -#[derive(PartialEq, Debug)] +#[derive(PartialEq, Eq, Debug)] pub enum CommandLineInputs { FileNames(Vec), FileAndOffset((String, u64, Option)), diff --git a/src/uu/pr/src/pr.rs b/src/uu/pr/src/pr.rs index 682e9b6d4..67319842a 100644 --- a/src/uu/pr/src/pr.rs +++ b/src/uu/pr/src/pr.rs @@ -580,7 +580,7 @@ fn build_options( let date_time = Local::now(); date_time.format("%b %d %H:%M %Y").to_string() } else { - file_last_modified_time(paths.get(0).unwrap()) + file_last_modified_time(paths.first().unwrap()) }; // +page option is less priority than --pages diff --git a/src/uu/seq/src/number.rs b/src/uu/seq/src/number.rs index 1b46f8f55..1bab62b14 100644 --- a/src/uu/seq/src/number.rs +++ b/src/uu/seq/src/number.rs @@ -24,16 +24,16 @@ impl Number { // requires an addition implementation, and we don't want to // implement that here. match self { - Number::Int(n) => n.is_zero(), - Number::Float(x) => x.is_zero(), + Self::Int(n) => n.is_zero(), + Self::Float(x) => x.is_zero(), } } /// Convert this number into an `ExtendedBigDecimal`. pub fn into_extended_big_decimal(self) -> ExtendedBigDecimal { match self { - Number::Int(n) => ExtendedBigDecimal::from(n), - Number::Float(x) => x, + Self::Int(n) => ExtendedBigDecimal::from(n), + Self::Float(x) => x, } } @@ -54,11 +54,11 @@ impl Number { // If this number is already an integer, it is already // rounded to the nearest integer in the direction of // `other`. - Number::Int(num) => num, + Self::Int(num) => num, // Otherwise, if this number is a float, we need to decide // whether `other` is larger or smaller than it, and thus // whether to round up or round down, respectively. - Number::Float(num) => { + Self::Float(num) => { let other: ExtendedBigDecimal = From::from(other.clone()); if other > num { num.ceil() diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index c3f3656a8..23d94ea2b 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -17,7 +17,7 @@ use crate::number::Number; use crate::number::PreciseNumber; /// An error returned when parsing a number fails. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum ParseNumberError { Float, Nan, diff --git a/src/uu/shred/src/shred.rs b/src/uu/shred/src/shred.rs index 7f1c97c77..96084df18 100644 --- a/src/uu/shred/src/shred.rs +++ b/src/uu/shred/src/shred.rs @@ -483,7 +483,7 @@ fn wipe_file( for _ in 0..n_full_arrays { for p in &PATTERNS { - pass_sequence.push(PassType::Pattern(*p)); + pass_sequence.push(PassType::Pattern(p)); } } for pattern in PATTERNS.iter().take(remainder) { diff --git a/src/uu/sort/src/numeric_str_cmp.rs b/src/uu/sort/src/numeric_str_cmp.rs index d6855b267..70f8c2cd8 100644 --- a/src/uu/sort/src/numeric_str_cmp.rs +++ b/src/uu/sort/src/numeric_str_cmp.rs @@ -22,12 +22,12 @@ enum Sign { Positive, } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct NumInfo { exponent: i64, sign: Sign, } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct NumInfoParseSettings { pub accept_si_units: bool, pub thousands_separator: Option, diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 15e36a595..16dab5c5c 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -171,7 +171,7 @@ impl Error for SortError {} impl UError for SortError { fn code(&self) -> i32 { match self { - SortError::Disorder { .. } => 1, + Self::Disorder { .. } => 1, _ => 2, } } diff --git a/src/uu/stat/src/stat.rs b/src/uu/stat/src/stat.rs index c26bca394..f50e31919 100644 --- a/src/uu/stat/src/stat.rs +++ b/src/uu/stat/src/stat.rs @@ -109,7 +109,7 @@ pub const F_SIGN: u8 = 1 << 4; // unused at present pub const F_GROUP: u8 = 1 << 5; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum OutputType { Str, Integer, @@ -119,7 +119,7 @@ pub enum OutputType { Unknown, } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Token { Char(char), Directive { diff --git a/src/uu/tac/src/error.rs b/src/uu/tac/src/error.rs index 92b071cc4..52c668516 100644 --- a/src/uu/tac/src/error.rs +++ b/src/uu/tac/src/error.rs @@ -44,17 +44,17 @@ impl Error for TacError {} impl Display for TacError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - TacError::InvalidRegex(e) => write!(f, "invalid regular expression: {}", e), - TacError::InvalidArgument(s) => { + Self::InvalidRegex(e) => write!(f, "invalid regular expression: {}", e), + Self::InvalidArgument(s) => { write!(f, "{}: read error: Invalid argument", s.maybe_quote()) } - TacError::FileNotFound(s) => write!( + Self::FileNotFound(s) => write!( f, "failed to open {} for reading: No such file or directory", s.quote() ), - TacError::ReadError(s, e) => write!(f, "failed to read from {}: {}", s, e), - TacError::WriteError(e) => write!(f, "failed to write to stdout: {}", e), + Self::ReadError(s, e) => write!(f, "failed to read from {}: {}", s, e), + Self::WriteError(e) => write!(f, "failed to write to stdout: {}", e), } } } diff --git a/src/uu/test/src/parser.rs b/src/uu/test/src/parser.rs index d8d7ce802..5d27f8838 100644 --- a/src/uu/test/src/parser.rs +++ b/src/uu/test/src/parser.rs @@ -14,7 +14,7 @@ use uucore::display::Quotable; use uucore::show_error; /// Represents one of the binary comparison operators for strings, integers, or files -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Operator { String(OsString), Int(OsString), @@ -22,14 +22,14 @@ pub enum Operator { } /// Represents one of the unary test operators for strings or files -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum UnaryOperator { StrlenOp(OsString), FiletestOp(OsString), } /// Represents a parsed token from a test expression -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Symbol { LParen, Bang, diff --git a/src/uu/tr/src/operation.rs b/src/uu/tr/src/operation.rs index 2c88758c5..0bc8005fe 100644 --- a/src/uu/tr/src/operation.rs +++ b/src/uu/tr/src/operation.rs @@ -143,13 +143,13 @@ impl Sequence { let set1 = Self::from_str(set1_str)?; let set2 = Self::from_str(set2_str)?; - let is_char_star = |s: &&Self| -> bool { matches!(s, Sequence::CharStar(_)) }; + let is_char_star = |s: &&Self| -> bool { matches!(s, Self::CharStar(_)) }; let set1_star_count = set1.iter().filter(is_char_star).count(); if set1_star_count == 0 { let set2_star_count = set2.iter().filter(is_char_star).count(); if set2_star_count < 2 { let char_star = set2.iter().find_map(|s| match s { - Sequence::CharStar(c) => Some(c), + Self::CharStar(c) => Some(c), _ => None, }); let mut partition = set2.as_slice().split(|s| matches!(s, Self::CharStar(_))); @@ -157,7 +157,7 @@ impl Sequence { let set2_len = set2 .iter() .filter_map(|s| match s { - Sequence::CharStar(_) => None, + Self::CharStar(_) => None, r => Some(r), }) .flat_map(Self::flatten) diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index b3110dcc1..b282218a6 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -56,19 +56,19 @@ impl TruncateMode { /// ``` fn to_size(&self, fsize: u64) -> u64 { match self { - TruncateMode::Absolute(size) => *size, - TruncateMode::Extend(size) => fsize + size, - TruncateMode::Reduce(size) => { + Self::Absolute(size) => *size, + Self::Extend(size) => fsize + size, + Self::Reduce(size) => { if *size > fsize { 0 } else { fsize - size } } - TruncateMode::AtMost(size) => fsize.min(*size), - TruncateMode::AtLeast(size) => fsize.max(*size), - TruncateMode::RoundDown(size) => fsize - fsize % size, - TruncateMode::RoundUp(size) => fsize + fsize % size, + Self::AtMost(size) => fsize.min(*size), + Self::AtLeast(size) => fsize.max(*size), + Self::RoundDown(size) => fsize - fsize % size, + Self::RoundUp(size) => fsize + fsize % size, } } } diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index b09b0c0ad..e938c1bf0 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -147,18 +147,18 @@ impl Input { /// Converts input to title that appears in stats. fn to_title(&self, quoting_style: &QuotingStyle) -> Option { match self { - Input::Path(path) => Some(escape_name(&path.clone().into_os_string(), quoting_style)), - Input::Stdin(StdinKind::Explicit) => { + Self::Path(path) => Some(escape_name(&path.clone().into_os_string(), quoting_style)), + Self::Stdin(StdinKind::Explicit) => { Some(escape_name(OsStr::new(STDIN_REPR), quoting_style)) } - Input::Stdin(StdinKind::Implicit) => None, + Self::Stdin(StdinKind::Implicit) => None, } } fn path_display(&self, quoting_style: &QuotingStyle) -> String { match self { - Input::Path(path) => escape_name(&path.clone().into_os_string(), quoting_style), - Input::Stdin(_) => escape_name(OsStr::new("standard input"), quoting_style), + Self::Path(path) => escape_name(&path.clone().into_os_string(), quoting_style), + Self::Stdin(_) => escape_name(OsStr::new("standard input"), quoting_style), } } } @@ -172,12 +172,12 @@ enum WcError { impl UError for WcError { fn code(&self) -> i32 { match self { - WcError::FilesDisabled(_) | WcError::StdinReprNotAllowed(_) => 1, + Self::FilesDisabled(_) | Self::StdinReprNotAllowed(_) => 1, } } fn usage(&self) -> bool { - matches!(self, WcError::FilesDisabled(_)) + matches!(self, Self::FilesDisabled(_)) } } @@ -186,7 +186,7 @@ impl Error for WcError {} impl Display for WcError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - WcError::FilesDisabled(message) | WcError::StdinReprNotAllowed(message) => { + Self::FilesDisabled(message) | Self::StdinReprNotAllowed(message) => { write!(f, "{}", message) } } diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index 1d2fe04cf..54c09e631 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -29,14 +29,14 @@ use std::os::unix::ffi::OsStrExt; use std::path::Path; /// The various level of verbosity -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub enum VerbosityLevel { Silent, Changes, Verbose, Normal, } -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug)] pub struct Verbosity { pub groups_only: bool, pub level: VerbosityLevel, diff --git a/src/uucore/src/lib/features/process.rs b/src/uucore/src/lib/features/process.rs index b573fdfcc..816b06a75 100644 --- a/src/uucore/src/lib/features/process.rs +++ b/src/uucore/src/lib/features/process.rs @@ -66,21 +66,21 @@ impl ExitStatus { pub fn success(&self) -> bool { match *self { - ExitStatus::Code(code) => code == 0, + Self::Code(code) => code == 0, _ => false, } } pub fn code(&self) -> Option { match *self { - ExitStatus::Code(code) => Some(code), + Self::Code(code) => Some(code), _ => None, } } pub fn signal(&self) -> Option { match *self { - ExitStatus::Signal(code) => Some(code), + Self::Signal(code) => Some(code), _ => None, } } @@ -89,8 +89,8 @@ impl ExitStatus { impl fmt::Display for ExitStatus { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ExitStatus::Code(code) => write!(f, "exit code: {}", code), - ExitStatus::Signal(code) => write!(f, "exit code: {}", code), + Self::Code(code) => write!(f, "exit code: {}", code), + Self::Signal(code) => write!(f, "exit code: {}", code), } } } diff --git a/src/uucore/src/lib/features/tokenize/num_format/formatter.rs b/src/uucore/src/lib/features/tokenize/num_format/formatter.rs index 801e05eb8..ed7d5a0f6 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/formatter.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/formatter.rs @@ -19,7 +19,7 @@ pub struct FormatPrimitive { pub suffix: Option, } -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Eq)] pub enum Base { Ten = 10, Hex = 16, diff --git a/src/uucore/src/lib/features/tokenize/num_format/num_format.rs b/src/uucore/src/lib/features/tokenize/num_format/num_format.rs index 89d0fe89b..c8486e792 100644 --- a/src/uucore/src/lib/features/tokenize/num_format/num_format.rs +++ b/src/uucore/src/lib/features/tokenize/num_format/num_format.rs @@ -33,7 +33,7 @@ fn warn_char_constant_ign(remaining_bytes: &[u8]) { show_warning!( "{:?}: character(s) following character \ constant have been ignored", - &*remaining_bytes + remaining_bytes ); } } diff --git a/src/uucore/src/lib/mods/backup_control.rs b/src/uucore/src/lib/mods/backup_control.rs index a5c9baa61..0037ed491 100644 --- a/src/uucore/src/lib/mods/backup_control.rs +++ b/src/uucore/src/lib/mods/backup_control.rs @@ -148,7 +148,7 @@ pub enum BackupError { impl UError for BackupError { fn code(&self) -> i32 { match self { - BackupError::BackupImpossible() => 2, + Self::BackupImpossible() => 2, _ => 1, } } @@ -157,7 +157,7 @@ impl UError for BackupError { // Suggested by clippy. matches!( self, - BackupError::InvalidArgument(_, _) | BackupError::AmbiguousArgument(_, _) + Self::InvalidArgument(_, _) | Self::AmbiguousArgument(_, _) ) } } @@ -166,25 +166,24 @@ impl Error for BackupError {} impl Display for BackupError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - use BackupError as BE; match self { - BE::InvalidArgument(arg, origin) => write!( + Self::InvalidArgument(arg, origin) => write!( f, "invalid argument {} for '{}'\n{}", arg.quote(), origin, VALID_ARGS_HELP ), - BE::AmbiguousArgument(arg, origin) => write!( + Self::AmbiguousArgument(arg, origin) => write!( f, "ambiguous argument {} for '{}'\n{}", arg.quote(), origin, VALID_ARGS_HELP ), - BE::BackupImpossible() => write!(f, "cannot create backup"), + Self::BackupImpossible() => write!(f, "cannot create backup"), // Placeholder for later - // BE::BackupFailed(from, to, e) => Display::fmt( + // Self::BackupFailed(from, to, e) => Display::fmt( // &uio_error!(e, "failed to backup {} to {}", from.quote(), to.quote()), // f // ), diff --git a/src/uucore/src/lib/parser/parse_size.rs b/src/uucore/src/lib/parser/parse_size.rs index 557010584..afe64ae67 100644 --- a/src/uucore/src/lib/parser/parse_size.rs +++ b/src/uucore/src/lib/parser/parse_size.rs @@ -94,9 +94,9 @@ pub enum ParseSizeError { impl Error for ParseSizeError { fn description(&self) -> &str { match *self { - ParseSizeError::InvalidSuffix(ref s) => &*s, - ParseSizeError::ParseFailure(ref s) => &*s, - ParseSizeError::SizeTooBig(ref s) => &*s, + Self::InvalidSuffix(ref s) => s, + Self::ParseFailure(ref s) => s, + Self::SizeTooBig(ref s) => s, } } } @@ -104,9 +104,7 @@ impl Error for ParseSizeError { impl fmt::Display for ParseSizeError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { let s = match self { - ParseSizeError::InvalidSuffix(s) - | ParseSizeError::ParseFailure(s) - | ParseSizeError::SizeTooBig(s) => s, + Self::InvalidSuffix(s) | Self::ParseFailure(s) | Self::SizeTooBig(s) => s, }; write!(f, "{}", s) }