From 72bcb0beb7bbfaa8d1e5fcdac6f94ba5ccc3a281 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Mon, 9 Jun 2025 13:11:57 +0200 Subject: [PATCH] chore: Fix warnings for Rust 1.89 (#32378) Closes #ISSUE Release Notes: - N/A --- crates/agent/src/thread_store.rs | 4 +- crates/channel/src/channel_store.rs | 2 +- .../src/channel_store/channel_index.rs | 2 +- crates/client/src/proxy.rs | 2 +- crates/editor/src/display_map/block_map.rs | 6 +-- crates/editor/src/display_map/fold_map.rs | 4 +- crates/editor/src/display_map/wrap_map.rs | 2 +- crates/editor/src/selections_collection.rs | 2 +- crates/extension_host/src/wasm_host.rs | 2 +- crates/git/src/repository.rs | 54 +++++++++---------- crates/gpui/src/app.rs | 6 +-- crates/gpui/src/platform.rs | 2 +- crates/gpui/src/platform/mac/events.rs | 2 +- crates/gpui/src/scene.rs | 2 +- crates/gpui/src/text_system/line_layout.rs | 4 +- crates/language/src/buffer.rs | 14 ++--- crates/language/src/syntax_map.rs | 4 +- .../src/livekit_client/playback.rs | 2 +- crates/markdown/src/markdown.rs | 2 +- .../markdown_preview/src/markdown_parser.rs | 8 +-- crates/multi_buffer/src/multi_buffer.rs | 29 ++++++---- crates/project/src/git_store/git_traversal.rs | 2 +- crates/project/src/project.rs | 2 +- crates/project_panel/src/project_panel.rs | 2 +- crates/recent_projects/src/remote_servers.rs | 2 +- crates/rope/src/chunk.rs | 4 +- crates/rope/src/rope.rs | 12 ++--- crates/sum_tree/src/sum_tree.rs | 2 +- crates/terminal/src/terminal_settings.rs | 2 +- crates/text/src/text.rs | 2 +- crates/watch/src/watch.rs | 2 +- crates/worktree/src/worktree.rs | 10 ++-- 32 files changed, 102 insertions(+), 95 deletions(-) diff --git a/crates/agent/src/thread_store.rs b/crates/agent/src/thread_store.rs index 9ad2d37446..a86fcda072 100644 --- a/crates/agent/src/thread_store.rs +++ b/crates/agent/src/thread_store.rs @@ -89,7 +89,7 @@ pub fn init(cx: &mut App) { pub struct SharedProjectContext(Rc>>); impl SharedProjectContext { - pub fn borrow(&self) -> Ref> { + pub fn borrow(&self) -> Ref<'_, Option> { self.0.borrow() } } @@ -919,7 +919,7 @@ impl ThreadsDatabase { fn bytes_encode( item: &Self::EItem, - ) -> Result, heed::BoxedError> { + ) -> Result, heed::BoxedError> { serde_json::to_vec(&item.0) .map(std::borrow::Cow::Owned) .map_err(Into::into) diff --git a/crates/channel/src/channel_store.rs b/crates/channel/src/channel_store.rs index b7162998cc..a73734cd49 100644 --- a/crates/channel/src/channel_store.rs +++ b/crates/channel/src/channel_store.rs @@ -111,7 +111,7 @@ pub struct ChannelMembership { pub role: proto::ChannelRole, } impl ChannelMembership { - pub fn sort_key(&self) -> MembershipSortKey { + pub fn sort_key(&self) -> MembershipSortKey<'_> { MembershipSortKey { role_order: match self.role { proto::ChannelRole::Admin => 0, diff --git a/crates/channel/src/channel_store/channel_index.rs b/crates/channel/src/channel_store/channel_index.rs index 8eb633e25f..749160f956 100644 --- a/crates/channel/src/channel_store/channel_index.rs +++ b/crates/channel/src/channel_store/channel_index.rs @@ -32,7 +32,7 @@ impl ChannelIndex { .retain(|channel_id| !channels.contains(channel_id)); } - pub fn bulk_insert(&mut self) -> ChannelPathsInsertGuard { + pub fn bulk_insert(&mut self) -> ChannelPathsInsertGuard<'_> { ChannelPathsInsertGuard { channels_ordered: &mut self.channels_ordered, channels_by_id: &mut self.channels_by_id, diff --git a/crates/client/src/proxy.rs b/crates/client/src/proxy.rs index ef87fa1a9b..eb3812ca07 100644 --- a/crates/client/src/proxy.rs +++ b/crates/client/src/proxy.rs @@ -39,7 +39,7 @@ enum ProxyType<'t> { HttpProxy(HttpProxyType<'t>), } -fn parse_proxy_type(proxy: &Url) -> Option<((String, u16), ProxyType)> { +fn parse_proxy_type(proxy: &Url) -> Option<((String, u16), ProxyType<'_>)> { let scheme = proxy.scheme(); let host = proxy.host()?.to_string(); let port = proxy.port_or_known_default()?; diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 8214ab7a8c..ea754da03f 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -464,7 +464,7 @@ impl BlockMap { map } - pub fn read(&self, wrap_snapshot: WrapSnapshot, edits: Patch) -> BlockMapReader { + pub fn read(&self, wrap_snapshot: WrapSnapshot, edits: Patch) -> BlockMapReader<'_> { self.sync(&wrap_snapshot, edits); *self.wrap_snapshot.borrow_mut() = wrap_snapshot.clone(); BlockMapReader { @@ -479,7 +479,7 @@ impl BlockMap { } } - pub fn write(&mut self, wrap_snapshot: WrapSnapshot, edits: Patch) -> BlockMapWriter { + pub fn write(&mut self, wrap_snapshot: WrapSnapshot, edits: Patch) -> BlockMapWriter<'_> { self.sync(&wrap_snapshot, edits); *self.wrap_snapshot.borrow_mut() = wrap_snapshot; BlockMapWriter(self) @@ -1327,7 +1327,7 @@ impl BlockSnapshot { } } - pub(super) fn row_infos(&self, start_row: BlockRow) -> BlockRows { + pub(super) fn row_infos(&self, start_row: BlockRow) -> BlockRows<'_> { let mut cursor = self.transforms.cursor::<(BlockRow, WrapRow)>(&()); cursor.seek(&start_row, Bias::Right, &()); let (output_start, input_start) = cursor.start(); diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 0011f07fea..92456836a9 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -357,7 +357,7 @@ impl FoldMap { &mut self, inlay_snapshot: InlaySnapshot, edits: Vec, - ) -> (FoldMapWriter, FoldSnapshot, Vec) { + ) -> (FoldMapWriter<'_>, FoldSnapshot, Vec) { let (snapshot, edits) = self.read(inlay_snapshot, edits); (FoldMapWriter(self), snapshot, edits) } @@ -730,7 +730,7 @@ impl FoldSnapshot { (line_end - line_start) as u32 } - pub fn row_infos(&self, start_row: u32) -> FoldRows { + pub fn row_infos(&self, start_row: u32) -> FoldRows<'_> { if start_row > self.transforms.summary().output.lines.row { panic!("invalid display row {}", start_row); } diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index fd662dbb1f..a29bf53882 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -726,7 +726,7 @@ impl WrapSnapshot { self.transforms.summary().output.longest_row } - pub fn row_infos(&self, start_row: u32) -> WrapRows { + pub fn row_infos(&self, start_row: u32) -> WrapRows<'_> { let mut transforms = self.transforms.cursor::<(WrapPoint, TabPoint)>(&()); transforms.seek(&WrapPoint::new(start_row, 0), Bias::Left, &()); let mut input_row = transforms.start().1.row(); diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rs index cec720f9d6..da5fbe41ef 100644 --- a/crates/editor/src/selections_collection.rs +++ b/crates/editor/src/selections_collection.rs @@ -411,7 +411,7 @@ impl<'a> MutableSelectionsCollection<'a> { self.collection.display_map(self.cx) } - pub fn buffer(&self) -> Ref { + pub fn buffer(&self) -> Ref<'_, MultiBufferSnapshot> { self.collection.buffer(self.cx) } diff --git a/crates/extension_host/src/wasm_host.rs b/crates/extension_host/src/wasm_host.rs index b31e9f1509..5d2c2f9b95 100644 --- a/crates/extension_host/src/wasm_host.rs +++ b/crates/extension_host/src/wasm_host.rs @@ -724,7 +724,7 @@ impl IncrementalCompilationCache { } impl CacheStore for IncrementalCompilationCache { - fn get(&self, key: &[u8]) -> Option> { + fn get(&self, key: &[u8]) -> Option> { self.cache.get(key).map(|v| v.into()) } diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index fbde692fdb..165497d129 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -323,7 +323,7 @@ pub trait GitRepository: Send + Sync { /// Resolve a list of refs to SHAs. fn revparse_batch(&self, revs: Vec) -> BoxFuture>>>; - fn head_sha(&self) -> BoxFuture> { + fn head_sha(&self) -> BoxFuture<'_, Option> { async move { self.revparse_batch(vec!["HEAD".into()]) .await @@ -525,7 +525,7 @@ impl GitRepository for RealGitRepository { repo.commondir().into() } - fn show(&self, commit: String) -> BoxFuture> { + fn show(&self, commit: String) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); self.executor .spawn(async move { @@ -561,7 +561,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture> { + fn load_commit(&self, commit: String, cx: AsyncApp) -> BoxFuture<'_, Result> { let Some(working_directory) = self.repository.lock().workdir().map(ToOwned::to_owned) else { return future::ready(Err(anyhow!("no working directory"))).boxed(); @@ -668,7 +668,7 @@ impl GitRepository for RealGitRepository { commit: String, mode: ResetMode, env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { async move { let working_directory = self.working_directory(); @@ -698,7 +698,7 @@ impl GitRepository for RealGitRepository { commit: String, paths: Vec, env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); async move { @@ -723,7 +723,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn load_index_text(&self, path: RepoPath) -> BoxFuture> { + fn load_index_text(&self, path: RepoPath) -> BoxFuture<'_, Option> { // https://git-scm.com/book/en/v2/Git-Internals-Git-Objects const GIT_MODE_SYMLINK: u32 = 0o120000; @@ -756,7 +756,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn load_committed_text(&self, path: RepoPath) -> BoxFuture> { + fn load_committed_text(&self, path: RepoPath) -> BoxFuture<'_, Option> { let repo = self.repository.clone(); self.executor .spawn(async move { @@ -777,7 +777,7 @@ impl GitRepository for RealGitRepository { path: RepoPath, content: Option, env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, anyhow::Result<()>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); self.executor @@ -841,7 +841,7 @@ impl GitRepository for RealGitRepository { remote.url().map(|url| url.to_string()) } - fn revparse_batch(&self, revs: Vec) -> BoxFuture>>> { + fn revparse_batch(&self, revs: Vec) -> BoxFuture<'_, Result>>> { let working_directory = self.working_directory(); self.executor .spawn(async move { @@ -891,14 +891,14 @@ impl GitRepository for RealGitRepository { .boxed() } - fn merge_message(&self) -> BoxFuture> { + fn merge_message(&self) -> BoxFuture<'_, Option> { let path = self.path().join("MERGE_MSG"); self.executor .spawn(async move { std::fs::read_to_string(&path).ok() }) .boxed() } - fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture> { + fn status(&self, path_prefixes: &[RepoPath]) -> BoxFuture<'_, Result> { let git_binary_path = self.git_binary_path.clone(); let working_directory = self.working_directory(); let path_prefixes = path_prefixes.to_owned(); @@ -919,7 +919,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn branches(&self) -> BoxFuture>> { + fn branches(&self) -> BoxFuture<'_, Result>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); self.executor @@ -986,7 +986,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn change_branch(&self, name: String) -> BoxFuture> { + fn change_branch(&self, name: String) -> BoxFuture<'_, Result<()>> { let repo = self.repository.clone(); self.executor .spawn(async move { @@ -1018,7 +1018,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn create_branch(&self, name: String) -> BoxFuture> { + fn create_branch(&self, name: String) -> BoxFuture<'_, Result<()>> { let repo = self.repository.clone(); self.executor .spawn(async move { @@ -1030,7 +1030,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture> { + fn blame(&self, path: RepoPath, content: Rope) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); @@ -1052,7 +1052,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn diff(&self, diff: DiffType) -> BoxFuture> { + fn diff(&self, diff: DiffType) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); self.executor @@ -1083,7 +1083,7 @@ impl GitRepository for RealGitRepository { &self, paths: Vec, env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); self.executor @@ -1111,7 +1111,7 @@ impl GitRepository for RealGitRepository { &self, paths: Vec, env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); @@ -1143,7 +1143,7 @@ impl GitRepository for RealGitRepository { name_and_email: Option<(SharedString, SharedString)>, options: CommitOptions, env: Arc>, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result<()>> { let working_directory = self.working_directory(); self.executor .spawn(async move { @@ -1182,7 +1182,7 @@ impl GitRepository for RealGitRepository { ask_pass: AskPassDelegate, env: Arc>, cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let executor = cx.background_executor().clone(); async move { @@ -1214,7 +1214,7 @@ impl GitRepository for RealGitRepository { ask_pass: AskPassDelegate, env: Arc>, cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let executor = cx.background_executor().clone(); async move { @@ -1239,7 +1239,7 @@ impl GitRepository for RealGitRepository { ask_pass: AskPassDelegate, env: Arc>, cx: AsyncApp, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let remote_name = format!("{}", fetch_options); let executor = cx.background_executor().clone(); @@ -1257,7 +1257,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn get_remotes(&self, branch_name: Option) -> BoxFuture>> { + fn get_remotes(&self, branch_name: Option) -> BoxFuture<'_, Result>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); self.executor @@ -1303,7 +1303,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn check_for_pushed_commit(&self) -> BoxFuture>> { + fn check_for_pushed_commit(&self) -> BoxFuture<'_, Result>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); self.executor @@ -1396,7 +1396,7 @@ impl GitRepository for RealGitRepository { .boxed() } - fn restore_checkpoint(&self, checkpoint: GitRepositoryCheckpoint) -> BoxFuture> { + fn restore_checkpoint(&self, checkpoint: GitRepositoryCheckpoint) -> BoxFuture<'_, Result<()>> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); @@ -1435,7 +1435,7 @@ impl GitRepository for RealGitRepository { &self, left: GitRepositoryCheckpoint, right: GitRepositoryCheckpoint, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); @@ -1474,7 +1474,7 @@ impl GitRepository for RealGitRepository { &self, base_checkpoint: GitRepositoryCheckpoint, target_checkpoint: GitRepositoryCheckpoint, - ) -> BoxFuture> { + ) -> BoxFuture<'_, Result> { let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index e6d5fb9e48..6c8b48873d 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -64,7 +64,7 @@ pub struct AppCell { impl AppCell { #[doc(hidden)] #[track_caller] - pub fn borrow(&self) -> AppRef { + pub fn borrow(&self) -> AppRef<'_> { if option_env!("TRACK_THREAD_BORROWS").is_some() { let thread_id = std::thread::current().id(); eprintln!("borrowed {thread_id:?}"); @@ -74,7 +74,7 @@ impl AppCell { #[doc(hidden)] #[track_caller] - pub fn borrow_mut(&self) -> AppRefMut { + pub fn borrow_mut(&self) -> AppRefMut<'_> { if option_env!("TRACK_THREAD_BORROWS").is_some() { let thread_id = std::thread::current().id(); eprintln!("borrowed {thread_id:?}"); @@ -84,7 +84,7 @@ impl AppCell { #[doc(hidden)] #[track_caller] - pub fn try_borrow_mut(&self) -> Result { + pub fn try_borrow_mut(&self) -> Result, BorrowMutError> { if option_env!("TRACK_THREAD_BORROWS").is_some() { let thread_id = std::thread::current().id(); eprintln!("borrowed {thread_id:?}"); diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index 9305a87819..4d7770b4a4 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -718,7 +718,7 @@ impl ops::Index for AtlasTextureList { impl AtlasTextureList { #[allow(unused)] - fn drain(&mut self) -> std::vec::Drain> { + fn drain(&mut self) -> std::vec::Drain<'_, Option> { self.free_list.clear(); self.textures.drain(..) } diff --git a/crates/gpui/src/platform/mac/events.rs b/crates/gpui/src/platform/mac/events.rs index b90e8f10dc..32ec4b89ab 100644 --- a/crates/gpui/src/platform/mac/events.rs +++ b/crates/gpui/src/platform/mac/events.rs @@ -25,7 +25,7 @@ pub(crate) const ESCAPE_KEY: u16 = 0x1b; const TAB_KEY: u16 = 0x09; const SHIFT_TAB_KEY: u16 = 0x19; -pub fn key_to_native(key: &str) -> Cow { +pub fn key_to_native(key: &str) -> Cow<'_, str> { use cocoa::appkit::*; let code = match key { "space" => SPACE_KEY, diff --git a/crates/gpui/src/scene.rs b/crates/gpui/src/scene.rs index 806054cefc..4eaef64afa 100644 --- a/crates/gpui/src/scene.rs +++ b/crates/gpui/src/scene.rs @@ -149,7 +149,7 @@ impl Scene { ), allow(dead_code) )] - pub(crate) fn batches(&self) -> impl Iterator { + pub(crate) fn batches(&self) -> impl Iterator> { BatchIterator { shadows: &self.shadows, shadows_start: 0, diff --git a/crates/gpui/src/text_system/line_layout.rs b/crates/gpui/src/text_system/line_layout.rs index e683bac7bd..5e5c2eff1e 100644 --- a/crates/gpui/src/text_system/line_layout.rs +++ b/crates/gpui/src/text_system/line_layout.rs @@ -616,7 +616,7 @@ impl Hash for (dyn AsCacheKeyRef + '_) { } impl AsCacheKeyRef for CacheKey { - fn as_cache_key_ref(&self) -> CacheKeyRef { + fn as_cache_key_ref(&self) -> CacheKeyRef<'_> { CacheKeyRef { text: &self.text, font_size: self.font_size, @@ -645,7 +645,7 @@ impl<'a> Borrow for Arc { } impl AsCacheKeyRef for CacheKeyRef<'_> { - fn as_cache_key_ref(&self) -> CacheKeyRef { + fn as_cache_key_ref(&self) -> CacheKeyRef<'_> { *self } } diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 4fea6236ed..0f43ff5c98 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -3127,7 +3127,7 @@ impl BufferSnapshot { None } - fn get_highlights(&self, range: Range) -> (SyntaxMapCaptures, Vec) { + fn get_highlights(&self, range: Range) -> (SyntaxMapCaptures<'_>, Vec) { let captures = self.syntax.captures(range, &self.text, |grammar| { grammar.highlights_query.as_ref() }); @@ -3143,7 +3143,7 @@ impl BufferSnapshot { /// in an arbitrary way due to being stored in a [`Rope`](text::Rope). The text is also /// returned in chunks where each chunk has a single syntax highlighting style and /// diagnostic status. - pub fn chunks(&self, range: Range, language_aware: bool) -> BufferChunks { + pub fn chunks(&self, range: Range, language_aware: bool) -> BufferChunks<'_> { let range = range.start.to_offset(self)..range.end.to_offset(self); let mut syntax = None; @@ -3192,12 +3192,12 @@ impl BufferSnapshot { } /// Iterates over every [`SyntaxLayer`] in the buffer. - pub fn syntax_layers(&self) -> impl Iterator + '_ { + pub fn syntax_layers(&self) -> impl Iterator> + '_ { self.syntax .layers_for_range(0..self.len(), &self.text, true) } - pub fn syntax_layer_at(&self, position: D) -> Option { + pub fn syntax_layer_at(&self, position: D) -> Option> { let offset = position.to_offset(self); self.syntax .layers_for_range(offset..offset, &self.text, false) @@ -3208,7 +3208,7 @@ impl BufferSnapshot { pub fn smallest_syntax_layer_containing( &self, range: Range, - ) -> Option { + ) -> Option> { let range = range.to_offset(self); return self .syntax @@ -3426,7 +3426,7 @@ impl BufferSnapshot { } /// Returns the root syntax node within the given row - pub fn syntax_root_ancestor(&self, position: Anchor) -> Option { + pub fn syntax_root_ancestor(&self, position: Anchor) -> Option> { let start_offset = position.to_offset(self); let row = self.summary_for_anchor::(&position).row as usize; @@ -3763,7 +3763,7 @@ impl BufferSnapshot { &self, range: Range, query: fn(&Grammar) -> Option<&tree_sitter::Query>, - ) -> SyntaxMapMatches { + ) -> SyntaxMapMatches<'_> { self.syntax.matches(range, self, query) } diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 0d131301cc..a61bc1c90f 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -1126,7 +1126,7 @@ impl<'a> SyntaxMapMatches<'a> { &self.grammars } - pub fn peek(&self) -> Option { + pub fn peek(&self) -> Option> { let layer = self.layers.first()?; if !layer.has_next { @@ -1550,7 +1550,7 @@ fn insert_newlines_between_ranges( impl OwnedSyntaxLayer { /// Returns the root syntax node for this layer. - pub fn node(&self) -> Node { + pub fn node(&self) -> Node<'_> { self.tree .root_node_with_offset(self.offset.0, self.offset.1) } diff --git a/crates/livekit_client/src/livekit_client/playback.rs b/crates/livekit_client/src/livekit_client/playback.rs index d941c314a9..3f6b3fd7db 100644 --- a/crates/livekit_client/src/livekit_client/playback.rs +++ b/crates/livekit_client/src/livekit_client/playback.rs @@ -412,7 +412,7 @@ impl libwebrtc::native::audio_mixer::AudioMixerSource for AudioMixerSource { self.sample_rate } - fn get_audio_frame_with_info<'a>(&self, target_sample_rate: u32) -> Option { + fn get_audio_frame_with_info<'a>(&self, target_sample_rate: u32) -> Option> { assert_eq!(self.sample_rate, target_sample_rate); let buf = self.buffer.lock().pop_front()?; Some(AudioFrame { diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs index 172cda09bb..ac959d13b5 100644 --- a/crates/markdown/src/markdown.rs +++ b/crates/markdown/src/markdown.rs @@ -231,7 +231,7 @@ impl Markdown { &self.parsed_markdown } - pub fn escape(s: &str) -> Cow { + pub fn escape(s: &str) -> Cow<'_, str> { // Valid to use bytes since multi-byte UTF-8 doesn't use ASCII chars. let count = s .bytes() diff --git a/crates/markdown_preview/src/markdown_parser.rs b/crates/markdown_preview/src/markdown_parser.rs index 0e540fcc9e..27691f2ecf 100644 --- a/crates/markdown_preview/src/markdown_parser.rs +++ b/crates/markdown_preview/src/markdown_parser.rs @@ -72,25 +72,25 @@ impl<'a> MarkdownParser<'a> { self.cursor >= self.tokens.len() - 1 } - fn peek(&self, steps: usize) -> Option<&(Event, Range)> { + fn peek(&self, steps: usize) -> Option<&(Event<'_>, Range)> { if self.eof() || (steps + self.cursor) >= self.tokens.len() { return self.tokens.last(); } return self.tokens.get(self.cursor + steps); } - fn previous(&self) -> Option<&(Event, Range)> { + fn previous(&self) -> Option<&(Event<'_>, Range)> { if self.cursor == 0 || self.cursor > self.tokens.len() { return None; } return self.tokens.get(self.cursor - 1); } - fn current(&self) -> Option<&(Event, Range)> { + fn current(&self) -> Option<&(Event<'_>, Range)> { return self.peek(0); } - fn current_event(&self) -> Option<&Event> { + fn current_event(&self) -> Option<&Event<'_>> { return self.current().map(|(event, _)| event); } diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 1815f3dd10..6d544222d4 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -728,7 +728,7 @@ impl MultiBuffer { self.snapshot.borrow().clone() } - pub fn read(&self, cx: &App) -> Ref { + pub fn read(&self, cx: &App) -> Ref<'_, MultiBufferSnapshot> { self.sync(cx); self.snapshot.borrow() } @@ -2615,7 +2615,7 @@ impl MultiBuffer { "untitled".into() } - fn buffer_based_title(&self, buffer: &Buffer) -> Option> { + fn buffer_based_title(&self, buffer: &Buffer) -> Option> { let mut is_leading_whitespace = true; let mut count = 0; let mut prev_was_space = false; @@ -3779,7 +3779,7 @@ impl MultiBufferSnapshot { .flat_map(|c| c.chars().rev()) } - fn reversed_chunks_in_range(&self, range: Range) -> ReversedMultiBufferChunks { + fn reversed_chunks_in_range(&self, range: Range) -> ReversedMultiBufferChunks<'_> { let mut cursor = self.cursor::(); cursor.seek(&range.end); let current_chunks = cursor.region().as_ref().map(|region| { @@ -4294,7 +4294,7 @@ impl MultiBufferSnapshot { self.excerpts.summary().widest_line_number + 1 } - pub fn bytes_in_range(&self, range: Range) -> MultiBufferBytes { + pub fn bytes_in_range(&self, range: Range) -> MultiBufferBytes<'_> { let range = range.start.to_offset(self)..range.end.to_offset(self); let mut excerpts = self.cursor::(); excerpts.seek(&range.start); @@ -4333,7 +4333,7 @@ impl MultiBufferSnapshot { pub fn reversed_bytes_in_range( &self, range: Range, - ) -> ReversedMultiBufferBytes { + ) -> ReversedMultiBufferBytes<'_> { let range = range.start.to_offset(self)..range.end.to_offset(self); let mut chunks = self.reversed_chunks_in_range(range.clone()); let chunk = chunks.next().map_or(&[][..], |c| c.as_bytes()); @@ -4344,7 +4344,7 @@ impl MultiBufferSnapshot { } } - pub fn row_infos(&self, start_row: MultiBufferRow) -> MultiBufferRows { + pub fn row_infos(&self, start_row: MultiBufferRow) -> MultiBufferRows<'_> { let mut cursor = self.cursor::(); cursor.seek(&Point::new(start_row.0, 0)); let mut result = MultiBufferRows { @@ -4357,7 +4357,11 @@ impl MultiBufferSnapshot { result } - pub fn chunks(&self, range: Range, language_aware: bool) -> MultiBufferChunks { + pub fn chunks( + &self, + range: Range, + language_aware: bool, + ) -> MultiBufferChunks<'_> { let mut chunks = MultiBufferChunks { excerpt_offset_range: ExcerptOffset::new(0)..ExcerptOffset::new(0), range: 0..0, @@ -5318,7 +5322,7 @@ impl MultiBufferSnapshot { .map(|excerpt| (excerpt.id, &excerpt.buffer, excerpt.range.clone())) } - fn cursor(&self) -> MultiBufferCursor { + fn cursor(&self) -> MultiBufferCursor<'_, D> { let excerpts = self.excerpts.cursor(&()); let diff_transforms = self.diff_transforms.cursor(&()); MultiBufferCursor { @@ -6081,7 +6085,7 @@ impl MultiBufferSnapshot { pub fn syntax_ancestor( &self, range: Range, - ) -> Option<(tree_sitter::Node, MultiOrSingleBufferOffsetRange)> { + ) -> Option<(tree_sitter::Node<'_>, MultiOrSingleBufferOffsetRange)> { let range = range.start.to_offset(self)..range.end.to_offset(self); let mut excerpt = self.excerpt_containing(range.clone())?; let node = excerpt @@ -6279,7 +6283,10 @@ impl MultiBufferSnapshot { } /// Returns the excerpt containing range and its offset start within the multibuffer or none if `range` spans multiple excerpts - pub fn excerpt_containing(&self, range: Range) -> Option { + pub fn excerpt_containing( + &self, + range: Range, + ) -> Option> { let range = range.start.to_offset(self)..range.end.to_offset(self); let mut cursor = self.cursor::(); cursor.seek(&range.start); @@ -6933,7 +6940,7 @@ impl Excerpt { } } - fn chunks_in_range(&self, range: Range, language_aware: bool) -> ExcerptChunks { + fn chunks_in_range(&self, range: Range, language_aware: bool) -> ExcerptChunks<'_> { let content_start = self.range.context.start.to_offset(&self.buffer); let chunks_start = content_start + range.start; let chunks_end = content_start + cmp::min(range.end, self.text_summary.len); diff --git a/crates/project/src/git_store/git_traversal.rs b/crates/project/src/git_store/git_traversal.rs index b3a45406c3..68ed03cfe9 100644 --- a/crates/project/src/git_store/git_traversal.rs +++ b/crates/project/src/git_store/git_traversal.rs @@ -211,7 +211,7 @@ pub struct GitEntry { } impl GitEntry { - pub fn to_ref(&self) -> GitEntryRef { + pub fn to_ref(&self) -> GitEntryRef<'_> { GitEntryRef { entry: &self.entry, git_summary: self.git_summary, diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 492c1722d8..c578dda0e9 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -467,7 +467,7 @@ impl CompletionSource { } } - pub fn lsp_completion(&self, apply_defaults: bool) -> Option> { + pub fn lsp_completion(&self, apply_defaults: bool) -> Option> { if let Self::Lsp { lsp_completion, lsp_defaults, diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 1a3d07ef49..ed27b11e8a 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -3227,7 +3227,7 @@ impl ProjectPanel { None } - fn entry_at_index(&self, index: usize) -> Option<(WorktreeId, GitEntryRef)> { + fn entry_at_index(&self, index: usize) -> Option<(WorktreeId, GitEntryRef<'_>)> { let mut offset = 0; for (worktree_id, visible_worktree_entries, _) in &self.visible_entries { if visible_worktree_entries.len() > offset + index { diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index 1f7c8295a9..134f728680 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -281,7 +281,7 @@ impl RemoteEntry { matches!(self, Self::Project { .. }) } - fn connection(&self) -> Cow { + fn connection(&self) -> Cow<'_, SshConnection> { match self { Self::Project { connection, .. } => Cow::Borrowed(connection), Self::SshConfig { host, .. } => Cow::Owned(SshConnection { diff --git a/crates/rope/src/chunk.rs b/crates/rope/src/chunk.rs index 5b0a671d86..dc00674380 100644 --- a/crates/rope/src/chunk.rs +++ b/crates/rope/src/chunk.rs @@ -53,7 +53,7 @@ impl Chunk { } #[inline(always)] - pub fn as_slice(&self) -> ChunkSlice { + pub fn as_slice(&self) -> ChunkSlice<'_> { ChunkSlice { chars: self.chars, chars_utf16: self.chars_utf16, @@ -64,7 +64,7 @@ impl Chunk { } #[inline(always)] - pub fn slice(&self, range: Range) -> ChunkSlice { + pub fn slice(&self, range: Range) -> ChunkSlice<'_> { self.as_slice().slice(range) } } diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs index b049498ccb..535b863b7d 100644 --- a/crates/rope/src/rope.rs +++ b/crates/rope/src/rope.rs @@ -241,7 +241,7 @@ impl Rope { self.chunks.extent(&()) } - pub fn cursor(&self, offset: usize) -> Cursor { + pub fn cursor(&self, offset: usize) -> Cursor<'_> { Cursor::new(self, offset) } @@ -258,23 +258,23 @@ impl Rope { .flat_map(|chunk| chunk.chars().rev()) } - pub fn bytes_in_range(&self, range: Range) -> Bytes { + pub fn bytes_in_range(&self, range: Range) -> Bytes<'_> { Bytes::new(self, range, false) } - pub fn reversed_bytes_in_range(&self, range: Range) -> Bytes { + pub fn reversed_bytes_in_range(&self, range: Range) -> Bytes<'_> { Bytes::new(self, range, true) } - pub fn chunks(&self) -> Chunks { + pub fn chunks(&self) -> Chunks<'_> { self.chunks_in_range(0..self.len()) } - pub fn chunks_in_range(&self, range: Range) -> Chunks { + pub fn chunks_in_range(&self, range: Range) -> Chunks<'_> { Chunks::new(self, range, false) } - pub fn reversed_chunks_in_range(&self, range: Range) -> Chunks { + pub fn reversed_chunks_in_range(&self, range: Range) -> Chunks<'_> { Chunks::new(self, range, true) } diff --git a/crates/sum_tree/src/sum_tree.rs b/crates/sum_tree/src/sum_tree.rs index d5f8deadad..82022d6685 100644 --- a/crates/sum_tree/src/sum_tree.rs +++ b/crates/sum_tree/src/sum_tree.rs @@ -380,7 +380,7 @@ impl SumTree { items } - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter::new(self) } diff --git a/crates/terminal/src/terminal_settings.rs b/crates/terminal/src/terminal_settings.rs index daebb9924e..bd93b7e0a6 100644 --- a/crates/terminal/src/terminal_settings.rs +++ b/crates/terminal/src/terminal_settings.rs @@ -103,7 +103,7 @@ pub struct VenvSettingsContent<'a> { } impl VenvSettings { - pub fn as_option(&self) -> Option { + pub fn as_option(&self) -> Option> { match self { VenvSettings::Off => None, VenvSettings::On { diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index 27692ff7fb..a2742081f4 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -2049,7 +2049,7 @@ impl BufferSnapshot { self.visible_text.reversed_chars_at(offset) } - pub fn reversed_chunks_in_range(&self, range: Range) -> rope::Chunks { + pub fn reversed_chunks_in_range(&self, range: Range) -> rope::Chunks<'_> { let range = range.start.to_offset(self)..range.end.to_offset(self); self.visible_text.reversed_chunks_in_range(range) } diff --git a/crates/watch/src/watch.rs b/crates/watch/src/watch.rs index a4a0ca6df4..c0741e4a20 100644 --- a/crates/watch/src/watch.rs +++ b/crates/watch/src/watch.rs @@ -150,7 +150,7 @@ impl Drop for Changed<'_, T> { } impl Receiver { - pub fn borrow(&mut self) -> parking_lot::MappedRwLockReadGuard { + pub fn borrow(&mut self) -> parking_lot::MappedRwLockReadGuard<'_, T> { let state = self.state.read(); self.version = state.version; RwLockReadGuard::map(state, |state| &state.value) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 62ce35789e..6b3a0b855f 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -2566,7 +2566,7 @@ impl Snapshot { include_dirs: bool, include_ignored: bool, start_offset: usize, - ) -> Traversal { + ) -> Traversal<'_> { let mut cursor = self.entries_by_path.cursor(&()); cursor.seek( &TraversalTarget::Count { @@ -2593,19 +2593,19 @@ impl Snapshot { include_dirs: bool, include_ignored: bool, path: &Path, - ) -> Traversal { + ) -> Traversal<'_> { Traversal::new(self, include_files, include_dirs, include_ignored, path) } - pub fn files(&self, include_ignored: bool, start: usize) -> Traversal { + pub fn files(&self, include_ignored: bool, start: usize) -> Traversal<'_> { self.traverse_from_offset(true, false, include_ignored, start) } - pub fn directories(&self, include_ignored: bool, start: usize) -> Traversal { + pub fn directories(&self, include_ignored: bool, start: usize) -> Traversal<'_> { self.traverse_from_offset(false, true, include_ignored, start) } - pub fn entries(&self, include_ignored: bool, start: usize) -> Traversal { + pub fn entries(&self, include_ignored: bool, start: usize) -> Traversal<'_> { self.traverse_from_offset(true, true, include_ignored, start) }