From 985dcf75230e0f12513e4e89d211618e5314c11d Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 26 Jun 2025 20:54:19 +0200 Subject: [PATCH] chore: Bump Rust version to 1.88 (#33439) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Goodies in this version: - if-let chains 🎉 - Better compiler perf for Zed (https://github.com/rust-lang/rust/pull/138522) For more, see: https://releases.rs/docs/1.88.0/ Release Notes: - N/A --------- Co-authored-by: Junkui Zhang <364772080@qq.com> --- Cargo.lock | 1 - Dockerfile-collab | 2 +- crates/agent_ui/src/buffer_codegen.rs | 6 -- crates/agent_ui/src/text_thread_editor.rs | 101 +----------------- .../src/delta_command.rs | 2 +- crates/buffer_diff/src/buffer_diff.rs | 2 +- crates/collab/src/db/tests/embedding_tests.rs | 5 +- crates/collab/src/rpc.rs | 4 +- crates/editor/src/editor.rs | 13 ++- crates/fs/src/fake_git_repo.rs | 55 +++++----- crates/git/src/repository.rs | 54 +++++----- crates/gpui/src/arena.rs | 26 ----- .../gpui/src/platform/blade/apple_compat.rs | 4 +- .../gpui/src/platform/linux/wayland/window.rs | 4 +- crates/gpui/src/platform/linux/x11/window.rs | 28 +---- crates/gpui/src/platform/windows/events.rs | 6 +- crates/gpui/src/platform/windows/window.rs | 12 +-- crates/gpui/src/text_system/line_layout.rs | 2 +- crates/gpui/src/util.rs | 28 ----- crates/multi_buffer/src/position.rs | 6 +- crates/project/src/git_store.rs | 4 +- crates/project/src/git_store/conflict_set.rs | 2 +- crates/project/src/lsp_store.rs | 5 +- crates/project/src/project_tests.rs | 4 +- crates/search/src/project_search.rs | 2 +- crates/terminal/src/terminal_hyperlinks.rs | 4 +- crates/theme_importer/Cargo.toml | 1 - crates/theme_importer/src/assets.rs | 27 ----- crates/theme_importer/src/main.rs | 1 - crates/worktree/src/worktree.rs | 2 +- rust-toolchain.toml | 2 +- 31 files changed, 112 insertions(+), 303 deletions(-) delete mode 100644 crates/theme_importer/src/assets.rs diff --git a/Cargo.lock b/Cargo.lock index f3bb4c11d2..473666a1a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16037,7 +16037,6 @@ dependencies = [ "indexmap", "log", "palette", - "rust-embed", "serde", "serde_json", "serde_json_lenient", diff --git a/Dockerfile-collab b/Dockerfile-collab index 48854af4da..2dafe296c7 100644 --- a/Dockerfile-collab +++ b/Dockerfile-collab @@ -1,6 +1,6 @@ # syntax = docker/dockerfile:1.2 -FROM rust:1.87-bookworm as builder +FROM rust:1.88-bookworm as builder WORKDIR app COPY . . diff --git a/crates/agent_ui/src/buffer_codegen.rs b/crates/agent_ui/src/buffer_codegen.rs index f3919a958f..117dcf4f8e 100644 --- a/crates/agent_ui/src/buffer_codegen.rs +++ b/crates/agent_ui/src/buffer_codegen.rs @@ -1094,15 +1094,9 @@ mod tests { }; use language_model::{LanguageModelRegistry, TokenUsage}; use rand::prelude::*; - use serde::Serialize; use settings::SettingsStore; use std::{future, sync::Arc}; - #[derive(Serialize)] - pub struct DummyCompletionRequest { - pub name: String, - } - #[gpui::test(iterations = 10)] async fn test_transform_autoindent(cx: &mut TestAppContext, mut rng: StdRng) { init_test(cx); diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index 0a1013a6f2..c035282c92 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -69,7 +69,7 @@ use workspace::{ searchable::{Direction, SearchableItemHandle}, }; use workspace::{ - Save, Toast, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace, + Save, Toast, Workspace, item::{self, FollowableItem, Item, ItemHandle}, notifications::NotificationId, pane, @@ -2924,13 +2924,6 @@ impl FollowableItem for TextThreadEditor { } } -pub struct ContextEditorToolbarItem { - active_context_editor: Option>, - model_summary_editor: Entity, -} - -impl ContextEditorToolbarItem {} - pub fn render_remaining_tokens( context_editor: &Entity, cx: &App, @@ -2983,98 +2976,6 @@ pub fn render_remaining_tokens( ) } -impl Render for ContextEditorToolbarItem { - fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - let left_side = h_flex() - .group("chat-title-group") - .gap_1() - .items_center() - .flex_grow() - .child( - div() - .w_full() - .when(self.active_context_editor.is_some(), |left_side| { - left_side.child(self.model_summary_editor.clone()) - }), - ) - .child( - div().visible_on_hover("chat-title-group").child( - IconButton::new("regenerate-context", IconName::RefreshTitle) - .shape(ui::IconButtonShape::Square) - .tooltip(Tooltip::text("Regenerate Title")) - .on_click(cx.listener(move |_, _, _window, cx| { - cx.emit(ContextEditorToolbarItemEvent::RegenerateSummary) - })), - ), - ); - - let right_side = h_flex() - .gap_2() - // TODO display this in a nicer way, once we have a design for it. - // .children({ - // let project = self - // .workspace - // .upgrade() - // .map(|workspace| workspace.read(cx).project().downgrade()); - // - // let scan_items_remaining = cx.update_global(|db: &mut SemanticDb, cx| { - // project.and_then(|project| db.remaining_summaries(&project, cx)) - // }); - // scan_items_remaining - // .map(|remaining_items| format!("Files to scan: {}", remaining_items)) - // }) - .children( - self.active_context_editor - .as_ref() - .and_then(|editor| editor.upgrade()) - .and_then(|editor| render_remaining_tokens(&editor, cx)), - ); - - h_flex() - .px_0p5() - .size_full() - .gap_2() - .justify_between() - .child(left_side) - .child(right_side) - } -} - -impl ToolbarItemView for ContextEditorToolbarItem { - fn set_active_pane_item( - &mut self, - active_pane_item: Option<&dyn ItemHandle>, - _window: &mut Window, - cx: &mut Context, - ) -> ToolbarItemLocation { - self.active_context_editor = active_pane_item - .and_then(|item| item.act_as::(cx)) - .map(|editor| editor.downgrade()); - cx.notify(); - if self.active_context_editor.is_none() { - ToolbarItemLocation::Hidden - } else { - ToolbarItemLocation::PrimaryRight - } - } - - fn pane_focus_update( - &mut self, - _pane_focused: bool, - _window: &mut Window, - cx: &mut Context, - ) { - cx.notify(); - } -} - -impl EventEmitter for ContextEditorToolbarItem {} - -pub enum ContextEditorToolbarItemEvent { - RegenerateSummary, -} -impl EventEmitter for ContextEditorToolbarItem {} - enum PendingSlashCommand {} fn invoked_slash_command_fold_placeholder( diff --git a/crates/assistant_slash_commands/src/delta_command.rs b/crates/assistant_slash_commands/src/delta_command.rs index 047d289908..8c840c17b2 100644 --- a/crates/assistant_slash_commands/src/delta_command.rs +++ b/crates/assistant_slash_commands/src/delta_command.rs @@ -74,7 +74,7 @@ impl SlashCommand for DeltaSlashCommand { .slice(section.range.to_offset(&context_buffer)), ); file_command_new_outputs.push(Arc::new(FileSlashCommand).run( - &[metadata.path.clone()], + std::slice::from_ref(&metadata.path), context_slash_command_output_sections, context_buffer.clone(), workspace.clone(), diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index 3812d48bf7..ee09fda46e 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -1867,7 +1867,7 @@ mod tests { let hunk = diff.hunks(&buffer, cx).next().unwrap(); let new_index_text = diff - .stage_or_unstage_hunks(true, &[hunk.clone()], &buffer, true, cx) + .stage_or_unstage_hunks(true, std::slice::from_ref(&hunk), &buffer, true, cx) .unwrap() .to_string(); assert_eq!(new_index_text, buffer_text); diff --git a/crates/collab/src/db/tests/embedding_tests.rs b/crates/collab/src/db/tests/embedding_tests.rs index 8659d4b4a1..bfc238dd9a 100644 --- a/crates/collab/src/db/tests/embedding_tests.rs +++ b/crates/collab/src/db/tests/embedding_tests.rs @@ -76,7 +76,10 @@ async fn test_purge_old_embeddings(cx: &mut gpui::TestAppContext) { db.purge_old_embeddings().await.unwrap(); // Try to retrieve the purged embeddings - let retrieved_embeddings = db.get_embeddings(model, &[digest.clone()]).await.unwrap(); + let retrieved_embeddings = db + .get_embeddings(model, std::slice::from_ref(&digest)) + .await + .unwrap(); assert!( retrieved_embeddings.is_empty(), "Old embeddings should have been purged" diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 22daab491c..753e591914 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -179,7 +179,7 @@ struct Session { } impl Session { - async fn db(&self) -> tokio::sync::MutexGuard { + async fn db(&self) -> tokio::sync::MutexGuard<'_, DbHandle> { #[cfg(test)] tokio::task::yield_now().await; let guard = self.db.lock().await; @@ -1037,7 +1037,7 @@ impl Server { } } - pub async fn snapshot(self: &Arc) -> ServerSnapshot { + pub async fn snapshot(self: &Arc) -> ServerSnapshot<'_> { ServerSnapshot { connection_pool: ConnectionPoolGuard { guard: self.connection_pool.lock(), diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index ea30cc6fab..6244e7a4c3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -3897,8 +3897,10 @@ impl Editor { bracket_pair_matching_end = Some(pair.clone()); } } - if bracket_pair.is_none() && bracket_pair_matching_end.is_some() { - bracket_pair = Some(bracket_pair_matching_end.unwrap()); + if let Some(end) = bracket_pair_matching_end + && bracket_pair.is_none() + { + bracket_pair = Some(end); is_bracket_pair_end = true; } } @@ -13381,7 +13383,12 @@ impl Editor { window: &mut Window, cx: &mut Context, ) { - self.unfold_ranges(&[range.clone()], false, auto_scroll.is_some(), cx); + self.unfold_ranges( + std::slice::from_ref(&range), + false, + auto_scroll.is_some(), + cx, + ); self.change_selections(auto_scroll, window, cx, |s| { if replace_newest { s.delete(s.newest_anchor().id); diff --git a/crates/fs/src/fake_git_repo.rs b/crates/fs/src/fake_git_repo.rs index c6e0afe294..40a292e040 100644 --- a/crates/fs/src/fake_git_repo.rs +++ b/crates/fs/src/fake_git_repo.rs @@ -74,7 +74,7 @@ impl FakeGitRepository { impl GitRepository for FakeGitRepository { fn reload_index(&self) {} - fn load_index_text(&self, path: RepoPath) -> BoxFuture> { + fn load_index_text(&self, path: RepoPath) -> BoxFuture<'_, Option> { async { self.with_state_async(false, move |state| { state @@ -89,7 +89,7 @@ impl GitRepository for FakeGitRepository { .boxed() } - fn load_committed_text(&self, path: RepoPath) -> BoxFuture> { + fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option> { async { self.with_state_async(false, move |state| { state @@ -108,7 +108,7 @@ impl GitRepository for FakeGitRepository { &self, _commit: String, _cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { unimplemented!() } @@ -117,7 +117,7 @@ impl GitRepository for FakeGitRepository { path: RepoPath, content: Option, _env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, anyhow::Result<()>> { self.with_state_async(true, move |state| { if let Some(message) = &state.simulated_index_write_error_message { anyhow::bail!("{message}"); @@ -134,7 +134,7 @@ impl GitRepository for FakeGitRepository { None } - fn revparse_batch(&self, revs: Vec) -> BoxFuture>>> { + fn revparse_batch(&self, revs: Vec) -> BoxFuture<'_, Result>>> { self.with_state_async(false, |state| { Ok(revs .into_iter() @@ -143,7 +143,7 @@ impl GitRepository for FakeGitRepository { }) } - fn show(&self, commit: String) -> BoxFuture> { + fn show(&self, commit: String) -> BoxFuture<'_, Result> { async { Ok(CommitDetails { sha: commit.into(), @@ -158,7 +158,7 @@ impl GitRepository for FakeGitRepository { _commit: String, _mode: ResetMode, _env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { unimplemented!() } @@ -167,7 +167,7 @@ impl GitRepository for FakeGitRepository { _commit: String, _paths: Vec, _env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { unimplemented!() } @@ -179,11 +179,11 @@ impl GitRepository for FakeGitRepository { self.common_dir_path.clone() } - fn merge_message(&self) -> BoxFuture> { + fn merge_message(&self) -> BoxFuture<'_, Option> { async move { None }.boxed() } - fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture> { + fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result> { let workdir_path = self.dot_git_path.parent().unwrap(); // Load gitignores @@ -314,7 +314,7 @@ impl GitRepository for FakeGitRepository { async move { result? }.boxed() } - fn branches(&self) -> BoxFuture>> { + fn branches(&self) -> BoxFuture<'_, Result>> { self.with_state_async(false, move |state| { let current_branch = &state.current_branch_name; Ok(state @@ -330,21 +330,21 @@ impl GitRepository for FakeGitRepository { }) } - fn change_branch(&self, name: String) -> BoxFuture> { + fn change_branch(&self, name: String) -> BoxFuture<'_, Result<()>> { self.with_state_async(true, |state| { state.current_branch_name = Some(name); Ok(()) }) } - fn create_branch(&self, name: String) -> BoxFuture> { + fn create_branch(&self, name: String) -> BoxFuture<'_, Result<()>> { self.with_state_async(true, move |state| { state.branches.insert(name.to_owned()); Ok(()) }) } - fn blame(&self, path: RepoPath, _content: Rope) -> BoxFuture> { + fn blame(&self, path: RepoPath, _content: Rope) -> BoxFuture<'_, Result> { self.with_state_async(false, move |state| { state .blames @@ -358,7 +358,7 @@ impl GitRepository for FakeGitRepository { &self, _paths: Vec, _env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { unimplemented!() } @@ -366,7 +366,7 @@ impl GitRepository for FakeGitRepository { &self, _paths: Vec, _env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { unimplemented!() } @@ -376,7 +376,7 @@ impl GitRepository for FakeGitRepository { _name_and_email: Option<(gpui::SharedString, gpui::SharedString)>, _options: CommitOptions, _env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { unimplemented!() } @@ -388,7 +388,7 @@ impl GitRepository for FakeGitRepository { _askpass: AskPassDelegate, _env: Arc>, _cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { unimplemented!() } @@ -399,7 +399,7 @@ impl GitRepository for FakeGitRepository { _askpass: AskPassDelegate, _env: Arc>, _cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { unimplemented!() } @@ -409,19 +409,19 @@ impl GitRepository for FakeGitRepository { _askpass: AskPassDelegate, _env: Arc>, _cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { unimplemented!() } - fn get_remotes(&self, _branch: Option) -> BoxFuture>> { + fn get_remotes(&self, _branch: Option) -> BoxFuture<'_, Result>> { unimplemented!() } - fn check_for_pushed_commit(&self) -> BoxFuture>> { + fn check_for_pushed_commit(&self) -> BoxFuture<'_, Result>> { future::ready(Ok(Vec::new())).boxed() } - fn diff(&self, _diff: git::repository::DiffType) -> BoxFuture> { + fn diff(&self, _diff: git::repository::DiffType) -> BoxFuture<'_, Result> { unimplemented!() } @@ -429,7 +429,10 @@ impl GitRepository for FakeGitRepository { unimplemented!() } - fn restore_checkpoint(&self, _checkpoint: GitRepositoryCheckpoint) -> BoxFuture> { + fn restore_checkpoint( + &self, + _checkpoint: GitRepositoryCheckpoint, + ) -> BoxFuture<'_, Result<()>> { unimplemented!() } @@ -437,7 +440,7 @@ impl GitRepository for FakeGitRepository { &self, _left: GitRepositoryCheckpoint, _right: GitRepositoryCheckpoint, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { unimplemented!() } @@ -445,7 +448,7 @@ impl GitRepository for FakeGitRepository { &self, _base_checkpoint: GitRepositoryCheckpoint, _target_checkpoint: GitRepositoryCheckpoint, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { unimplemented!() } } diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 1254e451fd..7b07cb62a1 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -303,25 +303,25 @@ pub trait GitRepository: Send + Sync { /// Returns the contents of an entry in the repository's index, or None if there is no entry for the given path. /// /// Also returns `None` for symlinks. - fn load_index_text(&self, path: RepoPath) -> BoxFuture>; + fn load_index_text(&self, path: RepoPath) -> BoxFuture<'_, Option>; /// Returns the contents of an entry in the repository's HEAD, or None if HEAD does not exist or has no entry for the given path. /// /// Also returns `None` for symlinks. - fn load_committed_text(&self, path: RepoPath) -> BoxFuture>; + fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option>; fn set_index_text( &self, path: RepoPath, content: Option, env: Arc>, - ) -> BoxFuture>; + ) -> BoxFuture<'_, anyhow::Result<()>>; /// Returns the URL of the remote with the given name. fn remote_url(&self, name: &str) -> Option; /// Resolve a list of refs to SHAs. - fn revparse_batch(&self, revs: Vec) -> BoxFuture>>>; + fn revparse_batch(&self, revs: Vec) -> BoxFuture<'_, Result>>>; fn head_sha(&self) -> BoxFuture<'_, Option> { async move { @@ -335,33 +335,33 @@ pub trait GitRepository: Send + Sync { .boxed() } - fn merge_message(&self) -> BoxFuture>; + fn merge_message(&self) -> BoxFuture<'_, Option>; - fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture>; + fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result>; - fn branches(&self) -> BoxFuture>>; + fn branches(&self) -> BoxFuture<'_, Result>>; - fn change_branch(&self, name: String) -> BoxFuture>; - fn create_branch(&self, name: String) -> BoxFuture>; + fn change_branch(&self, name: String) -> BoxFuture<'_, Result<()>>; + fn create_branch(&self, name: String) -> BoxFuture<'_, Result<()>>; fn reset( &self, commit: String, mode: ResetMode, env: Arc>, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<()>>; fn checkout_files( &self, commit: String, paths: Vec, env: Arc>, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<()>>; - fn show(&self, commit: String) -> BoxFuture>; + fn show(&self, commit: String) -> BoxFuture<'_, Result>; - fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture>; - fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture>; + fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result>; + fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result>; /// Returns the absolute path to the repository. For worktrees, this will be the path to the /// worktree's gitdir within the main repository (typically `.git/worktrees/`). @@ -376,7 +376,7 @@ pub trait GitRepository: Send + Sync { &self, paths: Vec, env: Arc>, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<()>>; /// Updates the index to match HEAD at the given paths. /// /// If any of the paths were previously staged but do not exist in HEAD, they will be removed from the index. @@ -384,7 +384,7 @@ pub trait GitRepository: Send + Sync { &self, paths: Vec, env: Arc>, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<()>>; fn commit( &self, @@ -392,7 +392,7 @@ pub trait GitRepository: Send + Sync { name_and_email: Option<(SharedString, SharedString)>, options: CommitOptions, env: Arc>, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result<()>>; fn push( &self, @@ -404,7 +404,7 @@ pub trait GitRepository: Send + Sync { // This method takes an AsyncApp to ensure it's invoked on the main thread, // otherwise git-credentials-manager won't work. cx: AsyncApp, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result>; fn pull( &self, @@ -415,7 +415,7 @@ pub trait GitRepository: Send + Sync { // This method takes an AsyncApp to ensure it's invoked on the main thread, // otherwise git-credentials-manager won't work. cx: AsyncApp, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result>; fn fetch( &self, @@ -425,35 +425,35 @@ pub trait GitRepository: Send + Sync { // This method takes an AsyncApp to ensure it's invoked on the main thread, // otherwise git-credentials-manager won't work. cx: AsyncApp, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result>; - fn get_remotes(&self, branch_name: Option) -> BoxFuture>>; + fn get_remotes(&self, branch_name: Option) -> BoxFuture<'_, Result>>; /// returns a list of remote branches that contain HEAD - fn check_for_pushed_commit(&self) -> BoxFuture>>; + fn check_for_pushed_commit(&self) -> BoxFuture<'_, Result>>; /// Run git diff - fn diff(&self, diff: DiffType) -> BoxFuture>; + fn diff(&self, diff: DiffType) -> BoxFuture<'_, Result>; /// Creates a checkpoint for the repository. fn checkpoint(&self) -> BoxFuture<'static, Result>; /// Resets to a previously-created checkpoint. - fn restore_checkpoint(&self, checkpoint: GitRepositoryCheckpoint) -> BoxFuture>; + fn restore_checkpoint(&self, checkpoint: GitRepositoryCheckpoint) -> BoxFuture<'_, Result<()>>; /// Compares two checkpoints, returning true if they are equal fn compare_checkpoints( &self, left: GitRepositoryCheckpoint, right: GitRepositoryCheckpoint, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result>; /// Computes a diff between two checkpoints. fn diff_checkpoints( &self, base_checkpoint: GitRepositoryCheckpoint, target_checkpoint: GitRepositoryCheckpoint, - ) -> BoxFuture>; + ) -> BoxFuture<'_, Result>; } pub enum DiffType { @@ -2268,7 +2268,7 @@ mod tests { impl RealGitRepository { /// Force a Git garbage collection on the repository. - fn gc(&self) -> BoxFuture> { + fn gc(&self) -> BoxFuture<'_, Result<()>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); let executor = self.executor.clone(); diff --git a/crates/gpui/src/arena.rs b/crates/gpui/src/arena.rs index 2448746a88..ee72d0e964 100644 --- a/crates/gpui/src/arena.rs +++ b/crates/gpui/src/arena.rs @@ -214,32 +214,6 @@ impl DerefMut for ArenaBox { } } -pub struct ArenaRef(ArenaBox); - -impl From> for ArenaRef { - fn from(value: ArenaBox) -> Self { - ArenaRef(value) - } -} - -impl Clone for ArenaRef { - fn clone(&self) -> Self { - Self(ArenaBox { - ptr: self.0.ptr, - valid: self.0.valid.clone(), - }) - } -} - -impl Deref for ArenaRef { - type Target = T; - - #[inline(always)] - fn deref(&self) -> &Self::Target { - self.0.deref() - } -} - #[cfg(test)] mod tests { use std::{cell::Cell, rc::Rc}; diff --git a/crates/gpui/src/platform/blade/apple_compat.rs b/crates/gpui/src/platform/blade/apple_compat.rs index b1baab8854..a75ddfa69a 100644 --- a/crates/gpui/src/platform/blade/apple_compat.rs +++ b/crates/gpui/src/platform/blade/apple_compat.rs @@ -29,14 +29,14 @@ pub unsafe fn new_renderer( } impl rwh::HasWindowHandle for RawWindow { - fn window_handle(&self) -> Result { + fn window_handle(&self) -> Result, rwh::HandleError> { let view = NonNull::new(self.view).unwrap(); let handle = rwh::AppKitWindowHandle::new(view); Ok(unsafe { rwh::WindowHandle::borrow_raw(handle.into()) }) } } impl rwh::HasDisplayHandle for RawWindow { - fn display_handle(&self) -> Result { + fn display_handle(&self) -> Result, rwh::HandleError> { let handle = rwh::AppKitDisplayHandle::new(); Ok(unsafe { rwh::DisplayHandle::borrow_raw(handle.into()) }) } diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 9d602130d4..36e070b0b0 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -252,11 +252,11 @@ impl Drop for WaylandWindow { } impl WaylandWindow { - fn borrow(&self) -> Ref { + fn borrow(&self) -> Ref<'_, WaylandWindowState> { self.0.state.borrow() } - fn borrow_mut(&self) -> RefMut { + fn borrow_mut(&self) -> RefMut<'_, WaylandWindowState> { self.0.state.borrow_mut() } diff --git a/crates/gpui/src/platform/linux/x11/window.rs b/crates/gpui/src/platform/linux/x11/window.rs index 248911a5b9..1a3c323c35 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -288,7 +288,7 @@ pub(crate) struct X11WindowStatePtr { } impl rwh::HasWindowHandle for RawWindow { - fn window_handle(&self) -> Result { + fn window_handle(&self) -> Result, rwh::HandleError> { let Some(non_zero) = NonZeroU32::new(self.window_id) else { log::error!("RawWindow.window_id zero when getting window handle."); return Err(rwh::HandleError::Unavailable); @@ -299,7 +299,7 @@ impl rwh::HasWindowHandle for RawWindow { } } impl rwh::HasDisplayHandle for RawWindow { - fn display_handle(&self) -> Result { + fn display_handle(&self) -> Result, rwh::HandleError> { let Some(non_zero) = NonNull::new(self.connection) else { log::error!("Null RawWindow.connection when getting display handle."); return Err(rwh::HandleError::Unavailable); @@ -310,12 +310,12 @@ impl rwh::HasDisplayHandle for RawWindow { } impl rwh::HasWindowHandle for X11Window { - fn window_handle(&self) -> Result { + fn window_handle(&self) -> Result, rwh::HandleError> { unimplemented!() } } impl rwh::HasDisplayHandle for X11Window { - fn display_handle(&self) -> Result { + fn display_handle(&self) -> Result, rwh::HandleError> { unimplemented!() } } @@ -679,26 +679,6 @@ impl X11WindowState { } } -/// A handle to an X11 window which destroys it on Drop. -pub struct X11WindowHandle { - id: xproto::Window, - xcb: Rc, -} - -impl Drop for X11WindowHandle { - fn drop(&mut self) { - maybe!({ - check_reply( - || "X11 DestroyWindow failed while dropping X11WindowHandle.", - self.xcb.destroy_window(self.id), - )?; - xcb_flush(&self.xcb); - anyhow::Ok(()) - }) - .log_err(); - } -} - pub(crate) struct X11Window(pub X11WindowStatePtr); impl Drop for X11Window { diff --git a/crates/gpui/src/platform/windows/events.rs b/crates/gpui/src/platform/windows/events.rs index 65565c6b3f..d7205580cd 100644 --- a/crates/gpui/src/platform/windows/events.rs +++ b/crates/gpui/src/platform/windows/events.rs @@ -1074,8 +1074,10 @@ fn handle_nc_mouse_up_msg( } let last_pressed = state_ptr.state.borrow_mut().nc_button_pressed.take(); - if button == MouseButton::Left && last_pressed.is_some() { - let handled = match (wparam.0 as u32, last_pressed.unwrap()) { + if button == MouseButton::Left + && let Some(last_pressed) = last_pressed + { + let handled = match (wparam.0 as u32, last_pressed) { (HTMINBUTTON, HTMINBUTTON) => { unsafe { ShowWindowAsync(handle, SW_MINIMIZE).ok().log_err() }; true diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index e84840fb25..c363d5854d 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -1250,11 +1250,13 @@ fn set_window_composition_attribute(hwnd: HWND, color: Option, state: u32 type SetWindowCompositionAttributeType = unsafe extern "system" fn(HWND, *mut WINDOWCOMPOSITIONATTRIBDATA) -> BOOL; let module_name = PCSTR::from_raw(c"user32.dll".as_ptr() as *const u8); - let user32 = GetModuleHandleA(module_name); - if user32.is_ok() { + if let Some(user32) = GetModuleHandleA(module_name) + .context("Unable to get user32.dll handle") + .log_err() + { let func_name = PCSTR::from_raw(c"SetWindowCompositionAttribute".as_ptr() as *const u8); let set_window_composition_attribute: SetWindowCompositionAttributeType = - std::mem::transmute(GetProcAddress(user32.unwrap(), func_name)); + std::mem::transmute(GetProcAddress(user32, func_name)); let mut color = color.unwrap_or_default(); let is_acrylic = state == 4; if is_acrylic && color.3 == 0 { @@ -1275,10 +1277,6 @@ fn set_window_composition_attribute(hwnd: HWND, color: Option, state: u32 cb_data: std::mem::size_of::(), }; let _ = set_window_composition_attribute(hwnd, &mut data as *mut _ as _); - } else { - let _ = user32 - .inspect_err(|e| log::error!("Error getting module: {e}")) - .ok(); } } } diff --git a/crates/gpui/src/text_system/line_layout.rs b/crates/gpui/src/text_system/line_layout.rs index 5e5c2eff1e..5a72080e48 100644 --- a/crates/gpui/src/text_system/line_layout.rs +++ b/crates/gpui/src/text_system/line_layout.rs @@ -582,7 +582,7 @@ pub struct FontRun { } trait AsCacheKeyRef { - fn as_cache_key_ref(&self) -> CacheKeyRef; + fn as_cache_key_ref(&self) -> CacheKeyRef<'_>; } #[derive(Clone, Debug, Eq)] diff --git a/crates/gpui/src/util.rs b/crates/gpui/src/util.rs index fda5e81333..5e92335fdc 100644 --- a/crates/gpui/src/util.rs +++ b/crates/gpui/src/util.rs @@ -83,34 +83,6 @@ where timer.race(future).await } -#[cfg(any(test, feature = "test-support"))] -pub struct CwdBacktrace<'a>(pub &'a backtrace::Backtrace); - -#[cfg(any(test, feature = "test-support"))] -impl std::fmt::Debug for CwdBacktrace<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - use backtrace::{BacktraceFmt, BytesOrWideString}; - - let cwd = std::env::current_dir().unwrap(); - let cwd = cwd.parent().unwrap(); - let mut print_path = |fmt: &mut std::fmt::Formatter<'_>, path: BytesOrWideString<'_>| { - std::fmt::Display::fmt(&path, fmt) - }; - let mut fmt = BacktraceFmt::new(f, backtrace::PrintFmt::Full, &mut print_path); - for frame in self.0.frames() { - let mut formatted_frame = fmt.frame(); - if frame - .symbols() - .iter() - .any(|s| s.filename().map_or(false, |f| f.starts_with(cwd))) - { - formatted_frame.backtrace_frame(frame)?; - } - } - fmt.finish() - } -} - /// Increment the given atomic counter if it is not zero. /// Return the new value of the counter. pub(crate) fn atomic_incr_if_not_zero(counter: &AtomicUsize) -> usize { diff --git a/crates/multi_buffer/src/position.rs b/crates/multi_buffer/src/position.rs index 1ed2fe56e4..0650875059 100644 --- a/crates/multi_buffer/src/position.rs +++ b/crates/multi_buffer/src/position.rs @@ -126,17 +126,17 @@ impl Default for TypedRow { impl PartialOrd for TypedOffset { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.value.cmp(&other.value)) + Some(self.cmp(&other)) } } impl PartialOrd for TypedPoint { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.value.cmp(&other.value)) + Some(self.cmp(&other)) } } impl PartialOrd for TypedRow { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.value.cmp(&other.value)) + Some(self.cmp(&other)) } } diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index 7002f83ab3..9ff3823e0f 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -4556,7 +4556,9 @@ async fn compute_snapshot( let mut events = Vec::new(); let branches = backend.branches().await?; let branch = branches.into_iter().find(|branch| branch.is_head); - let statuses = backend.status(&[WORK_DIRECTORY_REPO_PATH.clone()]).await?; + let statuses = backend + .status(std::slice::from_ref(&WORK_DIRECTORY_REPO_PATH)) + .await?; let statuses_by_path = SumTree::from_iter( statuses .entries diff --git a/crates/project/src/git_store/conflict_set.rs b/crates/project/src/git_store/conflict_set.rs index e78a70f275..27b191f65f 100644 --- a/crates/project/src/git_store/conflict_set.rs +++ b/crates/project/src/git_store/conflict_set.rs @@ -565,7 +565,7 @@ mod tests { conflict_set.snapshot().conflicts[0].clone() }); cx.update(|cx| { - conflict.resolve(buffer.clone(), &[conflict.theirs.clone()], cx); + conflict.resolve(buffer.clone(), std::slice::from_ref(&conflict.theirs), cx); }); cx.run_until_parked(); diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index 950e391a1d..6e56dec999 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -5743,7 +5743,10 @@ impl LspStore { match language { Some(language) => { adapter - .labels_for_completions(&[completion_item.clone()], language) + .labels_for_completions( + std::slice::from_ref(&completion_item), + language, + ) .await? } None => Vec::new(), diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 19b88c0695..54a013bc41 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -7502,13 +7502,13 @@ async fn test_staging_random_hunks( if hunk.status().has_secondary_hunk() { log::info!("staging hunk at {row}"); uncommitted_diff.update(cx, |diff, cx| { - diff.stage_or_unstage_hunks(true, &[hunk.clone()], &snapshot, true, cx); + diff.stage_or_unstage_hunks(true, std::slice::from_ref(hunk), &snapshot, true, cx); }); hunk.secondary_status = SecondaryHunkRemovalPending; } else { log::info!("unstaging hunk at {row}"); uncommitted_diff.update(cx, |diff, cx| { - diff.stage_or_unstage_hunks(false, &[hunk.clone()], &snapshot, true, cx); + diff.stage_or_unstage_hunks(false, std::slice::from_ref(hunk), &snapshot, true, cx); }); hunk.secondary_status = SecondaryHunkAdditionPending; } diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 79ae18fcfe..8e1ea3d773 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -1302,7 +1302,7 @@ impl ProjectSearchView { let range_to_select = match_ranges[new_index].clone(); self.results_editor.update(cx, |editor, cx| { let range_to_select = editor.range_for_match(&range_to_select); - editor.unfold_ranges(&[range_to_select.clone()], false, true, cx); + editor.unfold_ranges(std::slice::from_ref(&range_to_select), false, true, cx); editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| { s.select_ranges([range_to_select]) }); diff --git a/crates/terminal/src/terminal_hyperlinks.rs b/crates/terminal/src/terminal_hyperlinks.rs index 18675bbe02..e318ae21bd 100644 --- a/crates/terminal/src/terminal_hyperlinks.rs +++ b/crates/terminal/src/terminal_hyperlinks.rs @@ -52,7 +52,7 @@ pub(super) fn find_from_grid_point( ) -> Option<(String, bool, Match)> { let grid = term.grid(); let link = grid.index(point).hyperlink(); - let found_word = if link.is_some() { + let found_word = if let Some(ref url) = link { let mut min_index = point; loop { let new_min_index = min_index.sub(term, Boundary::Cursor, 1); @@ -73,7 +73,7 @@ pub(super) fn find_from_grid_point( } } - let url = link.unwrap().uri().to_owned(); + let url = url.uri().to_owned(); let url_match = min_index..=max_index; Some((url, true, url_match)) diff --git a/crates/theme_importer/Cargo.toml b/crates/theme_importer/Cargo.toml index 0fc3206d5c..f9f7daa5b3 100644 --- a/crates/theme_importer/Cargo.toml +++ b/crates/theme_importer/Cargo.toml @@ -15,7 +15,6 @@ gpui.workspace = true indexmap.workspace = true log.workspace = true palette.workspace = true -rust-embed.workspace = true serde.workspace = true serde_json.workspace = true serde_json_lenient.workspace = true diff --git a/crates/theme_importer/src/assets.rs b/crates/theme_importer/src/assets.rs deleted file mode 100644 index 56e6ed46ed..0000000000 --- a/crates/theme_importer/src/assets.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::borrow::Cow; - -use anyhow::{Context as _, Result}; -use gpui::{AssetSource, SharedString}; -use rust_embed::RustEmbed; - -#[derive(RustEmbed)] -#[folder = "../../assets"] -#[include = "fonts/**/*"] -#[exclude = "*.DS_Store"] -pub struct Assets; - -impl AssetSource for Assets { - fn load(&self, path: &str) -> Result>> { - Self::get(path) - .map(|f| f.data) - .with_context(|| format!("could not find asset at path {path:?}")) - .map(Some) - } - - fn list(&self, path: &str) -> Result> { - Ok(Self::iter() - .filter(|p| p.starts_with(path)) - .map(SharedString::from) - .collect()) - } -} diff --git a/crates/theme_importer/src/main.rs b/crates/theme_importer/src/main.rs index c2ceee4cfc..ebb2840d04 100644 --- a/crates/theme_importer/src/main.rs +++ b/crates/theme_importer/src/main.rs @@ -1,4 +1,3 @@ -mod assets; mod color; mod vscode; diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 6b3a0b855f..8c407fdd3e 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -3911,7 +3911,7 @@ impl BackgroundScanner { let Ok(request) = path_prefix_request else { break }; log::trace!("adding path prefix {:?}", request.path); - let did_scan = self.forcibly_load_paths(&[request.path.clone()]).await; + let did_scan = self.forcibly_load_paths(std::slice::from_ref(&request.path)).await; if did_scan { let abs_path = { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a7a9ac8295..f80eab8fbc 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.87" +channel = "1.88" profile = "minimal" components = [ "rustfmt", "clippy" ] targets = [