mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #3720 from andrewbaptist/fix_warnings
Update to handle all the latest cargo warnings
This commit is contained in:
@@ -62,8 +62,8 @@ enum LineReader {
|
||||
impl LineReader {
|
||||
fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
+5
-5
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Vec<String>, 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()?;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -70,7 +70,7 @@ impl<T: DoubleInt> Montgomery<T> {
|
||||
|
||||
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
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -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",
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user