Cargo.lock 🔗
@@ -16037,7 +16037,6 @@ dependencies = [
"indexmap",
"log",
"palette",
- "rust-embed",
"serde",
"serde_json",
"serde_json_lenient",
Piotr Osiewicz and Junkui Zhang created
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 -------------
crates/assistant_slash_commands/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 ---
crates/gpui/src/platform/blade/apple_compat.rs | 4
crates/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(-)
@@ -16037,7 +16037,6 @@ dependencies = [
"indexmap",
"log",
"palette",
- "rust-embed",
"serde",
"serde_json",
"serde_json_lenient",
@@ -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 . .
@@ -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);
@@ -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<WeakEntity<TextThreadEditor>>,
- model_summary_editor: Entity<Editor>,
-}
-
-impl ContextEditorToolbarItem {}
-
pub fn render_remaining_tokens(
context_editor: &Entity<TextThreadEditor>,
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<Self>) -> 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<Self>,
- ) -> ToolbarItemLocation {
- self.active_context_editor = active_pane_item
- .and_then(|item| item.act_as::<TextThreadEditor>(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<Self>,
- ) {
- cx.notify();
- }
-}
-
-impl EventEmitter<ToolbarItemEvent> for ContextEditorToolbarItem {}
-
-pub enum ContextEditorToolbarItemEvent {
- RegenerateSummary,
-}
-impl EventEmitter<ContextEditorToolbarItemEvent> for ContextEditorToolbarItem {}
-
enum PendingSlashCommand {}
fn invoked_slash_command_fold_placeholder(
@@ -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(),
@@ -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);
@@ -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"
@@ -179,7 +179,7 @@ struct Session {
}
impl Session {
- async fn db(&self) -> tokio::sync::MutexGuard<DbHandle> {
+ 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<Self>) -> ServerSnapshot {
+ pub async fn snapshot(self: &Arc<Self>) -> ServerSnapshot<'_> {
ServerSnapshot {
connection_pool: ConnectionPoolGuard {
guard: self.connection_pool.lock(),
@@ -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<Editor>,
) {
- 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);
@@ -74,7 +74,7 @@ impl FakeGitRepository {
impl GitRepository for FakeGitRepository {
fn reload_index(&self) {}
- fn load_index_text(&self, path: RepoPath) -> BoxFuture<Option<String>> {
+ fn load_index_text(&self, path: RepoPath) -> BoxFuture<'_, Option<String>> {
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<Option<String>> {
+ fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option<String>> {
async {
self.with_state_async(false, move |state| {
state
@@ -108,7 +108,7 @@ impl GitRepository for FakeGitRepository {
&self,
_commit: String,
_cx: AsyncApp,
- ) -> BoxFuture<Result<git::repository::CommitDiff>> {
+ ) -> BoxFuture<'_, Result<git::repository::CommitDiff>> {
unimplemented!()
}
@@ -117,7 +117,7 @@ impl GitRepository for FakeGitRepository {
path: RepoPath,
content: Option<String>,
_env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<anyhow::Result<()>> {
+ ) -> 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<String>) -> BoxFuture<Result<Vec<Option<String>>>> {
+ fn revparse_batch(&self, revs: Vec<String>) -> BoxFuture<'_, Result<Vec<Option<String>>>> {
self.with_state_async(false, |state| {
Ok(revs
.into_iter()
@@ -143,7 +143,7 @@ impl GitRepository for FakeGitRepository {
})
}
- fn show(&self, commit: String) -> BoxFuture<Result<CommitDetails>> {
+ fn show(&self, commit: String) -> BoxFuture<'_, Result<CommitDetails>> {
async {
Ok(CommitDetails {
sha: commit.into(),
@@ -158,7 +158,7 @@ impl GitRepository for FakeGitRepository {
_commit: String,
_mode: ResetMode,
_env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>> {
+ ) -> BoxFuture<'_, Result<()>> {
unimplemented!()
}
@@ -167,7 +167,7 @@ impl GitRepository for FakeGitRepository {
_commit: String,
_paths: Vec<RepoPath>,
_env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>> {
+ ) -> BoxFuture<'_, Result<()>> {
unimplemented!()
}
@@ -179,11 +179,11 @@ impl GitRepository for FakeGitRepository {
self.common_dir_path.clone()
}
- fn merge_message(&self) -> BoxFuture<Option<String>> {
+ fn merge_message(&self) -> BoxFuture<'_, Option<String>> {
async move { None }.boxed()
}
- fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<Result<GitStatus>> {
+ fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result<GitStatus>> {
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<Result<Vec<Branch>>> {
+ fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>> {
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<Result<()>> {
+ 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<Result<()>> {
+ 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<Result<git::blame::Blame>> {
+ fn blame(&self, path: RepoPath, _content: Rope) -> BoxFuture<'_, Result<git::blame::Blame>> {
self.with_state_async(false, move |state| {
state
.blames
@@ -358,7 +358,7 @@ impl GitRepository for FakeGitRepository {
&self,
_paths: Vec<RepoPath>,
_env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>> {
+ ) -> BoxFuture<'_, Result<()>> {
unimplemented!()
}
@@ -366,7 +366,7 @@ impl GitRepository for FakeGitRepository {
&self,
_paths: Vec<RepoPath>,
_env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>> {
+ ) -> BoxFuture<'_, Result<()>> {
unimplemented!()
}
@@ -376,7 +376,7 @@ impl GitRepository for FakeGitRepository {
_name_and_email: Option<(gpui::SharedString, gpui::SharedString)>,
_options: CommitOptions,
_env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>> {
+ ) -> BoxFuture<'_, Result<()>> {
unimplemented!()
}
@@ -388,7 +388,7 @@ impl GitRepository for FakeGitRepository {
_askpass: AskPassDelegate,
_env: Arc<HashMap<String, String>>,
_cx: AsyncApp,
- ) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> {
+ ) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
unimplemented!()
}
@@ -399,7 +399,7 @@ impl GitRepository for FakeGitRepository {
_askpass: AskPassDelegate,
_env: Arc<HashMap<String, String>>,
_cx: AsyncApp,
- ) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> {
+ ) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
unimplemented!()
}
@@ -409,19 +409,19 @@ impl GitRepository for FakeGitRepository {
_askpass: AskPassDelegate,
_env: Arc<HashMap<String, String>>,
_cx: AsyncApp,
- ) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> {
+ ) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
unimplemented!()
}
- fn get_remotes(&self, _branch: Option<String>) -> BoxFuture<Result<Vec<Remote>>> {
+ fn get_remotes(&self, _branch: Option<String>) -> BoxFuture<'_, Result<Vec<Remote>>> {
unimplemented!()
}
- fn check_for_pushed_commit(&self) -> BoxFuture<Result<Vec<gpui::SharedString>>> {
+ fn check_for_pushed_commit(&self) -> BoxFuture<'_, Result<Vec<gpui::SharedString>>> {
future::ready(Ok(Vec::new())).boxed()
}
- fn diff(&self, _diff: git::repository::DiffType) -> BoxFuture<Result<String>> {
+ fn diff(&self, _diff: git::repository::DiffType) -> BoxFuture<'_, Result<String>> {
unimplemented!()
}
@@ -429,7 +429,10 @@ impl GitRepository for FakeGitRepository {
unimplemented!()
}
- fn restore_checkpoint(&self, _checkpoint: GitRepositoryCheckpoint) -> BoxFuture<Result<()>> {
+ fn restore_checkpoint(
+ &self,
+ _checkpoint: GitRepositoryCheckpoint,
+ ) -> BoxFuture<'_, Result<()>> {
unimplemented!()
}
@@ -437,7 +440,7 @@ impl GitRepository for FakeGitRepository {
&self,
_left: GitRepositoryCheckpoint,
_right: GitRepositoryCheckpoint,
- ) -> BoxFuture<Result<bool>> {
+ ) -> BoxFuture<'_, Result<bool>> {
unimplemented!()
}
@@ -445,7 +448,7 @@ impl GitRepository for FakeGitRepository {
&self,
_base_checkpoint: GitRepositoryCheckpoint,
_target_checkpoint: GitRepositoryCheckpoint,
- ) -> BoxFuture<Result<String>> {
+ ) -> BoxFuture<'_, Result<String>> {
unimplemented!()
}
}
@@ -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<Option<String>>;
+ fn load_index_text(&self, path: RepoPath) -> BoxFuture<'_, Option<String>>;
/// 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<Option<String>>;
+ fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option<String>>;
fn set_index_text(
&self,
path: RepoPath,
content: Option<String>,
env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<anyhow::Result<()>>;
+ ) -> BoxFuture<'_, anyhow::Result<()>>;
/// Returns the URL of the remote with the given name.
fn remote_url(&self, name: &str) -> Option<String>;
/// Resolve a list of refs to SHAs.
- fn revparse_batch(&self, revs: Vec<String>) -> BoxFuture<Result<Vec<Option<String>>>>;
+ fn revparse_batch(&self, revs: Vec<String>) -> BoxFuture<'_, Result<Vec<Option<String>>>>;
fn head_sha(&self) -> BoxFuture<'_, Option<String>> {
async move {
@@ -335,33 +335,33 @@ pub trait GitRepository: Send + Sync {
.boxed()
}
- fn merge_message(&self) -> BoxFuture<Option<String>>;
+ fn merge_message(&self) -> BoxFuture<'_, Option<String>>;
- fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<Result<GitStatus>>;
+ fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result<GitStatus>>;
- fn branches(&self) -> BoxFuture<Result<Vec<Branch>>>;
+ fn branches(&self) -> BoxFuture<'_, Result<Vec<Branch>>>;
- fn change_branch(&self, name: String) -> BoxFuture<Result<()>>;
- fn create_branch(&self, name: String) -> BoxFuture<Result<()>>;
+ 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<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>>;
+ ) -> BoxFuture<'_, Result<()>>;
fn checkout_files(
&self,
commit: String,
paths: Vec<RepoPath>,
env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>>;
+ ) -> BoxFuture<'_, Result<()>>;
- fn show(&self, commit: String) -> BoxFuture<Result<CommitDetails>>;
+ fn show(&self, commit: String) -> BoxFuture<'_, Result<CommitDetails>>;
- fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<Result<CommitDiff>>;
- fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<Result<crate::blame::Blame>>;
+ fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result<CommitDiff>>;
+ fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result<crate::blame::Blame>>;
/// 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/<name>`).
@@ -376,7 +376,7 @@ pub trait GitRepository: Send + Sync {
&self,
paths: Vec<RepoPath>,
env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>>;
+ ) -> 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<RepoPath>,
env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>>;
+ ) -> BoxFuture<'_, Result<()>>;
fn commit(
&self,
@@ -392,7 +392,7 @@ pub trait GitRepository: Send + Sync {
name_and_email: Option<(SharedString, SharedString)>,
options: CommitOptions,
env: Arc<HashMap<String, String>>,
- ) -> BoxFuture<Result<()>>;
+ ) -> 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<Result<RemoteCommandOutput>>;
+ ) -> BoxFuture<'_, Result<RemoteCommandOutput>>;
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<Result<RemoteCommandOutput>>;
+ ) -> BoxFuture<'_, Result<RemoteCommandOutput>>;
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<Result<RemoteCommandOutput>>;
+ ) -> BoxFuture<'_, Result<RemoteCommandOutput>>;
- fn get_remotes(&self, branch_name: Option<String>) -> BoxFuture<Result<Vec<Remote>>>;
+ fn get_remotes(&self, branch_name: Option<String>) -> BoxFuture<'_, Result<Vec<Remote>>>;
/// returns a list of remote branches that contain HEAD
- fn check_for_pushed_commit(&self) -> BoxFuture<Result<Vec<SharedString>>>;
+ fn check_for_pushed_commit(&self) -> BoxFuture<'_, Result<Vec<SharedString>>>;
/// Run git diff
- fn diff(&self, diff: DiffType) -> BoxFuture<Result<String>>;
+ fn diff(&self, diff: DiffType) -> BoxFuture<'_, Result<String>>;
/// Creates a checkpoint for the repository.
fn checkpoint(&self) -> BoxFuture<'static, Result<GitRepositoryCheckpoint>>;
/// Resets to a previously-created checkpoint.
- fn restore_checkpoint(&self, checkpoint: GitRepositoryCheckpoint) -> BoxFuture<Result<()>>;
+ 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<Result<bool>>;
+ ) -> BoxFuture<'_, Result<bool>>;
/// Computes a diff between two checkpoints.
fn diff_checkpoints(
&self,
base_checkpoint: GitRepositoryCheckpoint,
target_checkpoint: GitRepositoryCheckpoint,
- ) -> BoxFuture<Result<String>>;
+ ) -> BoxFuture<'_, Result<String>>;
}
pub enum DiffType {
@@ -2268,7 +2268,7 @@ mod tests {
impl RealGitRepository {
/// Force a Git garbage collection on the repository.
- fn gc(&self) -> BoxFuture<Result<()>> {
+ 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();
@@ -214,32 +214,6 @@ impl<T: ?Sized> DerefMut for ArenaBox<T> {
}
}
-pub struct ArenaRef<T: ?Sized>(ArenaBox<T>);
-
-impl<T: ?Sized> From<ArenaBox<T>> for ArenaRef<T> {
- fn from(value: ArenaBox<T>) -> Self {
- ArenaRef(value)
- }
-}
-
-impl<T: ?Sized> Clone for ArenaRef<T> {
- fn clone(&self) -> Self {
- Self(ArenaBox {
- ptr: self.0.ptr,
- valid: self.0.valid.clone(),
- })
- }
-}
-
-impl<T: ?Sized> Deref for ArenaRef<T> {
- type Target = T;
-
- #[inline(always)]
- fn deref(&self) -> &Self::Target {
- self.0.deref()
- }
-}
-
#[cfg(test)]
mod tests {
use std::{cell::Cell, rc::Rc};
@@ -29,14 +29,14 @@ pub unsafe fn new_renderer(
}
impl rwh::HasWindowHandle for RawWindow {
- fn window_handle(&self) -> Result<rwh::WindowHandle, rwh::HandleError> {
+ fn window_handle(&self) -> Result<rwh::WindowHandle<'_>, 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<rwh::DisplayHandle, rwh::HandleError> {
+ fn display_handle(&self) -> Result<rwh::DisplayHandle<'_>, rwh::HandleError> {
let handle = rwh::AppKitDisplayHandle::new();
Ok(unsafe { rwh::DisplayHandle::borrow_raw(handle.into()) })
}
@@ -252,11 +252,11 @@ impl Drop for WaylandWindow {
}
impl WaylandWindow {
- fn borrow(&self) -> Ref<WaylandWindowState> {
+ fn borrow(&self) -> Ref<'_, WaylandWindowState> {
self.0.state.borrow()
}
- fn borrow_mut(&self) -> RefMut<WaylandWindowState> {
+ fn borrow_mut(&self) -> RefMut<'_, WaylandWindowState> {
self.0.state.borrow_mut()
}
@@ -288,7 +288,7 @@ pub(crate) struct X11WindowStatePtr {
}
impl rwh::HasWindowHandle for RawWindow {
- fn window_handle(&self) -> Result<rwh::WindowHandle, rwh::HandleError> {
+ fn window_handle(&self) -> Result<rwh::WindowHandle<'_>, 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<rwh::DisplayHandle, rwh::HandleError> {
+ fn display_handle(&self) -> Result<rwh::DisplayHandle<'_>, 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<rwh::WindowHandle, rwh::HandleError> {
+ fn window_handle(&self) -> Result<rwh::WindowHandle<'_>, rwh::HandleError> {
unimplemented!()
}
}
impl rwh::HasDisplayHandle for X11Window {
- fn display_handle(&self) -> Result<rwh::DisplayHandle, rwh::HandleError> {
+ fn display_handle(&self) -> Result<rwh::DisplayHandle<'_>, 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<XCBConnection>,
-}
-
-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 {
@@ -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
@@ -1250,11 +1250,13 @@ fn set_window_composition_attribute(hwnd: HWND, color: Option<Color>, 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<Color>, state: u32
cb_data: std::mem::size_of::<AccentPolicy>(),
};
let _ = set_window_composition_attribute(hwnd, &mut data as *mut _ as _);
- } else {
- let _ = user32
- .inspect_err(|e| log::error!("Error getting module: {e}"))
- .ok();
}
}
}
@@ -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)]
@@ -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 {
@@ -126,17 +126,17 @@ impl<T> Default for TypedRow<T> {
impl<T> PartialOrd for TypedOffset<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- Some(self.value.cmp(&other.value))
+ Some(self.cmp(&other))
}
}
impl<T> PartialOrd for TypedPoint<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- Some(self.value.cmp(&other.value))
+ Some(self.cmp(&other))
}
}
impl<T> PartialOrd for TypedRow<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- Some(self.value.cmp(&other.value))
+ Some(self.cmp(&other))
}
}
@@ -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
@@ -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();
@@ -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(),
@@ -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;
}
@@ -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])
});
@@ -52,7 +52,7 @@ pub(super) fn find_from_grid_point<T: EventListener>(
) -> 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<T: EventListener>(
}
}
- 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))
@@ -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
@@ -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<Option<Cow<'static, [u8]>>> {
- 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<Vec<SharedString>> {
- Ok(Self::iter()
- .filter(|p| p.starts_with(path))
- .map(SharedString::from)
- .collect())
- }
-}
@@ -1,4 +1,3 @@
-mod assets;
mod color;
mod vscode;
@@ -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 =
{
@@ -1,5 +1,5 @@
[toolchain]
-channel = "1.87"
+channel = "1.88"
profile = "minimal"
components = [ "rustfmt", "clippy" ]
targets = [