diff --git a/crates/channel/src/channel_store/channel_index.rs b/crates/channel/src/channel_store/channel_index.rs index fc753f7444..02a8cd333b 100644 --- a/crates/channel/src/channel_store/channel_index.rs +++ b/crates/channel/src/channel_store/channel_index.rs @@ -97,9 +97,9 @@ impl<'a> Drop for ChannelPathsInsertGuard<'a> { } } -fn channel_path_sorting_key<'a>( +fn channel_path_sorting_key( id: ChannelId, - channels_by_id: &'a BTreeMap>, + channels_by_id: &BTreeMap>, ) -> impl Iterator { let (parent_path, name) = channels_by_id .get(&id) diff --git a/crates/collab/src/tests/test_server.rs b/crates/collab/src/tests/test_server.rs index 7397e51f79..469c4176ab 100644 --- a/crates/collab/src/tests/test_server.rs +++ b/crates/collab/src/tests/test_server.rs @@ -138,7 +138,7 @@ impl TestServer { (server, client_a, client_b, channel_id) } - pub async fn start1<'a>(cx: &'a mut TestAppContext) -> TestClient { + pub async fn start1(cx: &mut TestAppContext) -> TestClient { let mut server = Self::start(cx.executor().clone()).await; server.create_client(cx, "user_a").await } @@ -589,19 +589,19 @@ impl TestClient { .await; } - pub fn local_projects<'a>(&'a self) -> impl Deref>> + 'a { + pub fn local_projects(&self) -> impl Deref>> + '_ { Ref::map(self.state.borrow(), |state| &state.local_projects) } - pub fn remote_projects<'a>(&'a self) -> impl Deref>> + 'a { + pub fn remote_projects(&self) -> impl Deref>> + '_ { Ref::map(self.state.borrow(), |state| &state.remote_projects) } - pub fn local_projects_mut<'a>(&'a self) -> impl DerefMut>> + 'a { + pub fn local_projects_mut(&self) -> impl DerefMut>> + '_ { RefMut::map(self.state.borrow_mut(), |state| &mut state.local_projects) } - pub fn remote_projects_mut<'a>(&'a self) -> impl DerefMut>> + 'a { + pub fn remote_projects_mut(&self) -> impl DerefMut>> + '_ { RefMut::map(self.state.borrow_mut(), |state| &mut state.remote_projects) } @@ -614,16 +614,14 @@ impl TestClient { }) } - pub fn buffers<'a>( - &'a self, - ) -> impl DerefMut, HashSet>>> + 'a + pub fn buffers( + &self, + ) -> impl DerefMut, HashSet>>> + '_ { RefMut::map(self.state.borrow_mut(), |state| &mut state.buffers) } - pub fn channel_buffers<'a>( - &'a self, - ) -> impl DerefMut>> + 'a { + pub fn channel_buffers(&self) -> impl DerefMut>> + '_ { RefMut::map(self.state.borrow_mut(), |state| &mut state.channel_buffers) } diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 8285644826..c0213bc331 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -512,13 +512,13 @@ impl DisplaySnapshot { }) } - pub fn chunks<'a>( - &'a self, + pub fn chunks( + &self, display_rows: Range, language_aware: bool, inlay_highlight_style: Option, suggestion_highlight_style: Option, - ) -> DisplayChunks<'a> { + ) -> DisplayChunks<'_> { self.block_snapshot.chunks( display_rows, language_aware, @@ -1826,10 +1826,10 @@ pub mod tests { ) } - fn syntax_chunks<'a>( + fn syntax_chunks( rows: Range, map: &Model, - theme: &'a SyntaxTheme, + theme: &SyntaxTheme, cx: &mut AppContext, ) -> Vec<(String, Option)> { chunks(rows, map, theme, cx) @@ -1838,10 +1838,10 @@ pub mod tests { .collect() } - fn chunks<'a>( + fn chunks( rows: Range, map: &Model, - theme: &'a SyntaxTheme, + theme: &SyntaxTheme, cx: &mut AppContext, ) -> Vec<(String, Option, Option)> { let snapshot = map.update(cx, |map, cx| map.snapshot(cx)); diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 229b05e955..19c6e8970d 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -982,7 +982,7 @@ impl InlaySnapshot { summary } - pub fn buffer_rows<'a>(&'a self, row: u32) -> InlayBufferRows<'a> { + pub fn buffer_rows(&self, row: u32) -> InlayBufferRows<'_> { let mut cursor = self.transforms.cursor::<(InlayPoint, Point)>(); let inlay_point = InlayPoint::new(row, 0); cursor.seek(&inlay_point, Bias::Left, &()); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 78e0afd2b6..ce15b36f6a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1705,18 +1705,14 @@ impl Editor { } } - pub fn language_at<'a, T: ToOffset>( - &self, - point: T, - cx: &'a AppContext, - ) -> Option> { + pub fn language_at(&self, point: T, cx: &AppContext) -> Option> { self.buffer.read(cx).language_at(point, cx) } - pub fn file_at<'a, T: ToOffset>( + pub fn file_at( &self, point: T, - cx: &'a AppContext, + cx: &AppContext, ) -> Option> { self.buffer.read(cx).read(cx).file_at(point).cloned() } @@ -10439,7 +10435,7 @@ pub fn styled_runs_for_code_label<'a>( }) } -pub(crate) fn split_words<'a>(text: &'a str) -> impl std::iter::Iterator + 'a { +pub(crate) fn split_words(text: &str) -> impl std::iter::Iterator + '_ { let mut index = 0; let mut codepoints = text.char_indices().peekable(); diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index c1d5e052e1..cecc81fb4b 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -7310,7 +7310,7 @@ async fn go_to_hunk(executor: BackgroundExecutor, cx: &mut gpui::TestAppContext) #[test] fn test_split_words() { - fn split<'a>(text: &'a str) -> Vec<&'a str> { + fn split(text: &str) -> Vec<&str> { split_words(text).collect() } diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 8eb1119110..96fdcfdefc 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -593,7 +593,7 @@ impl Item for Editor { None } - fn tab_description<'a>(&self, detail: usize, cx: &'a AppContext) -> Option { + fn tab_description(&self, detail: usize, cx: &AppContext) -> Option { let path = path_for_buffer(&self.buffer, detail, true, cx)?; Some(path.to_string_lossy().to_string().into()) } diff --git a/crates/git/src/diff.rs b/crates/git/src/diff.rs index 07b0240f60..20f425f42c 100644 --- a/crates/git/src/diff.rs +++ b/crates/git/src/diff.rs @@ -208,8 +208,8 @@ impl BufferDiff { } } - fn process_patch_hunk<'a>( - patch: &GitPatch<'a>, + fn process_patch_hunk( + patch: &GitPatch<'_>, hunk_index: usize, buffer: &text::BufferSnapshot, buffer_row_divergence: &mut i64, diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index e1d98d23bd..0727123e84 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -2839,10 +2839,10 @@ impl BufferSnapshot { } /// Returns bracket range pairs overlapping or adjacent to `range` - pub fn bracket_ranges<'a, T: ToOffset>( - &'a self, + pub fn bracket_ranges( + &self, range: Range, - ) -> impl Iterator, Range)> + 'a { + ) -> impl Iterator, Range)> + '_ { // Find bracket pairs that *inclusively* contain the given range. let range = range.start.to_offset(self).saturating_sub(1) ..self.len().min(range.end.to_offset(self) + 1); @@ -2935,10 +2935,10 @@ impl BufferSnapshot { /// Returns anchor ranges for any matches of the redaction query. /// The buffer can be associated with multiple languages, and the redaction query associated with each /// will be run on the relevant section of the buffer. - pub fn redacted_ranges<'a, T: ToOffset>( - &'a self, + pub fn redacted_ranges( + &self, range: Range, - ) -> impl Iterator> + 'a { + ) -> impl Iterator> + '_ { let offset_range = range.start.to_offset(self)..range.end.to_offset(self); let mut syntax_matches = self.syntax.matches(offset_range, self, |grammar| { grammar @@ -3015,28 +3015,28 @@ impl BufferSnapshot { /// Returns all the Git diff hunks intersecting the given /// row range. - pub fn git_diff_hunks_in_row_range<'a>( - &'a self, + pub fn git_diff_hunks_in_row_range( + &self, range: Range, - ) -> impl 'a + Iterator> { + ) -> impl '_ + Iterator> { self.git_diff.hunks_in_row_range(range, self) } /// Returns all the Git diff hunks intersecting the given /// range. - pub fn git_diff_hunks_intersecting_range<'a>( - &'a self, + pub fn git_diff_hunks_intersecting_range( + &self, range: Range, - ) -> impl 'a + Iterator> { + ) -> impl '_ + Iterator> { self.git_diff.hunks_intersecting_range(range, self) } /// Returns all the Git diff hunks intersecting the given /// range, in reverse order. - pub fn git_diff_hunks_intersecting_range_rev<'a>( - &'a self, + pub fn git_diff_hunks_intersecting_range_rev( + &self, range: Range, - ) -> impl 'a + Iterator> { + ) -> impl '_ + Iterator> { self.git_diff.hunks_intersecting_range_rev(range, self) } diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 0c0d434825..61af2d366c 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -1525,11 +1525,7 @@ impl MultiBuffer { .unwrap_or(false) } - pub fn language_at<'a, T: ToOffset>( - &self, - point: T, - cx: &'a AppContext, - ) -> Option> { + pub fn language_at(&self, point: T, cx: &AppContext) -> Option> { self.point_to_buffer_offset(point, cx) .and_then(|(buffer, offset, _)| buffer.read(cx).language_at(offset)) } @@ -2828,10 +2824,10 @@ impl MultiBufferSnapshot { .map(|excerpt| (excerpt.id, &excerpt.buffer, excerpt.range.clone())) } - fn excerpts_for_range<'a, T: ToOffset>( - &'a self, + fn excerpts_for_range( + &self, range: Range, - ) -> impl Iterator + 'a { + ) -> impl Iterator + '_ { let range = range.start.to_offset(self)..range.end.to_offset(self); let mut cursor = self.excerpts.cursor::(); @@ -2956,10 +2952,10 @@ impl MultiBufferSnapshot { /// Returns enclosing bracket ranges containing the given range or returns None if the range is /// not contained in a single excerpt - pub fn enclosing_bracket_ranges<'a, T: ToOffset>( - &'a self, + pub fn enclosing_bracket_ranges( + &self, range: Range, - ) -> Option, Range)> + 'a> { + ) -> Option, Range)> + '_> { let range = range.start.to_offset(self)..range.end.to_offset(self); let excerpt = self.excerpt_containing(range.clone())?; @@ -2973,10 +2969,10 @@ impl MultiBufferSnapshot { /// Returns bracket range pairs overlapping the given `range` or returns None if the `range` is /// not contained in a single excerpt - pub fn bracket_ranges<'a, T: ToOffset>( - &'a self, + pub fn bracket_ranges( + &self, range: Range, - ) -> Option, Range)> + 'a> { + ) -> Option, Range)> + '_> { let range = range.start.to_offset(self)..range.end.to_offset(self); let excerpt = self.excerpt_containing(range.clone())?; @@ -3041,12 +3037,12 @@ impl MultiBufferSnapshot { self.trailing_excerpt_update_count } - pub fn file_at<'a, T: ToOffset>(&'a self, point: T) -> Option<&'a Arc> { + pub fn file_at(&self, point: T) -> Option<&Arc> { self.point_to_buffer_offset(point) .and_then(|(buffer, _)| buffer.file()) } - pub fn language_at<'a, T: ToOffset>(&'a self, point: T) -> Option<&'a Arc> { + pub fn language_at(&self, point: T) -> Option<&Arc> { self.point_to_buffer_offset(point) .and_then(|(buffer, offset)| buffer.language_at(offset)) } @@ -3065,7 +3061,7 @@ impl MultiBufferSnapshot { language_settings(language, file, cx) } - pub fn language_scope_at<'a, T: ToOffset>(&'a self, point: T) -> Option { + pub fn language_scope_at(&self, point: T) -> Option { self.point_to_buffer_offset(point) .and_then(|(buffer, offset)| buffer.language_scope_at(offset)) } @@ -3133,10 +3129,10 @@ impl MultiBufferSnapshot { false } - pub fn git_diff_hunks_in_range_rev<'a>( - &'a self, + pub fn git_diff_hunks_in_range_rev( + &self, row_range: Range, - ) -> impl 'a + Iterator> { + ) -> impl Iterator> + '_ { let mut cursor = self.excerpts.cursor::(); cursor.seek(&Point::new(row_range.end, 0), Bias::Left, &()); @@ -3198,10 +3194,10 @@ impl MultiBufferSnapshot { .flatten() } - pub fn git_diff_hunks_in_range<'a>( - &'a self, + pub fn git_diff_hunks_in_range( + &self, row_range: Range, - ) -> impl 'a + Iterator> { + ) -> impl Iterator> + '_ { let mut cursor = self.excerpts.cursor::(); cursor.seek(&Point::new(row_range.start, 0), Bias::Right, &()); @@ -3317,7 +3313,7 @@ impl MultiBufferSnapshot { )) } - fn excerpt_locator_for_id<'a>(&'a self, id: ExcerptId) -> &'a Locator { + fn excerpt_locator_for_id(&self, id: ExcerptId) -> &Locator { if id == ExcerptId::min() { Locator::min_ref() } else if id == ExcerptId::max() { @@ -3342,7 +3338,7 @@ impl MultiBufferSnapshot { Some(&self.excerpt(excerpt_id)?.buffer) } - fn excerpt<'a>(&'a self, excerpt_id: ExcerptId) -> Option<&'a Excerpt> { + fn excerpt(&self, excerpt_id: ExcerptId) -> Option<&Excerpt> { let mut cursor = self.excerpts.cursor::>(); let locator = self.excerpt_locator_for_id(excerpt_id); cursor.seek(&Some(locator), Bias::Left, &()); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 71c68a989d..332967875d 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1016,7 +1016,7 @@ impl Project { } /// Collect all worktrees, including ones that don't appear in the project panel - pub fn worktrees<'a>(&'a self) -> impl 'a + DoubleEndedIterator> { + pub fn worktrees(&self) -> impl '_ + DoubleEndedIterator> { self.worktrees .iter() .filter_map(move |worktree| worktree.upgrade()) @@ -9155,7 +9155,7 @@ fn subscribe_for_copilot_events( ) } -fn glob_literal_prefix<'a>(glob: &'a str) -> &'a str { +fn glob_literal_prefix(glob: &str) -> &str { let mut literal_end = 0; for (i, part) in glob.split(path::MAIN_SEPARATOR).enumerate() { if part.contains(&['*', '?', '{', '}']) { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 16d4516b5c..3954015907 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -2845,10 +2845,10 @@ mod tests { )) } #[track_caller] - fn assert_key_bindings_for<'a>( + fn assert_key_bindings_for( window: AnyWindowHandle, cx: &TestAppContext, - actions: Vec<(&'static str, &'a dyn Action)>, + actions: Vec<(&'static str, &dyn Action)>, line: u32, ) { let available_actions = cx diff --git a/tooling/xtask/src/main.rs b/tooling/xtask/src/main.rs index d716842cb4..f6e7496669 100644 --- a/tooling/xtask/src/main.rs +++ b/tooling/xtask/src/main.rs @@ -94,7 +94,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> { "clippy::iter_overeager_cloned", "clippy::let_underscore_future", "clippy::map_entry", - "clippy::needless_lifetimes", "clippy::needless_update", "clippy::never_loop", "clippy::non_canonical_clone_impl",