chore: run cargo +nightly clippy --fix

This commit is contained in:
Niyaz Nigmatullin 2022-11-15 17:57:08 +02:00
parent c3218740dc
commit fdd6a05259
9 changed files with 31 additions and 31 deletions

View file

@ -511,7 +511,7 @@ fn test_write_to_self() {
.create_new(true)
.write(true)
.append(true)
.open(&file_path)
.open(file_path)
.unwrap();
s.fixtures.append("first_file", "first_file_content.");

View file

@ -1085,7 +1085,7 @@ fn test_cp_no_deref_folder_to_folder() {
fn test_cp_archive() {
let (at, mut ucmd) = at_and_ucmd!();
let ts = time::OffsetDateTime::now_local().unwrap();
let previous = FileTime::from_unix_time(ts.unix_timestamp() - 3600, ts.nanosecond() as u32);
let previous = FileTime::from_unix_time(ts.unix_timestamp() - 3600, ts.nanosecond());
// set the file creation/modification an hour ago
filetime::set_file_times(
at.plus_as_string(TEST_HELLO_WORLD_SOURCE),

View file

@ -2057,7 +2057,7 @@ fn test_ls_indicator_style() {
.tempdir()
.expect("failed to create dir");
let socket_path = dir.path().join("sock");
let _listener = UnixListener::bind(&socket_path).expect("failed to create socket");
let _listener = UnixListener::bind(socket_path).expect("failed to create socket");
new_ucmd!()
.args(&[

View file

@ -621,7 +621,7 @@ fn test_mv_update_option() {
at.touch(file_b);
let ts = time::OffsetDateTime::now_local().unwrap();
let now = FileTime::from_unix_time(ts.unix_timestamp(), ts.nanosecond());
let later = FileTime::from_unix_time(ts.unix_timestamp() as i64 + 3600, ts.nanosecond() as u32);
let later = FileTime::from_unix_time(ts.unix_timestamp() + 3600, ts.nanosecond());
filetime::set_file_times(at.plus_as_string(file_a), now, now).unwrap();
filetime::set_file_times(at.plus_as_string(file_b), now, later).unwrap();

View file

@ -85,7 +85,7 @@ impl RandomFile {
/// `create()` file handle located at `at` / `name`
fn new(at: &AtPath, name: &str) -> Self {
Self {
inner: File::create(&at.plus(name)).unwrap(),
inner: File::create(at.plus(name)).unwrap(),
}
}

View file

@ -34,7 +34,7 @@ fn get_symlink_times(at: &AtPath, path: &str) -> (FileTime, FileTime) {
}
fn set_file_times(at: &AtPath, path: &str, atime: FileTime, mtime: FileTime) {
filetime::set_file_times(&at.plus_as_string(path), atime, mtime).unwrap();
filetime::set_file_times(at.plus_as_string(path), atime, mtime).unwrap();
}
// Adjusts for local timezone

View file

@ -8,7 +8,7 @@ use crate::common::util::*;
#[cfg(unix)]
fn check_termination(result: &ExitStatus) {
assert_eq!(result.signal(), Some(libc::SIGPIPE as i32));
assert_eq!(result.signal(), Some(libc::SIGPIPE));
}
#[cfg(not(unix))]

View file

@ -470,7 +470,7 @@ pub fn recursive_copy(src: &Path, dest: &Path) -> Result<()> {
fs::create_dir(&new_dest)?;
recursive_copy(&entry.path(), &new_dest)?;
} else {
fs::copy(&entry.path(), new_dest)?;
fs::copy(entry.path(), new_dest)?;
}
}
}
@ -631,12 +631,12 @@ impl AtPath {
pub fn rmdir(&self, dir: &str) {
log_info("rmdir", self.plus_as_string(dir));
fs::remove_dir(&self.plus(dir)).unwrap();
fs::remove_dir(self.plus(dir)).unwrap();
}
pub fn mkdir(&self, dir: &str) {
log_info("mkdir", self.plus_as_string(dir));
fs::create_dir(&self.plus(dir)).unwrap();
fs::create_dir(self.plus(dir)).unwrap();
}
pub fn mkdir_all(&self, dir: &str) {
@ -645,7 +645,7 @@ impl AtPath {
}
pub fn make_file(&self, name: &str) -> File {
match File::create(&self.plus(name)) {
match File::create(self.plus(name)) {
Ok(f) => f,
Err(e) => panic!("{}", e),
}
@ -653,7 +653,7 @@ impl AtPath {
pub fn touch(&self, file: &str) {
log_info("touch", self.plus_as_string(file));
File::create(&self.plus(file)).unwrap();
File::create(self.plus(file)).unwrap();
}
#[cfg(not(windows))]
@ -682,25 +682,25 @@ impl AtPath {
pub fn hard_link(&self, original: &str, link: &str) {
log_info(
"hard_link",
&format!(
format!(
"{},{}",
self.plus_as_string(original),
self.plus_as_string(link)
),
);
hard_link(&self.plus(original), &self.plus(link)).unwrap();
hard_link(self.plus(original), self.plus(link)).unwrap();
}
pub fn symlink_file(&self, original: &str, link: &str) {
log_info(
"symlink",
&format!(
format!(
"{},{}",
self.plus_as_string(original),
self.plus_as_string(link)
),
);
symlink_file(&self.plus(original), &self.plus(link)).unwrap();
symlink_file(self.plus(original), self.plus(link)).unwrap();
}
pub fn relative_symlink_file(&self, original: &str, link: &str) {
@ -708,21 +708,21 @@ impl AtPath {
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
log_info(
"symlink",
&format!("{},{}", &original, &self.plus_as_string(link)),
format!("{},{}", &original, &self.plus_as_string(link)),
);
symlink_file(original, &self.plus(link)).unwrap();
symlink_file(original, self.plus(link)).unwrap();
}
pub fn symlink_dir(&self, original: &str, link: &str) {
log_info(
"symlink",
&format!(
format!(
"{},{}",
self.plus_as_string(original),
self.plus_as_string(link)
),
);
symlink_dir(&self.plus(original), &self.plus(link)).unwrap();
symlink_dir(self.plus(original), self.plus(link)).unwrap();
}
pub fn relative_symlink_dir(&self, original: &str, link: &str) {
@ -730,14 +730,14 @@ impl AtPath {
let original = original.replace('/', &MAIN_SEPARATOR.to_string());
log_info(
"symlink",
&format!("{},{}", &original, &self.plus_as_string(link)),
format!("{},{}", &original, &self.plus_as_string(link)),
);
symlink_dir(original, &self.plus(link)).unwrap();
symlink_dir(original, self.plus(link)).unwrap();
}
pub fn is_symlink(&self, path: &str) -> bool {
log_info("is_symlink", self.plus_as_string(path));
match fs::symlink_metadata(&self.plus(path)) {
match fs::symlink_metadata(self.plus(path)) {
Ok(m) => m.file_type().is_symlink(),
Err(_) => false,
}
@ -745,7 +745,7 @@ impl AtPath {
pub fn resolve_link(&self, path: &str) -> String {
log_info("resolve_link", self.plus_as_string(path));
match fs::read_link(&self.plus(path)) {
match fs::read_link(self.plus(path)) {
Ok(p) => self.minus_as_string(p.to_str().unwrap()),
Err(_) => "".to_string(),
}
@ -753,7 +753,7 @@ impl AtPath {
pub fn read_symlink(&self, path: &str) -> String {
log_info("read_symlink", self.plus_as_string(path));
fs::read_link(&self.plus(path))
fs::read_link(self.plus(path))
.unwrap()
.to_str()
.unwrap()
@ -761,21 +761,21 @@ impl AtPath {
}
pub fn symlink_metadata(&self, path: &str) -> fs::Metadata {
match fs::symlink_metadata(&self.plus(path)) {
match fs::symlink_metadata(self.plus(path)) {
Ok(m) => m,
Err(e) => panic!("{}", e),
}
}
pub fn metadata(&self, path: &str) -> fs::Metadata {
match fs::metadata(&self.plus(path)) {
match fs::metadata(self.plus(path)) {
Ok(m) => m,
Err(e) => panic!("{}", e),
}
}
pub fn file_exists(&self, path: &str) -> bool {
match fs::metadata(&self.plus(path)) {
match fs::metadata(self.plus(path)) {
Ok(m) => m.is_file(),
Err(_) => false,
}
@ -783,14 +783,14 @@ impl AtPath {
/// Decide whether the named symbolic link exists in the test directory.
pub fn symlink_exists(&self, path: &str) -> bool {
match fs::symlink_metadata(&self.plus(path)) {
match fs::symlink_metadata(self.plus(path)) {
Ok(m) => m.file_type().is_symlink(),
Err(_) => false,
}
}
pub fn dir_exists(&self, path: &str) -> bool {
match fs::metadata(&self.plus(path)) {
match fs::metadata(self.plus(path)) {
Ok(m) => m.is_dir(),
Err(_) => false,
}

View file

@ -52,7 +52,7 @@ fn util_name_double() {
};
let scenario = TestScenario::new("sort");
let mut child = Command::new(&scenario.bin_path)
let mut child = Command::new(scenario.bin_path)
.arg("sort")
.stdin(Stdio::piped())
.stderr(Stdio::piped())