From 47b76481e51451827530714512b30882d85e3a9a Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 13 Jun 2026 01:36:41 +0200 Subject: chore(treewide): Also fix all `clippy` warnings --- .../turtle/src/atuin_daemon/components/search.rs | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'crates/turtle/src/atuin_daemon/components/search.rs') diff --git a/crates/turtle/src/atuin_daemon/components/search.rs b/crates/turtle/src/atuin_daemon/components/search.rs index bcb18865..bcd60cc4 100644 --- a/crates/turtle/src/atuin_daemon/components/search.rs +++ b/crates/turtle/src/atuin_daemon/components/search.rs @@ -60,6 +60,7 @@ impl SearchComponent { } /// Rebuild the entire search index from the database. + #[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn rebuild_index(&self) -> Result<()> { let handle_guard = self.handle.read().await; let handle = handle_guard @@ -114,6 +115,7 @@ impl Component for SearchComponent { "search" } + #[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn start(&mut self, handle: DaemonHandle) -> Result<()> { *self.handle.write().await = Some(handle.clone()); @@ -179,6 +181,7 @@ impl Component for SearchComponent { Ok(()) } + #[expect(clippy::significant_drop_tightening, reason = "false positive")] async fn handle_event(&mut self, event: &DaemonEvent) -> Result<()> { match event { DaemonEvent::RecordsAdded(records) => { @@ -314,7 +317,7 @@ impl SearchSvc for SearchGrpcService { ); // Convert proto FilterMode + context to IndexFilterMode - let index_filter = convert_filter_mode(filter_mode, &proto_context); + let index_filter = convert_filter_mode(filter_mode, proto_context.as_ref()); // Build QueryContext from proto context let query_context = proto_context @@ -368,21 +371,21 @@ impl SearchSvc for SearchGrpcService { /// Convert proto `FilterMode` and context to `IndexFilterMode`. fn convert_filter_mode( mode: FilterMode, - context: &Option, + context: Option<&search::SearchContext>, ) -> IndexFilterMode { + #[expect( + clippy::match_same_arms, + reason = "wildcard pattern used in second one" + )] match (mode, context) { (FilterMode::Global, _) => IndexFilterMode::Global, (FilterMode::Directory, Some(ctx)) => { IndexFilterMode::Directory(with_trailing_slash(&ctx.cwd)) } - (FilterMode::Workspace, Some(ctx)) => { - if let Some(ref git_root) = ctx.git_root { - IndexFilterMode::Workspace(with_trailing_slash(git_root)) - } else { - // Fall back to directory if no git root - IndexFilterMode::Directory(with_trailing_slash(&ctx.cwd)) - } - } + (FilterMode::Workspace, Some(ctx)) => ctx.git_root.as_ref().map_or_else( + || IndexFilterMode::Directory(with_trailing_slash(&ctx.cwd)), + |git_root| IndexFilterMode::Workspace(with_trailing_slash(git_root)), + ), (FilterMode::Host, Some(ctx)) => IndexFilterMode::Host(ctx.hostname.clone()), (FilterMode::Session, Some(ctx)) => IndexFilterMode::Session(ctx.session_id.clone()), (FilterMode::SessionPreload, Some(ctx)) => { -- cgit v1.3.1