Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Enable `clippy::explicit_counter_loop` (#8776)

Marshall Bowers1fa949633436
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 258e3fb8a9b..78e0afd2b66 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -2735,9 +2735,8 @@ impl Editor {
let mut edits = Vec::new();
let mut rows = Vec::new();
- let mut rows_inserted = 0;
- for selection in self.selections.all_adjusted(cx) {
+ for (rows_inserted, selection) in self.selections.all_adjusted(cx).into_iter().enumerate() {
let cursor = selection.head();
let row = cursor.row;
@@ -2746,8 +2745,7 @@ impl Editor {
let newline = "\n".to_string();
edits.push((start_of_line..start_of_line, newline));
- rows.push(row + rows_inserted);
- rows_inserted += 1;
+ rows.push(row + rows_inserted as u32);
}
self.transact(cx, |editor, cx| {
diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rs
index 4cfb96af67a..d716842cb41 100644
--- a/tooling/xtask/src/main.rs
+++ b/tooling/xtask/src/main.rs
@@ -89,7 +89,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
"clippy::derivable_impls",
"clippy::derive_ord_xor_partial_ord",
"clippy::eq_op",
- "clippy::explicit_counter_loop",
"clippy::implied_bounds_in_impls",
"clippy::iter_kv_map",
"clippy::iter_overeager_cloned",