Patchwork D9094: rust: clippy pass

login
register
mail settings
Submitter phabricator
Date Sept. 28, 2020, 12:24 p.m.
Message ID <differential-rev-PHID-DREV-auqownzkb5cd2zzzmqcc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47309/
State Superseded
Headers show

Comments

phabricator - Sept. 28, 2020, 12:24 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This removes some justified warnings and one hard error that, while technically
  not a bug, was an ugly oversight on my part.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9094

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_tree/iter.rs
  rust/hg-core/src/dirstate/dirstate_tree/node.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-core/src/dirstate/dirstate_tree/node.rs b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/node.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/node.rs
@@ -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),
                     }
                 }
diff --git a/rust/hg-core/src/dirstate/dirstate_tree/iter.rs b/rust/hg-core/src/dirstate/dirstate_tree/iter.rs
--- a/rust/hg-core/src/dirstate/dirstate_tree/iter.rs
+++ b/rust/hg-core/src/dirstate/dirstate_tree/iter.rs
@@ -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)
     }));
 }