chore: Bump Rust version to 1.88 (#33439)

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>
This commit is contained in:
Piotr Osiewicz 2025-06-26 20:54:19 +02:00 committed by GitHub
parent b079871428
commit 985dcf7523
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 112 additions and 303 deletions

1
Cargo.lock generated
View file

@ -16037,7 +16037,6 @@ dependencies = [
"indexmap", "indexmap",
"log", "log",
"palette", "palette",
"rust-embed",
"serde", "serde",
"serde_json", "serde_json",
"serde_json_lenient", "serde_json_lenient",

View file

@ -1,6 +1,6 @@
# syntax = docker/dockerfile:1.2 # syntax = docker/dockerfile:1.2
FROM rust:1.87-bookworm as builder FROM rust:1.88-bookworm as builder
WORKDIR app WORKDIR app
COPY . . COPY . .

View file

@ -1094,15 +1094,9 @@ mod tests {
}; };
use language_model::{LanguageModelRegistry, TokenUsage}; use language_model::{LanguageModelRegistry, TokenUsage};
use rand::prelude::*; use rand::prelude::*;
use serde::Serialize;
use settings::SettingsStore; use settings::SettingsStore;
use std::{future, sync::Arc}; use std::{future, sync::Arc};
#[derive(Serialize)]
pub struct DummyCompletionRequest {
pub name: String,
}
#[gpui::test(iterations = 10)] #[gpui::test(iterations = 10)]
async fn test_transform_autoindent(cx: &mut TestAppContext, mut rng: StdRng) { async fn test_transform_autoindent(cx: &mut TestAppContext, mut rng: StdRng) {
init_test(cx); init_test(cx);

View file

@ -69,7 +69,7 @@ use workspace::{
searchable::{Direction, SearchableItemHandle}, searchable::{Direction, SearchableItemHandle},
}; };
use workspace::{ use workspace::{
Save, Toast, ToolbarItemEvent, ToolbarItemLocation, ToolbarItemView, Workspace, Save, Toast, Workspace,
item::{self, FollowableItem, Item, ItemHandle}, item::{self, FollowableItem, Item, ItemHandle},
notifications::NotificationId, notifications::NotificationId,
pane, 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( pub fn render_remaining_tokens(
context_editor: &Entity<TextThreadEditor>, context_editor: &Entity<TextThreadEditor>,
cx: &App, 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 {} enum PendingSlashCommand {}
fn invoked_slash_command_fold_placeholder( fn invoked_slash_command_fold_placeholder(

View file

@ -74,7 +74,7 @@ impl SlashCommand for DeltaSlashCommand {
.slice(section.range.to_offset(&context_buffer)), .slice(section.range.to_offset(&context_buffer)),
); );
file_command_new_outputs.push(Arc::new(FileSlashCommand).run( file_command_new_outputs.push(Arc::new(FileSlashCommand).run(
&[metadata.path.clone()], std::slice::from_ref(&metadata.path),
context_slash_command_output_sections, context_slash_command_output_sections,
context_buffer.clone(), context_buffer.clone(),
workspace.clone(), workspace.clone(),

View file

@ -1867,7 +1867,7 @@ mod tests {
let hunk = diff.hunks(&buffer, cx).next().unwrap(); let hunk = diff.hunks(&buffer, cx).next().unwrap();
let new_index_text = diff 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() .unwrap()
.to_string(); .to_string();
assert_eq!(new_index_text, buffer_text); assert_eq!(new_index_text, buffer_text);

View file

@ -76,7 +76,10 @@ async fn test_purge_old_embeddings(cx: &mut gpui::TestAppContext) {
db.purge_old_embeddings().await.unwrap(); db.purge_old_embeddings().await.unwrap();
// Try to retrieve the purged embeddings // 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!( assert!(
retrieved_embeddings.is_empty(), retrieved_embeddings.is_empty(),
"Old embeddings should have been purged" "Old embeddings should have been purged"

View file

@ -179,7 +179,7 @@ struct Session {
} }
impl Session { impl Session {
async fn db(&self) -> tokio::sync::MutexGuard<DbHandle> { async fn db(&self) -> tokio::sync::MutexGuard<'_, DbHandle> {
#[cfg(test)] #[cfg(test)]
tokio::task::yield_now().await; tokio::task::yield_now().await;
let guard = self.db.lock().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 { ServerSnapshot {
connection_pool: ConnectionPoolGuard { connection_pool: ConnectionPoolGuard {
guard: self.connection_pool.lock(), guard: self.connection_pool.lock(),

View file

@ -3897,8 +3897,10 @@ impl Editor {
bracket_pair_matching_end = Some(pair.clone()); bracket_pair_matching_end = Some(pair.clone());
} }
} }
if bracket_pair.is_none() && bracket_pair_matching_end.is_some() { if let Some(end) = bracket_pair_matching_end
bracket_pair = Some(bracket_pair_matching_end.unwrap()); && bracket_pair.is_none()
{
bracket_pair = Some(end);
is_bracket_pair_end = true; is_bracket_pair_end = true;
} }
} }
@ -13381,7 +13383,12 @@ impl Editor {
window: &mut Window, window: &mut Window,
cx: &mut Context<Editor>, 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| { self.change_selections(auto_scroll, window, cx, |s| {
if replace_newest { if replace_newest {
s.delete(s.newest_anchor().id); s.delete(s.newest_anchor().id);

View file

@ -74,7 +74,7 @@ impl FakeGitRepository {
impl GitRepository for FakeGitRepository { impl GitRepository for FakeGitRepository {
fn reload_index(&self) {} 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 { async {
self.with_state_async(false, move |state| { self.with_state_async(false, move |state| {
state state
@ -89,7 +89,7 @@ impl GitRepository for FakeGitRepository {
.boxed() .boxed()
} }
fn load_committed_text(&self, path: RepoPath) -> BoxFuture<Option<String>> { fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option<String>> {
async { async {
self.with_state_async(false, move |state| { self.with_state_async(false, move |state| {
state state
@ -108,7 +108,7 @@ impl GitRepository for FakeGitRepository {
&self, &self,
_commit: String, _commit: String,
_cx: AsyncApp, _cx: AsyncApp,
) -> BoxFuture<Result<git::repository::CommitDiff>> { ) -> BoxFuture<'_, Result<git::repository::CommitDiff>> {
unimplemented!() unimplemented!()
} }
@ -117,7 +117,7 @@ impl GitRepository for FakeGitRepository {
path: RepoPath, path: RepoPath,
content: Option<String>, content: Option<String>,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
) -> BoxFuture<anyhow::Result<()>> { ) -> BoxFuture<'_, anyhow::Result<()>> {
self.with_state_async(true, move |state| { self.with_state_async(true, move |state| {
if let Some(message) = &state.simulated_index_write_error_message { if let Some(message) = &state.simulated_index_write_error_message {
anyhow::bail!("{message}"); anyhow::bail!("{message}");
@ -134,7 +134,7 @@ impl GitRepository for FakeGitRepository {
None 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| { self.with_state_async(false, |state| {
Ok(revs Ok(revs
.into_iter() .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 { async {
Ok(CommitDetails { Ok(CommitDetails {
sha: commit.into(), sha: commit.into(),
@ -158,7 +158,7 @@ impl GitRepository for FakeGitRepository {
_commit: String, _commit: String,
_mode: ResetMode, _mode: ResetMode,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> { ) -> BoxFuture<'_, Result<()>> {
unimplemented!() unimplemented!()
} }
@ -167,7 +167,7 @@ impl GitRepository for FakeGitRepository {
_commit: String, _commit: String,
_paths: Vec<RepoPath>, _paths: Vec<RepoPath>,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> { ) -> BoxFuture<'_, Result<()>> {
unimplemented!() unimplemented!()
} }
@ -179,11 +179,11 @@ impl GitRepository for FakeGitRepository {
self.common_dir_path.clone() self.common_dir_path.clone()
} }
fn merge_message(&self) -> BoxFuture<Option<String>> { fn merge_message(&self) -> BoxFuture<'_, Option<String>> {
async move { None }.boxed() 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(); let workdir_path = self.dot_git_path.parent().unwrap();
// Load gitignores // Load gitignores
@ -314,7 +314,7 @@ impl GitRepository for FakeGitRepository {
async move { result? }.boxed() 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| { self.with_state_async(false, move |state| {
let current_branch = &state.current_branch_name; let current_branch = &state.current_branch_name;
Ok(state 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| { self.with_state_async(true, |state| {
state.current_branch_name = Some(name); state.current_branch_name = Some(name);
Ok(()) Ok(())
}) })
} }
fn create_branch(&self, name: String) -> BoxFuture<Result<()>> { fn create_branch(&self, name: String) -> BoxFuture<'_, Result<()>> {
self.with_state_async(true, move |state| { self.with_state_async(true, move |state| {
state.branches.insert(name.to_owned()); state.branches.insert(name.to_owned());
Ok(()) 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| { self.with_state_async(false, move |state| {
state state
.blames .blames
@ -358,7 +358,7 @@ impl GitRepository for FakeGitRepository {
&self, &self,
_paths: Vec<RepoPath>, _paths: Vec<RepoPath>,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> { ) -> BoxFuture<'_, Result<()>> {
unimplemented!() unimplemented!()
} }
@ -366,7 +366,7 @@ impl GitRepository for FakeGitRepository {
&self, &self,
_paths: Vec<RepoPath>, _paths: Vec<RepoPath>,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> { ) -> BoxFuture<'_, Result<()>> {
unimplemented!() unimplemented!()
} }
@ -376,7 +376,7 @@ impl GitRepository for FakeGitRepository {
_name_and_email: Option<(gpui::SharedString, gpui::SharedString)>, _name_and_email: Option<(gpui::SharedString, gpui::SharedString)>,
_options: CommitOptions, _options: CommitOptions,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>> { ) -> BoxFuture<'_, Result<()>> {
unimplemented!() unimplemented!()
} }
@ -388,7 +388,7 @@ impl GitRepository for FakeGitRepository {
_askpass: AskPassDelegate, _askpass: AskPassDelegate,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
_cx: AsyncApp, _cx: AsyncApp,
) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> { ) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
unimplemented!() unimplemented!()
} }
@ -399,7 +399,7 @@ impl GitRepository for FakeGitRepository {
_askpass: AskPassDelegate, _askpass: AskPassDelegate,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
_cx: AsyncApp, _cx: AsyncApp,
) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> { ) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
unimplemented!() unimplemented!()
} }
@ -409,19 +409,19 @@ impl GitRepository for FakeGitRepository {
_askpass: AskPassDelegate, _askpass: AskPassDelegate,
_env: Arc<HashMap<String, String>>, _env: Arc<HashMap<String, String>>,
_cx: AsyncApp, _cx: AsyncApp,
) -> BoxFuture<Result<git::repository::RemoteCommandOutput>> { ) -> BoxFuture<'_, Result<git::repository::RemoteCommandOutput>> {
unimplemented!() unimplemented!()
} }
fn get_remotes(&self, _branch: Option<String>) -> BoxFuture<Result<Vec<Remote>>> { fn get_remotes(&self, _branch: Option<String>) -> BoxFuture<'_, Result<Vec<Remote>>> {
unimplemented!() 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() 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!() unimplemented!()
} }
@ -429,7 +429,10 @@ impl GitRepository for FakeGitRepository {
unimplemented!() unimplemented!()
} }
fn restore_checkpoint(&self, _checkpoint: GitRepositoryCheckpoint) -> BoxFuture<Result<()>> { fn restore_checkpoint(
&self,
_checkpoint: GitRepositoryCheckpoint,
) -> BoxFuture<'_, Result<()>> {
unimplemented!() unimplemented!()
} }
@ -437,7 +440,7 @@ impl GitRepository for FakeGitRepository {
&self, &self,
_left: GitRepositoryCheckpoint, _left: GitRepositoryCheckpoint,
_right: GitRepositoryCheckpoint, _right: GitRepositoryCheckpoint,
) -> BoxFuture<Result<bool>> { ) -> BoxFuture<'_, Result<bool>> {
unimplemented!() unimplemented!()
} }
@ -445,7 +448,7 @@ impl GitRepository for FakeGitRepository {
&self, &self,
_base_checkpoint: GitRepositoryCheckpoint, _base_checkpoint: GitRepositoryCheckpoint,
_target_checkpoint: GitRepositoryCheckpoint, _target_checkpoint: GitRepositoryCheckpoint,
) -> BoxFuture<Result<String>> { ) -> BoxFuture<'_, Result<String>> {
unimplemented!() unimplemented!()
} }
} }

View file

@ -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. /// 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. /// 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. /// 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. /// 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( fn set_index_text(
&self, &self,
path: RepoPath, path: RepoPath,
content: Option<String>, content: Option<String>,
env: Arc<HashMap<String, String>>, env: Arc<HashMap<String, String>>,
) -> BoxFuture<anyhow::Result<()>>; ) -> BoxFuture<'_, anyhow::Result<()>>;
/// Returns the URL of the remote with the given name. /// Returns the URL of the remote with the given name.
fn remote_url(&self, name: &str) -> Option<String>; fn remote_url(&self, name: &str) -> Option<String>;
/// Resolve a list of refs to SHAs. /// 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>> { fn head_sha(&self) -> BoxFuture<'_, Option<String>> {
async move { async move {
@ -335,33 +335,33 @@ pub trait GitRepository: Send + Sync {
.boxed() .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 change_branch(&self, name: String) -> BoxFuture<'_, Result<()>>;
fn create_branch(&self, name: String) -> BoxFuture<Result<()>>; fn create_branch(&self, name: String) -> BoxFuture<'_, Result<()>>;
fn reset( fn reset(
&self, &self,
commit: String, commit: String,
mode: ResetMode, mode: ResetMode,
env: Arc<HashMap<String, String>>, env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>>; ) -> BoxFuture<'_, Result<()>>;
fn checkout_files( fn checkout_files(
&self, &self,
commit: String, commit: String,
paths: Vec<RepoPath>, paths: Vec<RepoPath>,
env: Arc<HashMap<String, String>>, 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 load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result<CommitDiff>>;
fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<Result<crate::blame::Blame>>; 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 /// 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>`). /// worktree's gitdir within the main repository (typically `.git/worktrees/<name>`).
@ -376,7 +376,7 @@ pub trait GitRepository: Send + Sync {
&self, &self,
paths: Vec<RepoPath>, paths: Vec<RepoPath>,
env: Arc<HashMap<String, String>>, env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>>; ) -> BoxFuture<'_, Result<()>>;
/// Updates the index to match HEAD at the given paths. /// 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. /// 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, &self,
paths: Vec<RepoPath>, paths: Vec<RepoPath>,
env: Arc<HashMap<String, String>>, env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>>; ) -> BoxFuture<'_, Result<()>>;
fn commit( fn commit(
&self, &self,
@ -392,7 +392,7 @@ pub trait GitRepository: Send + Sync {
name_and_email: Option<(SharedString, SharedString)>, name_and_email: Option<(SharedString, SharedString)>,
options: CommitOptions, options: CommitOptions,
env: Arc<HashMap<String, String>>, env: Arc<HashMap<String, String>>,
) -> BoxFuture<Result<()>>; ) -> BoxFuture<'_, Result<()>>;
fn push( fn push(
&self, &self,
@ -404,7 +404,7 @@ pub trait GitRepository: Send + Sync {
// This method takes an AsyncApp to ensure it's invoked on the main thread, // This method takes an AsyncApp to ensure it's invoked on the main thread,
// otherwise git-credentials-manager won't work. // otherwise git-credentials-manager won't work.
cx: AsyncApp, cx: AsyncApp,
) -> BoxFuture<Result<RemoteCommandOutput>>; ) -> BoxFuture<'_, Result<RemoteCommandOutput>>;
fn pull( fn pull(
&self, &self,
@ -415,7 +415,7 @@ pub trait GitRepository: Send + Sync {
// This method takes an AsyncApp to ensure it's invoked on the main thread, // This method takes an AsyncApp to ensure it's invoked on the main thread,
// otherwise git-credentials-manager won't work. // otherwise git-credentials-manager won't work.
cx: AsyncApp, cx: AsyncApp,
) -> BoxFuture<Result<RemoteCommandOutput>>; ) -> BoxFuture<'_, Result<RemoteCommandOutput>>;
fn fetch( fn fetch(
&self, &self,
@ -425,35 +425,35 @@ pub trait GitRepository: Send + Sync {
// This method takes an AsyncApp to ensure it's invoked on the main thread, // This method takes an AsyncApp to ensure it's invoked on the main thread,
// otherwise git-credentials-manager won't work. // otherwise git-credentials-manager won't work.
cx: AsyncApp, 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 /// 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 /// 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. /// Creates a checkpoint for the repository.
fn checkpoint(&self) -> BoxFuture<'static, Result<GitRepositoryCheckpoint>>; fn checkpoint(&self) -> BoxFuture<'static, Result<GitRepositoryCheckpoint>>;
/// Resets to a previously-created checkpoint. /// 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 /// Compares two checkpoints, returning true if they are equal
fn compare_checkpoints( fn compare_checkpoints(
&self, &self,
left: GitRepositoryCheckpoint, left: GitRepositoryCheckpoint,
right: GitRepositoryCheckpoint, right: GitRepositoryCheckpoint,
) -> BoxFuture<Result<bool>>; ) -> BoxFuture<'_, Result<bool>>;
/// Computes a diff between two checkpoints. /// Computes a diff between two checkpoints.
fn diff_checkpoints( fn diff_checkpoints(
&self, &self,
base_checkpoint: GitRepositoryCheckpoint, base_checkpoint: GitRepositoryCheckpoint,
target_checkpoint: GitRepositoryCheckpoint, target_checkpoint: GitRepositoryCheckpoint,
) -> BoxFuture<Result<String>>; ) -> BoxFuture<'_, Result<String>>;
} }
pub enum DiffType { pub enum DiffType {
@ -2268,7 +2268,7 @@ mod tests {
impl RealGitRepository { impl RealGitRepository {
/// Force a Git garbage collection on the repository. /// 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 working_directory = self.working_directory();
let git_binary_path = self.git_binary_path.clone(); let git_binary_path = self.git_binary_path.clone();
let executor = self.executor.clone(); let executor = self.executor.clone();

View file

@ -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)] #[cfg(test)]
mod tests { mod tests {
use std::{cell::Cell, rc::Rc}; use std::{cell::Cell, rc::Rc};

View file

@ -29,14 +29,14 @@ pub unsafe fn new_renderer(
} }
impl rwh::HasWindowHandle for RawWindow { 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 view = NonNull::new(self.view).unwrap();
let handle = rwh::AppKitWindowHandle::new(view); let handle = rwh::AppKitWindowHandle::new(view);
Ok(unsafe { rwh::WindowHandle::borrow_raw(handle.into()) }) Ok(unsafe { rwh::WindowHandle::borrow_raw(handle.into()) })
} }
} }
impl rwh::HasDisplayHandle 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 handle = rwh::AppKitDisplayHandle::new(); let handle = rwh::AppKitDisplayHandle::new();
Ok(unsafe { rwh::DisplayHandle::borrow_raw(handle.into()) }) Ok(unsafe { rwh::DisplayHandle::borrow_raw(handle.into()) })
} }

View file

@ -252,11 +252,11 @@ impl Drop for WaylandWindow {
} }
impl WaylandWindow { impl WaylandWindow {
fn borrow(&self) -> Ref<WaylandWindowState> { fn borrow(&self) -> Ref<'_, WaylandWindowState> {
self.0.state.borrow() self.0.state.borrow()
} }
fn borrow_mut(&self) -> RefMut<WaylandWindowState> { fn borrow_mut(&self) -> RefMut<'_, WaylandWindowState> {
self.0.state.borrow_mut() self.0.state.borrow_mut()
} }

View file

@ -288,7 +288,7 @@ pub(crate) struct X11WindowStatePtr {
} }
impl rwh::HasWindowHandle for RawWindow { 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 { let Some(non_zero) = NonZeroU32::new(self.window_id) else {
log::error!("RawWindow.window_id zero when getting window handle."); log::error!("RawWindow.window_id zero when getting window handle.");
return Err(rwh::HandleError::Unavailable); return Err(rwh::HandleError::Unavailable);
@ -299,7 +299,7 @@ impl rwh::HasWindowHandle for RawWindow {
} }
} }
impl rwh::HasDisplayHandle 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 { let Some(non_zero) = NonNull::new(self.connection) else {
log::error!("Null RawWindow.connection when getting display handle."); log::error!("Null RawWindow.connection when getting display handle.");
return Err(rwh::HandleError::Unavailable); return Err(rwh::HandleError::Unavailable);
@ -310,12 +310,12 @@ impl rwh::HasDisplayHandle for RawWindow {
} }
impl rwh::HasWindowHandle for X11Window { impl rwh::HasWindowHandle for X11Window {
fn window_handle(&self) -> Result<rwh::WindowHandle, rwh::HandleError> { fn window_handle(&self) -> Result<rwh::WindowHandle<'_>, rwh::HandleError> {
unimplemented!() unimplemented!()
} }
} }
impl rwh::HasDisplayHandle for X11Window { impl rwh::HasDisplayHandle for X11Window {
fn display_handle(&self) -> Result<rwh::DisplayHandle, rwh::HandleError> { fn display_handle(&self) -> Result<rwh::DisplayHandle<'_>, rwh::HandleError> {
unimplemented!() 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); pub(crate) struct X11Window(pub X11WindowStatePtr);
impl Drop for X11Window { impl Drop for X11Window {

View file

@ -1074,8 +1074,10 @@ fn handle_nc_mouse_up_msg(
} }
let last_pressed = state_ptr.state.borrow_mut().nc_button_pressed.take(); let last_pressed = state_ptr.state.borrow_mut().nc_button_pressed.take();
if button == MouseButton::Left && last_pressed.is_some() { if button == MouseButton::Left
let handled = match (wparam.0 as u32, last_pressed.unwrap()) { && let Some(last_pressed) = last_pressed
{
let handled = match (wparam.0 as u32, last_pressed) {
(HTMINBUTTON, HTMINBUTTON) => { (HTMINBUTTON, HTMINBUTTON) => {
unsafe { ShowWindowAsync(handle, SW_MINIMIZE).ok().log_err() }; unsafe { ShowWindowAsync(handle, SW_MINIMIZE).ok().log_err() };
true true

View file

@ -1250,11 +1250,13 @@ fn set_window_composition_attribute(hwnd: HWND, color: Option<Color>, state: u32
type SetWindowCompositionAttributeType = type SetWindowCompositionAttributeType =
unsafe extern "system" fn(HWND, *mut WINDOWCOMPOSITIONATTRIBDATA) -> BOOL; unsafe extern "system" fn(HWND, *mut WINDOWCOMPOSITIONATTRIBDATA) -> BOOL;
let module_name = PCSTR::from_raw(c"user32.dll".as_ptr() as *const u8); let module_name = PCSTR::from_raw(c"user32.dll".as_ptr() as *const u8);
let user32 = GetModuleHandleA(module_name); if let Some(user32) = GetModuleHandleA(module_name)
if user32.is_ok() { .context("Unable to get user32.dll handle")
.log_err()
{
let func_name = PCSTR::from_raw(c"SetWindowCompositionAttribute".as_ptr() as *const u8); let func_name = PCSTR::from_raw(c"SetWindowCompositionAttribute".as_ptr() as *const u8);
let set_window_composition_attribute: SetWindowCompositionAttributeType = 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 mut color = color.unwrap_or_default();
let is_acrylic = state == 4; let is_acrylic = state == 4;
if is_acrylic && color.3 == 0 { 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>(), cb_data: std::mem::size_of::<AccentPolicy>(),
}; };
let _ = set_window_composition_attribute(hwnd, &mut data as *mut _ as _); let _ = set_window_composition_attribute(hwnd, &mut data as *mut _ as _);
} else {
let _ = user32
.inspect_err(|e| log::error!("Error getting module: {e}"))
.ok();
} }
} }
} }

View file

@ -582,7 +582,7 @@ pub struct FontRun {
} }
trait AsCacheKeyRef { trait AsCacheKeyRef {
fn as_cache_key_ref(&self) -> CacheKeyRef; fn as_cache_key_ref(&self) -> CacheKeyRef<'_>;
} }
#[derive(Clone, Debug, Eq)] #[derive(Clone, Debug, Eq)]

View file

@ -83,34 +83,6 @@ where
timer.race(future).await 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. /// Increment the given atomic counter if it is not zero.
/// Return the new value of the counter. /// Return the new value of the counter.
pub(crate) fn atomic_incr_if_not_zero(counter: &AtomicUsize) -> usize { pub(crate) fn atomic_incr_if_not_zero(counter: &AtomicUsize) -> usize {

View file

@ -126,17 +126,17 @@ impl<T> Default for TypedRow<T> {
impl<T> PartialOrd for TypedOffset<T> { impl<T> PartialOrd for TypedOffset<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { 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> { impl<T> PartialOrd for TypedPoint<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { 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> { impl<T> PartialOrd for TypedRow<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.value.cmp(&other.value)) Some(self.cmp(&other))
} }
} }

View file

@ -4556,7 +4556,9 @@ async fn compute_snapshot(
let mut events = Vec::new(); let mut events = Vec::new();
let branches = backend.branches().await?; let branches = backend.branches().await?;
let branch = branches.into_iter().find(|branch| branch.is_head); 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( let statuses_by_path = SumTree::from_iter(
statuses statuses
.entries .entries

View file

@ -565,7 +565,7 @@ mod tests {
conflict_set.snapshot().conflicts[0].clone() conflict_set.snapshot().conflicts[0].clone()
}); });
cx.update(|cx| { 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(); cx.run_until_parked();

View file

@ -5743,7 +5743,10 @@ impl LspStore {
match language { match language {
Some(language) => { Some(language) => {
adapter adapter
.labels_for_completions(&[completion_item.clone()], language) .labels_for_completions(
std::slice::from_ref(&completion_item),
language,
)
.await? .await?
} }
None => Vec::new(), None => Vec::new(),

View file

@ -7502,13 +7502,13 @@ async fn test_staging_random_hunks(
if hunk.status().has_secondary_hunk() { if hunk.status().has_secondary_hunk() {
log::info!("staging hunk at {row}"); log::info!("staging hunk at {row}");
uncommitted_diff.update(cx, |diff, cx| { 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; hunk.secondary_status = SecondaryHunkRemovalPending;
} else { } else {
log::info!("unstaging hunk at {row}"); log::info!("unstaging hunk at {row}");
uncommitted_diff.update(cx, |diff, cx| { 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; hunk.secondary_status = SecondaryHunkAdditionPending;
} }

View file

@ -1302,7 +1302,7 @@ impl ProjectSearchView {
let range_to_select = match_ranges[new_index].clone(); let range_to_select = match_ranges[new_index].clone();
self.results_editor.update(cx, |editor, cx| { self.results_editor.update(cx, |editor, cx| {
let range_to_select = editor.range_for_match(&range_to_select); 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| { editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| {
s.select_ranges([range_to_select]) s.select_ranges([range_to_select])
}); });

View file

@ -52,7 +52,7 @@ pub(super) fn find_from_grid_point<T: EventListener>(
) -> Option<(String, bool, Match)> { ) -> Option<(String, bool, Match)> {
let grid = term.grid(); let grid = term.grid();
let link = grid.index(point).hyperlink(); 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; let mut min_index = point;
loop { loop {
let new_min_index = min_index.sub(term, Boundary::Cursor, 1); 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; let url_match = min_index..=max_index;
Some((url, true, url_match)) Some((url, true, url_match))

View file

@ -15,7 +15,6 @@ gpui.workspace = true
indexmap.workspace = true indexmap.workspace = true
log.workspace = true log.workspace = true
palette.workspace = true palette.workspace = true
rust-embed.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true
serde_json_lenient.workspace = true serde_json_lenient.workspace = true

View file

@ -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())
}
}

View file

@ -1,4 +1,3 @@
mod assets;
mod color; mod color;
mod vscode; mod vscode;

View file

@ -3911,7 +3911,7 @@ impl BackgroundScanner {
let Ok(request) = path_prefix_request else { break }; let Ok(request) = path_prefix_request else { break };
log::trace!("adding path prefix {:?}", request.path); 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 { if did_scan {
let abs_path = let abs_path =
{ {

View file

@ -1,5 +1,5 @@
[toolchain] [toolchain]
channel = "1.87" channel = "1.88"
profile = "minimal" profile = "minimal"
components = [ "rustfmt", "clippy" ] components = [ "rustfmt", "clippy" ]
targets = [ targets = [