Fix Clippy lints

This commit is contained in:
ariasuni 2020-04-19 06:33:42 +02:00
parent 5a84953b4e
commit dba3f37b0a
14 changed files with 186 additions and 199 deletions

View File

@ -50,9 +50,10 @@ fn write_statics() -> IOResult<()> {
use std::io::Write;
use std::path::PathBuf;
let ver = match is_development_version() {
true => format!("exa v{} ({} built on {})", cargo_version(), git_hash(), build_date()),
false => format!("exa v{}", cargo_version()),
let ver = if is_development_version() {
format!("exa v{} ({} built on {})", cargo_version(), git_hash(), build_date())
} else {
format!("exa v{}", cargo_version())
};
let out = PathBuf::from(env::var("OUT_DIR").unwrap());

View File

@ -3,7 +3,6 @@
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use git2;
use log::{debug, error, info, warn};
use crate::fs::fields as f;

View File

@ -2,6 +2,7 @@
#![allow(trivial_casts)] // for ARM
extern crate libc;
use std::cmp::Ordering;
use std::io;
use std::path::Path;
@ -58,20 +59,23 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib
None => return Err(io::Error::new(io::ErrorKind::Other, "Error: path somehow contained a NUL?")),
};
let mut names = Vec::new();
let bufsize = lister.listxattr_first(&c_path);
if bufsize < 0 {
return Err(io::Error::last_os_error());
match bufsize.cmp(&0) {
Ordering::Less => return Err(io::Error::last_os_error()),
Ordering::Equal => return Ok(Vec::new()),
Ordering::Greater => {},
}
else if bufsize > 0 {
let mut buf = vec![0u8; bufsize as usize];
let err = lister.listxattr_second(&c_path, &mut buf, bufsize);
if err < 0 {
return Err(io::Error::last_os_error());
match err.cmp(&0) {
Ordering::Less => return Err(io::Error::last_os_error()),
Ordering::Equal => return Ok(Vec::new()),
Ordering::Greater => {},
}
let mut names = Vec::new();
if err > 0 {
// End indices of the attribute names
// the buffer contains 0-terminated c-strings
@ -93,9 +97,6 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib
start = c_end;
}
}
}
Ok(names)
}

View File

@ -474,8 +474,6 @@ impl<'dir> FileTarget<'dir> {
/// More readable aliases for the permission bits exposed by libc.
#[allow(trivial_numeric_casts)]
mod modes {
use libc;
pub type Mode = u32;
// The `libc::mode_t` types actual type varies, but the value returned
// from `metadata.permissions().mode()` is always `u32`.

View File

@ -5,9 +5,6 @@ use std::iter::FromIterator;
use std::os::unix::fs::MetadataExt;
use std::path::Path;
use glob;
use natord;
use crate::fs::File;
use crate::fs::DotFilter;

View File

@ -2,8 +2,6 @@ use std::ffi::OsString;
use std::fmt;
use std::num::ParseIntError;
use glob;
use crate::options::{flags, HelpString, VersionString};
use crate::options::parser::{Arg, Flag, ParseError};

View File

@ -267,7 +267,7 @@ impl Args {
// -abx => error
//
else {
for (index, byte) in bytes.into_iter().enumerate().skip(1) {
for (index, byte) in bytes.iter().enumerate().skip(1) {
let arg = self.lookup_short(*byte)?;
let flag = Flag::Short(*byte);
match arg.takes_value {
@ -283,7 +283,7 @@ impl Args {
}
else {
match arg.takes_value {
Forbidden => assert!(false),
Forbidden => unreachable!(),
Necessary(_) => {
return Err(ParseError::NeedsValue { flag, values });
},
@ -292,7 +292,6 @@ impl Args {
}
}
}
}
}
}
@ -309,14 +308,14 @@ impl Args {
}
fn lookup_short(&self, short: ShortArg) -> Result<&Arg, ParseError> {
match self.0.into_iter().find(|arg| arg.short == Some(short)) {
match self.0.iter().find(|arg| arg.short == Some(short)) {
Some(arg) => Ok(arg),
None => Err(ParseError::UnknownShortArgument { attempt: short })
}
}
fn lookup_long<'b>(&self, long: &'b OsStr) -> Result<&Arg, ParseError> {
match self.0.into_iter().find(|arg| arg.long == long) {
match self.0.iter().find(|arg| arg.long == long) {
Some(arg) => Ok(arg),
None => Err(ParseError::UnknownArgument { attempt: long.to_os_string() })
}

View File

@ -1,5 +1,4 @@
use ansi_term::Style;
use glob;
use crate::fs::File;
use crate::options::{flags, Vars, Misfire};
@ -366,7 +365,7 @@ mod customs_test {
#[test]
fn $name() {
let mappings: Vec<(glob::Pattern, Style)>
= $mappings.into_iter()
= $mappings.iter()
.map(|t| (glob::Pattern::new(t.0).unwrap(), t.1))
.collect();

View File

@ -290,7 +290,7 @@ impl TimeFormat {
Ok(TimeFormat::FullISO)
}
else {
Err(Misfire::BadArgument(&flags::TIME_STYLE, word.into()))
Err(Misfire::BadArgument(&flags::TIME_STYLE, word))
}
}
}

View File

@ -50,7 +50,7 @@ impl<'a> Render<'a> {
};
grid.add(tg::Cell {
contents: format!("{icon}{filename}", icon=&icon.unwrap_or("".to_string()), filename=filename.strings().to_string()),
contents: format!("{icon}{filename}", icon=&icon.unwrap_or_default(), filename=filename.strings().to_string()),
width: *width,
});
}

View File

@ -46,8 +46,7 @@ fn icon(file: &File) -> char {
let extensions = Box::new(FileExtensions);
if file.is_directory() { '\u{f115}' }
else if let Some(icon) = extensions.icon_file(file) { icon }
else {
if let Some(ext) = file.ext.as_ref() {
else if let Some(ext) = file.ext.as_ref() {
match ext.as_str() {
"ai" => '\u{e7b4}',
"android" => '\u{e70e}',
@ -191,4 +190,3 @@ fn icon(file: &File) -> char {
'\u{f15b}'
}
}
}

View File

@ -6,8 +6,6 @@ use std::sync::{Mutex, MutexGuard};
use datetime::TimeZone;
use zoneinfo_compiled::{CompiledData, Result as TZResult};
use locale;
use log::debug;
use users::UsersCache;

View File

@ -4,7 +4,6 @@ use std::time::Duration;
use datetime::{LocalDateTime, TimeZone, DatePiece, TimePiece};
use datetime::fmt::DateFormat;
use locale;
use std::cmp;