diff --git a/crates/project_core/src/worktree.rs b/crates/project_core/src/worktree.rs index 2fe51e67ba..a7b8e23b3c 100644 --- a/crates/project_core/src/worktree.rs +++ b/crates/project_core/src/worktree.rs @@ -3918,16 +3918,14 @@ impl BackgroundScanner { let repository = dotgit_path.and_then(|path| state.build_git_repository(path, self.fs.as_ref())); - for new_job in new_jobs { - if let Some(mut new_job) = new_job { - if let Some(containing_repository) = &repository { - new_job.containing_repository = Some(containing_repository.clone()); - } - - job.scan_queue - .try_send(new_job) - .expect("channel is unbounded"); + for mut new_job in new_jobs.into_iter().flatten() { + if let Some(containing_repository) = &repository { + new_job.containing_repository = Some(containing_repository.clone()); } + + job.scan_queue + .try_send(new_job) + .expect("channel is unbounded"); } Ok(()) diff --git a/crates/semantic_index/src/db.rs b/crates/semantic_index/src/db.rs index ea299da411..7deb05200e 100644 --- a/crates/semantic_index/src/db.rs +++ b/crates/semantic_index/src/db.rs @@ -278,11 +278,7 @@ impl VectorDatabase { let worktree_id = worktree_query .query_row(params![worktree_root_path], |row| Ok(row.get::<_, i64>(0)?)); - if worktree_id.is_ok() { - return Ok(true); - } else { - return Ok(false); - } + Ok(worktree_id.is_ok()) }) } @@ -302,17 +298,15 @@ impl VectorDatabase { let digests = Rc::new( digests .into_iter() - .map(|p| Value::Blob(p.0.to_vec())) + .map(|digest| Value::Blob(digest.0.to_vec())) .collect::>(), ); let rows = query.query_map(params![digests], |row| { Ok((row.get::<_, SpanDigest>(0)?, row.get::<_, Embedding>(1)?)) })?; - for row in rows { - if let Ok(row) = row { - embeddings_by_digest.insert(row.0, row.1); - } + for (digest, embedding) in rows.flatten() { + embeddings_by_digest.insert(digest, embedding); } Ok(embeddings_by_digest) @@ -344,10 +338,8 @@ impl VectorDatabase { Ok((row.get::<_, SpanDigest>(0)?, row.get::<_, Embedding>(1)?)) })?; - for row in rows { - if let Ok(row) = row { - embeddings_by_digest.insert(row.0, row.1); - } + for (digest, embedding) in rows.flatten() { + embeddings_by_digest.insert(digest, embedding); } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index a4a99ccc33..5452240e3c 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -3713,7 +3713,7 @@ fn open_items( project_paths_to_open .into_iter() .enumerate() - .map(|(i, (abs_path, project_path))| { + .map(|(ix, (abs_path, project_path))| { let workspace = workspace.clone(); cx.spawn(|mut cx| { let fs = app_state.fs.clone(); @@ -3721,7 +3721,7 @@ fn open_items( let file_project_path = project_path?; if fs.is_file(&abs_path).await { Some(( - i, + ix, workspace .update(&mut cx, |workspace, cx| { workspace.open_path(file_project_path, None, true, cx) @@ -3739,10 +3739,8 @@ fn open_items( let tasks = tasks.collect::>(); let tasks = futures::future::join_all(tasks.into_iter()); - for maybe_opened_path in tasks.await.into_iter() { - if let Some((i, path_open_result)) = maybe_opened_path { - opened_items[i] = Some(path_open_result); - } + for (ix, path_open_result) in tasks.await.into_iter().flatten() { + opened_items[ix] = Some(path_open_result); } Ok(opened_items) diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index dd5a0b5be8..dc9f43519d 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -296,9 +296,9 @@ fn main() { let task = workspace::open_paths(&paths, &app_state, None, cx); cx.spawn(|_| async move { if let Some((_window, results)) = task.await.log_err() { - for result in results { - if let Some(Err(e)) = result { - log::error!("Error opening path: {}", e); + for result in results.into_iter().flatten() { + if let Err(err) = result { + log::error!("Error opening path: {err}",); } } } diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rs index 4068a46e40..11f3df1e3c 100644 --- a/tooling/xtask/src/main.rs +++ b/tooling/xtask/src/main.rs @@ -101,7 +101,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> { "clippy::iter_kv_map", "clippy::iter_overeager_cloned", "clippy::let_underscore_future", - "clippy::manual_flatten", "clippy::map_entry", "clippy::needless_arbitrary_self_type", "clippy::needless_borrowed_reference",