Run a round of clippy --fix to fix a ton of lints (#7006)

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>

Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
This commit is contained in:
Alex Saveau
2022-11-04 13:11:17 -07:00
committed by GitHub
parent f1bde69131
commit be5d71ea47
32 changed files with 51 additions and 53 deletions

View File

@ -198,7 +198,7 @@ impl Command for Ls {
} else if full_paths || absolute_path {
Some(path.to_string_lossy().to_string())
} else if let Some(prefix) = &prefix {
if let Ok(remainder) = path.strip_prefix(&prefix) {
if let Ok(remainder) = path.strip_prefix(prefix) {
if directory {
// When the path is the same as the cwd, path_diff should be "."
let path_diff =
@ -215,7 +215,7 @@ impl Command for Ls {
Some(path_diff)
} else {
let new_prefix = if let Some(pfx) = diff_paths(&prefix, &cwd) {
let new_prefix = if let Some(pfx) = diff_paths(prefix, &cwd) {
pfx
} else {
prefix.to_path_buf()

View File

@ -295,7 +295,7 @@ fn move_file(
fn move_item(from: &Path, from_span: Span, to: &Path) -> Result<(), ShellError> {
// We first try a rename, which is a quick operation. If that doesn't work, we'll try a copy
// and remove the old file/folder. This is necessary if we're moving across filesystems or devices.
std::fs::rename(&from, &to).or_else(|_| {
std::fs::rename(from, to).or_else(|_| {
match if from.is_file() {
let mut options = fs_extra::file::CopyOptions::new();
options.overwrite = true;

View File

@ -97,7 +97,7 @@ impl Command for Open {
let path_no_whitespace = &path.item.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
let path = Path::new(path_no_whitespace);
if permission_denied(&path) {
if permission_denied(path) {
#[cfg(unix)]
let error_msg = match path.metadata() {
Ok(md) => format!(

View File

@ -284,8 +284,8 @@ fn rm(
}
Ok(all_targets
.into_iter()
.map(move |(f, _)| {
.into_keys()
.map(move |f| {
let is_empty = || match f.read_dir() {
Ok(mut p) => p.next().is_none(),
Err(_) => false,

View File

@ -72,7 +72,7 @@ impl Command for Watch {
.item
.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
let path = match nu_path::canonicalize_with(path_no_whitespace, &cwd) {
let path = match nu_path::canonicalize_with(path_no_whitespace, cwd) {
Ok(p) => p,
Err(e) => {
return Err(ShellError::DirectoryNotFound(