rust: clippy pass
This removes some justified warnings and one hard error that, while technically
not a bug, was an ugly oversight on my part.
Differential Revision: https://phab.mercurial-scm.org/D9094
--- a/rust/hg-core/src/dirstate/dirstate_tree/iter.rs Mon Sep 28 08:07:09 2020 -0700
+++ b/rust/hg-core/src/dirstate/dirstate_tree/iter.rs Mon Sep 28 14:07:00 2020 +0200
@@ -160,7 +160,7 @@
let meta = self.root_dir.join(filename_as_path).symlink_metadata();
match meta {
Ok(ref m) if m.file_type().is_symlink() => true,
- _ => return false,
+ _ => false,
}
}
}
@@ -182,7 +182,7 @@
fn next(&mut self) -> Option<Self::Item> {
// If any paths have already been `Dispatch`-ed, return them
- while let Some(res) = self.shortcuts.pop_front() {
+ if let Some(res) = self.shortcuts.pop_front() {
return Some(res);
}
@@ -250,7 +250,7 @@
) {
to_visit.extend(dir.children.iter().map(|(path, child)| {
let full_path = join_path(&base_path, &path);
- (Cow::from(full_path), child)
+ (full_path, child)
}));
}
--- a/rust/hg-core/src/dirstate/dirstate_tree/node.rs Mon Sep 28 08:07:09 2020 -0700
+++ b/rust/hg-core/src/dirstate/dirstate_tree/node.rs Mon Sep 28 14:07:00 2020 +0200
@@ -91,9 +91,9 @@
match &mut self.kind {
NodeKind::Directory(directory) => {
- return Node::insert_in_directory(
+ Node::insert_in_directory(
directory, new_entry, head, tail,
- );
+ )
}
NodeKind::File(_) => {
unreachable!("The file case has already been handled")
@@ -227,7 +227,7 @@
d.children.remove(head);
}
res.cleanup =
- d.children.len() == 0 && d.was_file.is_none();
+ d.children.is_empty() && d.was_file.is_none();
res
} else {
empty_result
@@ -241,7 +241,7 @@
if cleanup {
d.children.remove(head);
}
- if d.children.len() == 0 && d.was_file.is_none() {
+ if d.children.is_empty() && d.was_file.is_none() {
f.was_directory = None;
}
@@ -288,7 +288,7 @@
}
RemoveResult {
- cleanup: cleanup,
+ cleanup,
old_entry: Some(entry),
}
}