diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d2503aa50..1402912c2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -240,7 +240,7 @@ jobs: timeout-minutes: 60 name: (Windows) Run Clippy and tests if: github.repository_owner == 'zed-industries' - runs-on: hosted-windows-1 + runs-on: hosted-windows-2 steps: # more info here:- https://github.com/rust-lang/cargo/issues/13020 - name: Enable longer pathnames for git diff --git a/Cargo.toml b/Cargo.toml index 5929bb2399..5d958f3bb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -709,6 +709,9 @@ debug = "full" lto = false codegen-units = 16 +[workspace.lints.rust] +unexpected_cfgs = { level = "allow" } + [workspace.lints.clippy] dbg_macro = "deny" todo = "deny" diff --git a/crates/buffer_diff/src/buffer_diff.rs b/crates/buffer_diff/src/buffer_diff.rs index 2363567ce1..5a3264bb98 100644 --- a/crates/buffer_diff/src/buffer_diff.rs +++ b/crates/buffer_diff/src/buffer_diff.rs @@ -109,7 +109,7 @@ impl sum_tree::Summary for DiffHunkSummary { } } -impl<'a> sum_tree::SeekTarget<'a, DiffHunkSummary, DiffHunkSummary> for Anchor { +impl sum_tree::SeekTarget<'_, DiffHunkSummary, DiffHunkSummary> for Anchor { fn cmp(&self, cursor_location: &DiffHunkSummary, buffer: &text::BufferSnapshot) -> Ordering { if self .cmp(&cursor_location.buffer_range.start, buffer) diff --git a/crates/channel/src/channel_store/channel_index.rs b/crates/channel/src/channel_store/channel_index.rs index 02a8cd333b..c3311ad879 100644 --- a/crates/channel/src/channel_store/channel_index.rs +++ b/crates/channel/src/channel_store/channel_index.rs @@ -48,7 +48,7 @@ pub struct ChannelPathsInsertGuard<'a> { channels_by_id: &'a mut BTreeMap>, } -impl<'a> ChannelPathsInsertGuard<'a> { +impl ChannelPathsInsertGuard<'_> { pub fn insert(&mut self, channel_proto: proto::Channel) -> bool { let mut ret = false; let parent_path = channel_proto @@ -86,7 +86,7 @@ impl<'a> ChannelPathsInsertGuard<'a> { } } -impl<'a> Drop for ChannelPathsInsertGuard<'a> { +impl Drop for ChannelPathsInsertGuard<'_> { fn drop(&mut self) { self.channels_ordered.sort_by(|a, b| { let a = channel_path_sorting_key(*a, self.channels_by_id); diff --git a/crates/collab/src/db/queries/extensions.rs b/crates/collab/src/db/queries/extensions.rs index 2b76e12335..19515e013c 100644 --- a/crates/collab/src/db/queries/extensions.rs +++ b/crates/collab/src/db/queries/extensions.rs @@ -202,7 +202,7 @@ impl Database { .await } - pub async fn get_known_extension_versions<'a>(&self) -> Result>> { + pub async fn get_known_extension_versions(&self) -> Result>> { self.transaction(|tx| async move { let mut extension_external_ids_by_id = HashMap::default(); diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 53bf63165e..2c5c44c067 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -975,7 +975,7 @@ impl Server { } } -impl<'a> Deref for ConnectionPoolGuard<'a> { +impl Deref for ConnectionPoolGuard<'_> { type Target = ConnectionPool; fn deref(&self) -> &Self::Target { @@ -983,13 +983,13 @@ impl<'a> Deref for ConnectionPoolGuard<'a> { } } -impl<'a> DerefMut for ConnectionPoolGuard<'a> { +impl DerefMut for ConnectionPoolGuard<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.guard } } -impl<'a> Drop for ConnectionPoolGuard<'a> { +impl Drop for ConnectionPoolGuard<'_> { fn drop(&mut self) { #[cfg(test)] self.check_invariants(); diff --git a/crates/collab_ui/src/panel_settings.rs b/crates/collab_ui/src/panel_settings.rs index 3133894d80..075eec3a0a 100644 --- a/crates/collab_ui/src/panel_settings.rs +++ b/crates/collab_ui/src/panel_settings.rs @@ -27,7 +27,7 @@ impl<'de> Deserialize<'de> for ChatPanelButton { { struct Visitor; - impl<'de> serde::de::Visitor<'de> for Visitor { + impl serde::de::Visitor<'_> for Visitor { type Value = ChatPanelButton; fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/crates/copilot/src/copilot_chat.rs b/crates/copilot/src/copilot_chat.rs index 83a71bc4af..a528af6a13 100644 --- a/crates/copilot/src/copilot_chat.rs +++ b/crates/copilot/src/copilot_chat.rs @@ -411,7 +411,7 @@ async fn stream_completion( match serde_json::from_str::(line) { Ok(response) => { - if response.choices.first().is_none() + if response.choices.is_empty() || response.choices.first().unwrap().finish_reason.is_some() { None diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index b0a9810d50..85f4f44fd6 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -999,7 +999,7 @@ impl std::ops::DerefMut for BlockPoint { } } -impl<'a> Deref for BlockMapReader<'a> { +impl Deref for BlockMapReader<'_> { type Target = BlockSnapshot; fn deref(&self) -> &Self::Target { @@ -1007,13 +1007,13 @@ impl<'a> Deref for BlockMapReader<'a> { } } -impl<'a> DerefMut for BlockMapReader<'a> { +impl DerefMut for BlockMapReader<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.snapshot } } -impl<'a> BlockMapReader<'a> { +impl BlockMapReader<'_> { pub fn row_for_block(&self, block_id: CustomBlockId) -> Option { let block = self.blocks.iter().find(|block| block.id == block_id)?; let buffer_row = block @@ -1053,7 +1053,7 @@ impl<'a> BlockMapReader<'a> { } } -impl<'a> BlockMapWriter<'a> { +impl BlockMapWriter<'_> { pub fn insert( &mut self, blocks: impl IntoIterator>, @@ -1740,7 +1740,7 @@ impl BlockSnapshot { } } -impl<'a> BlockChunks<'a> { +impl BlockChunks<'_> { /// Go to the next transform fn advance(&mut self) { self.input_chunk = Chunk::default(); @@ -1856,7 +1856,7 @@ impl<'a> Iterator for BlockChunks<'a> { } } -impl<'a> Iterator for BlockRows<'a> { +impl Iterator for BlockRows<'_> { type Item = RowInfo; fn next(&mut self) -> Option { @@ -1952,7 +1952,7 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for BlockRow { } } -impl<'a> Deref for BlockContext<'a, '_> { +impl Deref for BlockContext<'_, '_> { type Target = App; fn deref(&self) -> &Self::Target { diff --git a/crates/editor/src/display_map/fold_map.rs b/crates/editor/src/display_map/fold_map.rs index 5ea5c5a173..581c105f6b 100644 --- a/crates/editor/src/display_map/fold_map.rs +++ b/crates/editor/src/display_map/fold_map.rs @@ -132,7 +132,7 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for FoldPoint { pub(crate) struct FoldMapWriter<'a>(&'a mut FoldMap); -impl<'a> FoldMapWriter<'a> { +impl FoldMapWriter<'_> { pub(crate) fn fold( &mut self, ranges: impl IntoIterator, FoldPlaceholder)>, @@ -1121,7 +1121,7 @@ impl<'a> sum_tree::Dimension<'a, FoldSummary> for FoldRange { } } -impl<'a> sum_tree::SeekTarget<'a, FoldSummary, FoldRange> for FoldRange { +impl sum_tree::SeekTarget<'_, FoldSummary, FoldRange> for FoldRange { fn cmp(&self, other: &Self, buffer: &MultiBufferSnapshot) -> Ordering { AnchorRangeExt::cmp(&self.0, &other.0, buffer) } @@ -1144,7 +1144,7 @@ pub struct FoldRows<'a> { fold_point: FoldPoint, } -impl<'a> FoldRows<'a> { +impl FoldRows<'_> { pub(crate) fn seek(&mut self, row: u32) { let fold_point = FoldPoint::new(row, 0); self.cursor.seek(&fold_point, Bias::Left, &()); @@ -1155,7 +1155,7 @@ impl<'a> FoldRows<'a> { } } -impl<'a> Iterator for FoldRows<'a> { +impl Iterator for FoldRows<'_> { type Item = RowInfo; fn next(&mut self) -> Option { @@ -1190,7 +1190,7 @@ pub struct FoldChunks<'a> { max_output_offset: FoldOffset, } -impl<'a> FoldChunks<'a> { +impl FoldChunks<'_> { pub(crate) fn seek(&mut self, range: Range) { self.transform_cursor.seek(&range.start, Bias::Right, &()); diff --git a/crates/editor/src/display_map/inlay_map.rs b/crates/editor/src/display_map/inlay_map.rs index 154ca1447f..eaf4bdc5cf 100644 --- a/crates/editor/src/display_map/inlay_map.rs +++ b/crates/editor/src/display_map/inlay_map.rs @@ -215,7 +215,7 @@ pub struct InlayChunks<'a> { snapshot: &'a InlaySnapshot, } -impl<'a> InlayChunks<'a> { +impl InlayChunks<'_> { pub fn seek(&mut self, new_range: Range) { self.transforms.seek(&new_range.start, Bias::Right, &()); @@ -341,7 +341,7 @@ impl<'a> Iterator for InlayChunks<'a> { } } -impl<'a> InlayBufferRows<'a> { +impl InlayBufferRows<'_> { pub fn seek(&mut self, row: u32) { let inlay_point = InlayPoint::new(row, 0); self.transforms.seek(&inlay_point, Bias::Left, &()); @@ -363,7 +363,7 @@ impl<'a> InlayBufferRows<'a> { } } -impl<'a> Iterator for InlayBufferRows<'a> { +impl Iterator for InlayBufferRows<'_> { type Item = RowInfo; fn next(&mut self) -> Option { diff --git a/crates/editor/src/display_map/tab_map.rs b/crates/editor/src/display_map/tab_map.rs index 824f848aed..e2c2c96033 100644 --- a/crates/editor/src/display_map/tab_map.rs +++ b/crates/editor/src/display_map/tab_map.rs @@ -498,7 +498,7 @@ pub struct TabChunks<'a> { inside_leading_tab: bool, } -impl<'a> TabChunks<'a> { +impl TabChunks<'_> { pub(crate) fn seek(&mut self, range: Range) { let (input_start, expanded_char_column, to_next_stop) = self.snapshot.to_fold_point(range.start, Bias::Left); diff --git a/crates/editor/src/display_map/wrap_map.rs b/crates/editor/src/display_map/wrap_map.rs index 629a7df8e0..f52d5b70f3 100644 --- a/crates/editor/src/display_map/wrap_map.rs +++ b/crates/editor/src/display_map/wrap_map.rs @@ -69,7 +69,7 @@ pub struct WrapRows<'a> { transforms: Cursor<'a, Transform, (WrapPoint, TabPoint)>, } -impl<'a> WrapRows<'a> { +impl WrapRows<'_> { pub(crate) fn seek(&mut self, start_row: u32) { self.transforms .seek(&WrapPoint::new(start_row, 0), Bias::Left, &()); @@ -872,7 +872,7 @@ impl WrapSnapshot { } } -impl<'a> WrapChunks<'a> { +impl WrapChunks<'_> { pub(crate) fn seek(&mut self, rows: Range) { let output_start = WrapPoint::new(rows.start, 0); let output_end = WrapPoint::new(rows.end, 0); @@ -955,7 +955,7 @@ impl<'a> Iterator for WrapChunks<'a> { } } -impl<'a> Iterator for WrapRows<'a> { +impl Iterator for WrapRows<'_> { type Item = RowInfo; fn next(&mut self) -> Option { @@ -1120,7 +1120,7 @@ impl<'a> sum_tree::Dimension<'a, TransformSummary> for TabPoint { } } -impl<'a> sum_tree::SeekTarget<'a, TransformSummary, TransformSummary> for TabPoint { +impl sum_tree::SeekTarget<'_, TransformSummary, TransformSummary> for TabPoint { fn cmp(&self, cursor_location: &TransformSummary, _: &()) -> std::cmp::Ordering { Ord::cmp(&self.0, &cursor_location.input.lines) } diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 13d69284bd..4542361f70 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -17393,7 +17393,7 @@ impl Focusable for Editor { } impl Render for Editor { - fn render<'a>(&mut self, _: &mut Window, cx: &mut Context<'a, Self>) -> impl IntoElement { + fn render(&mut self, _: &mut Window, cx: &mut Context<'_, Self>) -> impl IntoElement { let settings = ThemeSettings::get_global(cx); let mut text_style = match self.mode { diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index dbf0bb5cd0..b464a7b310 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -177,7 +177,7 @@ impl<'de> Deserialize<'de> for ScrollbarDiagnostics { { struct Visitor; - impl<'de> serde::de::Visitor<'de> for Visitor { + impl serde::de::Visitor<'_> for Visitor { type Value = ScrollbarDiagnostics; fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index abf66ace2d..e3c5ca7dd1 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -238,7 +238,7 @@ pub fn indented_line_beginning( } /// Returns a position of the end of line. - +/// /// If `stop_at_soft_boundaries` is true, the returned position is that of the /// displayed line (e.g. it could actually be in the middle of a text line if that line is soft-wrapped). /// Otherwise it's always going to be the end of a logical line. diff --git a/crates/editor/src/selections_collection.rs b/crates/editor/src/selections_collection.rs index e22e47a4a3..7896322e1b 100644 --- a/crates/editor/src/selections_collection.rs +++ b/crates/editor/src/selections_collection.rs @@ -843,14 +843,14 @@ impl<'a> MutableSelectionsCollection<'a> { } } -impl<'a> Deref for MutableSelectionsCollection<'a> { +impl Deref for MutableSelectionsCollection<'_> { type Target = SelectionsCollection; fn deref(&self) -> &Self::Target { self.collection } } -impl<'a> DerefMut for MutableSelectionsCollection<'a> { +impl DerefMut for MutableSelectionsCollection<'_> { fn deref_mut(&mut self) -> &mut Self::Target { self.collection } diff --git a/crates/extension_api/src/extension_api.rs b/crates/extension_api/src/extension_api.rs index 06793abac1..4351761022 100644 --- a/crates/extension_api/src/extension_api.rs +++ b/crates/extension_api/src/extension_api.rs @@ -181,7 +181,10 @@ pub fn register_extension(build_extension: fn() -> Box) { } fn extension() -> &'static mut dyn Extension { - unsafe { EXTENSION.as_deref_mut().unwrap() } + #[expect(static_mut_refs)] + unsafe { + EXTENSION.as_deref_mut().unwrap() + } } static mut EXTENSION: Option> = None; diff --git a/crates/extension_host/src/headless_host.rs b/crates/extension_host/src/headless_host.rs index cd5379faf1..19f87d0d25 100644 --- a/crates/extension_host/src/headless_host.rs +++ b/crates/extension_host/src/headless_host.rs @@ -78,10 +78,9 @@ impl HeadlessExtensionStore { if e.dev { return true; } - !self - .loaded_extensions + self.loaded_extensions .get(e.id.as_str()) - .is_some_and(|loaded| loaded.as_ref() == e.version.as_str()) + .is_none_or(|loaded| loaded.as_ref() != e.version.as_str()) }) .collect(); diff --git a/crates/extension_host/src/wasm_host/wit.rs b/crates/extension_host/src/wasm_host/wit.rs index 35328f644a..f9567526ed 100644 --- a/crates/extension_host/src/wasm_host/wit.rs +++ b/crates/extension_host/src/wasm_host/wit.rs @@ -348,7 +348,7 @@ impl Extension { .call_labels_for_completions( store, &language_server_id.0, - &completions.into_iter().map(Into::into).collect::>(), + &completions.into_iter().collect::>(), ) .await? .map(|labels| { @@ -402,7 +402,7 @@ impl Extension { .call_labels_for_symbols( store, &language_server_id.0, - &symbols.into_iter().map(Into::into).collect::>(), + &symbols.into_iter().collect::>(), ) .await? .map(|labels| { diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index e1448010d2..eab204f115 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -1451,9 +1451,9 @@ impl<'a> PathComponentSlice<'a> { matches.next(); } if is_first_normal || is_last || !is_normal || contains_match { - if !longest + if longest .as_ref() - .is_some_and(|old| old.end - old.start > cur.end - cur.start) + .is_none_or(|old| old.end - old.start <= cur.end - cur.start) { longest = Some(cur); } @@ -1462,9 +1462,9 @@ impl<'a> PathComponentSlice<'a> { cur.end = i + 1; } } - if !longest + if longest .as_ref() - .is_some_and(|old| old.end - old.start > cur.end - cur.start) + .is_none_or(|old| old.end - old.start <= cur.end - cur.start) { longest = Some(cur); } diff --git a/crates/file_finder/src/new_path_prompt.rs b/crates/file_finder/src/new_path_prompt.rs index 2eea4efba9..420238493d 100644 --- a/crates/file_finder/src/new_path_prompt.rs +++ b/crates/file_finder/src/new_path_prompt.rs @@ -108,7 +108,7 @@ impl Match { fn styled_text(&self, project: &Project, window: &Window, cx: &App) -> StyledText { let mut text = "./".to_string(); let mut highlights = Vec::new(); - let mut offset = text.as_bytes().len(); + let mut offset = text.len(); let separator = '/'; let dir_indicator = "[…]"; @@ -125,7 +125,7 @@ impl Match { highlights.push((range.start + offset..range.end + offset, style)) } text.push(separator); - offset = text.as_bytes().len(); + offset = text.len(); if let Some(suffix) = &self.suffix { text.push_str(suffix); @@ -140,10 +140,10 @@ impl Match { Color::Created }; highlights.push(( - offset..offset + suffix.as_bytes().len(), + offset..offset + suffix.len(), HighlightStyle::color(color.color(cx)), )); - offset += suffix.as_bytes().len(); + offset += suffix.len(); if entry.is_some_and(|e| e.is_dir()) { text.push(separator); offset += separator.len_utf8(); @@ -165,7 +165,7 @@ impl Match { text.push_str(suffix); let existing_prefix_len = self .existing_prefix(project, cx) - .map(|prefix| prefix.to_string_lossy().as_bytes().len()) + .map(|prefix| prefix.to_string_lossy().len()) .unwrap_or(0); if existing_prefix_len > 0 { @@ -175,14 +175,14 @@ impl Match { )); } highlights.push(( - offset + existing_prefix_len..offset + suffix.as_bytes().len(), + offset + existing_prefix_len..offset + suffix.len(), HighlightStyle::color(if self.entry(project, cx).is_some() { Color::Conflict.color(cx) } else { Color::Created.color(cx) }), )); - offset += suffix.as_bytes().len(); + offset += suffix.len(); if suffix.ends_with('/') { text.push_str(dir_indicator); highlights.push(( diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index d1821754b1..9af1d92dea 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -1261,7 +1261,7 @@ impl FakeFs { self.with_git_state(dot_git, true, |state| { let branch = branch.map(Into::into); state.branches.extend(branch.clone()); - state.current_branch_name = branch.map(Into::into) + state.current_branch_name = branch }) } diff --git a/crates/fuzzy/src/paths.rs b/crates/fuzzy/src/paths.rs index bc3e399dc2..cb3d131b38 100644 --- a/crates/fuzzy/src/paths.rs +++ b/crates/fuzzy/src/paths.rs @@ -140,7 +140,7 @@ pub async fn match_path_sets<'a, Set: PathMatchCandidateSet<'a>>( let query_char_bag = CharBag::from(&lowercase_query[..]); let num_cpus = executor.num_cpus().min(path_count); - let segment_size = (path_count + num_cpus - 1) / num_cpus; + let segment_size = path_count.div_ceil(num_cpus); let mut segment_results = (0..num_cpus) .map(|_| Vec::with_capacity(max_results)) .collect::>(); diff --git a/crates/fuzzy/src/strings.rs b/crates/fuzzy/src/strings.rs index 458278739a..12888e42ed 100644 --- a/crates/fuzzy/src/strings.rs +++ b/crates/fuzzy/src/strings.rs @@ -145,7 +145,7 @@ pub async fn match_strings( let query_char_bag = CharBag::from(&lowercase_query[..]); let num_cpus = executor.num_cpus().min(candidates.len()); - let segment_size = (candidates.len() + num_cpus - 1) / num_cpus; + let segment_size = candidates.len().div_ceil(num_cpus); let mut segment_results = (0..num_cpus) .map(|_| Vec::with_capacity(max_results.min(candidates.len()))) .collect::>(); diff --git a/crates/git/src/blame.rs b/crates/git/src/blame.rs index fd87fcb7aa..fcdd427c5a 100644 --- a/crates/git/src/blame.rs +++ b/crates/git/src/blame.rs @@ -344,7 +344,7 @@ mod tests { have_json.push('\n'); let update = std::env::var("UPDATE_GOLDEN") - .map(|val| val.to_ascii_lowercase() == "true") + .map(|val| val.eq_ignore_ascii_case("true")) .unwrap_or(false); if update { diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 5d7e46bc14..0edbd62fb9 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -1019,7 +1019,7 @@ impl Borrow for RepoPath { #[derive(Debug)] pub struct RepoPathDescendants<'a>(pub &'a Path); -impl<'a> MapSeekTarget for RepoPathDescendants<'a> { +impl MapSeekTarget for RepoPathDescendants<'_> { fn cmp_cursor(&self, key: &RepoPath) -> Ordering { if key.starts_with(self.0) { Ordering::Greater diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index ba6a0fbdca..f5a45f45f2 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -553,7 +553,7 @@ impl GitPanel { } fn select_first(&mut self, _: &SelectFirst, _window: &mut Window, cx: &mut Context) { - if self.entries.first().is_some() { + if !self.entries.is_empty() { self.selected_entry = Some(1); self.scroll_to_selected_entry(cx); } diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 00b50e1e41..d5f4e606c7 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -82,7 +82,7 @@ impl AppCell { #[derive(Deref, DerefMut)] pub struct AppRef<'a>(Ref<'a, App>); -impl<'a> Drop for AppRef<'a> { +impl Drop for AppRef<'_> { fn drop(&mut self) { if option_env!("TRACK_THREAD_BORROWS").is_some() { let thread_id = std::thread::current().id(); @@ -95,7 +95,7 @@ impl<'a> Drop for AppRef<'a> { #[derive(Deref, DerefMut)] pub struct AppRefMut<'a>(RefMut<'a, App>); -impl<'a> Drop for AppRefMut<'a> { +impl Drop for AppRefMut<'_> { fn drop(&mut self) { if option_env!("TRACK_THREAD_BORROWS").is_some() { let thread_id = std::thread::current().id(); diff --git a/crates/gpui/src/app/context.rs b/crates/gpui/src/app/context.rs index 31f17cd9c8..1f813f463f 100644 --- a/crates/gpui/src/app/context.rs +++ b/crates/gpui/src/app/context.rs @@ -649,7 +649,7 @@ impl<'a, T: 'static> Context<'a, T> { } } -impl<'a, T> Context<'a, T> { +impl Context<'_, T> { /// Emit an event of the specified type, which can be handled by other entities that have subscribed via `subscribe` methods on their respective contexts. pub fn emit(&mut self, event: Evt) where @@ -664,7 +664,7 @@ impl<'a, T> Context<'a, T> { } } -impl<'a, T> AppContext for Context<'a, T> { +impl AppContext for Context<'_, T> { type Result = U; fn new( diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rs index 69037f9eef..7b53506ae4 100644 --- a/crates/gpui/src/app/entity_map.rs +++ b/crates/gpui/src/app/entity_map.rs @@ -191,7 +191,7 @@ pub(crate) struct Lease<'a, T> { entity_type: PhantomData, } -impl<'a, T: 'static> core::ops::Deref for Lease<'a, T> { +impl core::ops::Deref for Lease<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -199,13 +199,13 @@ impl<'a, T: 'static> core::ops::Deref for Lease<'a, T> { } } -impl<'a, T: 'static> core::ops::DerefMut for Lease<'a, T> { +impl core::ops::DerefMut for Lease<'_, T> { fn deref_mut(&mut self) -> &mut Self::Target { self.entity.as_mut().unwrap().downcast_mut().unwrap() } } -impl<'a, T> Drop for Lease<'a, T> { +impl Drop for Lease<'_, T> { fn drop(&mut self) { if self.entity.is_some() && !panicking() { panic!("Leases must be ended with EntityMap::end_lease") diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs index 149d924b6f..ec9bfa451b 100644 --- a/crates/gpui/src/color.rs +++ b/crates/gpui/src/color.rs @@ -82,7 +82,7 @@ impl From for u32 { struct RgbaVisitor; -impl<'de> Visitor<'de> for RgbaVisitor { +impl Visitor<'_> for RgbaVisitor { type Value = Rgba; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { @@ -180,7 +180,7 @@ impl TryFrom<&'_ str> for Rgba { /// Duplicates a given hex digit. /// E.g., `0xf` -> `0xff`. const fn duplicate(value: u8) -> u8 { - value << 4 | value + (value << 4) | value } (duplicate(r), duplicate(g), duplicate(b), duplicate(a)) diff --git a/crates/gpui/src/elements/list.rs b/crates/gpui/src/elements/list.rs index 10d64d7f75..36b6bc5a10 100644 --- a/crates/gpui/src/elements/list.rs +++ b/crates/gpui/src/elements/list.rs @@ -946,13 +946,13 @@ impl<'a> sum_tree::Dimension<'a, ListItemSummary> for Height { } } -impl<'a> sum_tree::SeekTarget<'a, ListItemSummary, ListItemSummary> for Count { +impl sum_tree::SeekTarget<'_, ListItemSummary, ListItemSummary> for Count { fn cmp(&self, other: &ListItemSummary, _: &()) -> std::cmp::Ordering { self.0.partial_cmp(&other.count).unwrap() } } -impl<'a> sum_tree::SeekTarget<'a, ListItemSummary, ListItemSummary> for Height { +impl sum_tree::SeekTarget<'_, ListItemSummary, ListItemSummary> for Height { fn cmp(&self, other: &ListItemSummary, _: &()) -> std::cmp::Ordering { self.0.partial_cmp(&other.height).unwrap() } diff --git a/crates/gpui/src/executor.rs b/crates/gpui/src/executor.rs index 8b3e5c2359..4f78f97ad3 100644 --- a/crates/gpui/src/executor.rs +++ b/crates/gpui/src/executor.rs @@ -587,7 +587,7 @@ impl<'a> Scope<'a> { } } -impl<'a> Drop for Scope<'a> { +impl Drop for Scope<'_> { fn drop(&mut self) { self.tx.take().unwrap(); diff --git a/crates/gpui/src/platform/mac/attributed_string.rs b/crates/gpui/src/platform/mac/attributed_string.rs index 3f1185bc14..5f313ac699 100644 --- a/crates/gpui/src/platform/mac/attributed_string.rs +++ b/crates/gpui/src/platform/mac/attributed_string.rs @@ -5,7 +5,6 @@ use objc::{class, msg_send, sel, sel_impl}; /// The `cocoa` crate does not define NSAttributedString (and related Cocoa classes), /// which are needed for copying rich text (that is, text intermingled with images) /// to the clipboard. This adds access to those APIs. - #[allow(non_snake_case)] pub trait NSAttributedString: Sized { unsafe fn alloc(_: Self) -> id { diff --git a/crates/gpui/src/platform/mac/dispatcher.rs b/crates/gpui/src/platform/mac/dispatcher.rs index 776ca4fe04..13b2742d23 100644 --- a/crates/gpui/src/platform/mac/dispatcher.rs +++ b/crates/gpui/src/platform/mac/dispatcher.rs @@ -26,7 +26,7 @@ pub(crate) mod dispatch_sys { use dispatch_sys::*; pub(crate) fn dispatch_get_main_queue() -> dispatch_queue_t { - unsafe { addr_of!(_dispatch_main_q) as *const _ as dispatch_queue_t } + addr_of!(_dispatch_main_q) as *const _ as dispatch_queue_t } pub(crate) struct MacDispatcher { diff --git a/crates/gpui/src/platform/windows/window.rs b/crates/gpui/src/platform/windows/window.rs index b3813b9a24..d5972b3caa 100644 --- a/crates/gpui/src/platform/windows/window.rs +++ b/crates/gpui/src/platform/windows/window.rs @@ -1221,10 +1221,10 @@ fn set_window_composition_attribute(hwnd: HWND, color: Option, state: u32 unsafe { type SetWindowCompositionAttributeType = unsafe extern "system" fn(HWND, *mut WINDOWCOMPOSITIONATTRIBDATA) -> BOOL; - let module_name = PCSTR::from_raw("user32.dll\0".as_ptr()); + let module_name = PCSTR::from_raw(c"user32.dll".as_ptr() as *const u8); let user32 = GetModuleHandleA(module_name); if user32.is_ok() { - let func_name = PCSTR::from_raw("SetWindowCompositionAttribute\0".as_ptr()); + 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)); let mut color = color.unwrap_or_default(); @@ -1238,7 +1238,7 @@ fn set_window_composition_attribute(hwnd: HWND, color: Option, state: u32 gradient_color: (color.0 as u32) | ((color.1 as u32) << 8) | ((color.2 as u32) << 16) - | (color.3 as u32) << 24, + | ((color.3 as u32) << 24), animation_id: 0, }; let mut data = WINDOWCOMPOSITIONATTRIBDATA { diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rs index 6b9256e6e7..2ab3a21f7d 100644 --- a/crates/gpui/src/text_system.rs +++ b/crates/gpui/src/text_system.rs @@ -670,6 +670,15 @@ pub struct TextRun { pub strikethrough: Option, } +#[cfg(all(target_os = "macos", test))] +impl TextRun { + fn with_len(&self, len: usize) -> Self { + let mut this = self.clone(); + this.len = len; + this + } +} + /// An identifier for a specific glyph, as returned by [`TextSystem::layout_line`]. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] #[repr(C)] diff --git a/crates/gpui/src/text_system/line_layout.rs b/crates/gpui/src/text_system/line_layout.rs index 360042d98e..200ea1be51 100644 --- a/crates/gpui/src/text_system/line_layout.rs +++ b/crates/gpui/src/text_system/line_layout.rs @@ -601,15 +601,15 @@ struct CacheKeyRef<'a> { wrap_width: Option, } -impl<'a> PartialEq for (dyn AsCacheKeyRef + 'a) { +impl PartialEq for (dyn AsCacheKeyRef + '_) { fn eq(&self, other: &dyn AsCacheKeyRef) -> bool { self.as_cache_key_ref() == other.as_cache_key_ref() } } -impl<'a> Eq for (dyn AsCacheKeyRef + 'a) {} +impl Eq for (dyn AsCacheKeyRef + '_) {} -impl<'a> Hash for (dyn AsCacheKeyRef + 'a) { +impl Hash for (dyn AsCacheKeyRef + '_) { fn hash(&self, state: &mut H) { self.as_cache_key_ref().hash(state) } @@ -644,7 +644,7 @@ impl<'a> Borrow for Arc { } } -impl<'a> AsCacheKeyRef for CacheKeyRef<'a> { +impl AsCacheKeyRef for CacheKeyRef<'_> { fn as_cache_key_ref(&self) -> CacheKeyRef { *self } diff --git a/crates/gpui/src/text_system/line_wrapper.rs b/crates/gpui/src/text_system/line_wrapper.rs index 08e9a69f61..b7a783a728 100644 --- a/crates/gpui/src/text_system/line_wrapper.rs +++ b/crates/gpui/src/text_system/line_wrapper.rs @@ -543,14 +543,6 @@ mod tests { background_color: None, }; - impl TextRun { - fn with_len(&self, len: usize) -> Self { - let mut this = self.clone(); - this.len = len; - this - } - } - let text = "aa bbb cccc ddddd eeee".into(); let lines = text_system .shape_text( diff --git a/crates/gpui/src/util.rs b/crates/gpui/src/util.rs index 01ef384e7c..7e86136c57 100644 --- a/crates/gpui/src/util.rs +++ b/crates/gpui/src/util.rs @@ -72,7 +72,7 @@ where pub struct CwdBacktrace<'a>(pub &'a backtrace::Backtrace); #[cfg(any(test, feature = "test-support"))] -impl<'a> std::fmt::Debug for CwdBacktrace<'a> { +impl std::fmt::Debug for CwdBacktrace<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { use backtrace::{BacktraceFmt, BytesOrWideString}; diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index ad6ace22cc..6650b9440c 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -3689,8 +3689,6 @@ impl Window { dispatch_tree.bindings_for_action(action, &[context]) } - /// Returns a generic event listener that invokes the given listener with the view and context associated with the given view handle. - /// Returns a generic event listener that invokes the given listener with the view and context associated with the given view handle. pub fn listener_for( &self, diff --git a/crates/http_client/src/http_client.rs b/crates/http_client/src/http_client.rs index 9d24951682..6f19b16860 100644 --- a/crates/http_client/src/http_client.rs +++ b/crates/http_client/src/http_client.rs @@ -79,7 +79,7 @@ pub trait HttpClient: 'static + Send + Sync { .body(body); match request { - Ok(request) => Box::pin(async move { self.send(request).await.map_err(Into::into) }), + Ok(request) => Box::pin(async move { self.send(request).await }), Err(e) => Box::pin(async move { Err(e.into()) }), } } @@ -96,7 +96,7 @@ pub trait HttpClient: 'static + Send + Sync { .body(body); match request { - Ok(request) => Box::pin(async move { self.send(request).await.map_err(Into::into) }), + Ok(request) => Box::pin(async move { self.send(request).await }), Err(e) => Box::pin(async move { Err(e.into()) }), } } diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 5d91b617e0..aaf1014d05 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -509,7 +509,7 @@ impl fmt::Debug for ChunkRenderer { } } -impl<'a, 'b> Deref for ChunkRendererContext<'a, 'b> { +impl Deref for ChunkRendererContext<'_, '_> { type Target = App; fn deref(&self) -> &Self::Target { @@ -517,7 +517,7 @@ impl<'a, 'b> Deref for ChunkRendererContext<'a, 'b> { } } -impl<'a, 'b> DerefMut for ChunkRendererContext<'a, 'b> { +impl DerefMut for ChunkRendererContext<'_, '_> { fn deref_mut(&mut self) -> &mut Self::Target { self.context } @@ -4137,7 +4137,7 @@ impl Deref for BufferSnapshot { } } -unsafe impl<'a> Send for BufferChunks<'a> {} +unsafe impl Send for BufferChunks<'_> {} impl<'a> BufferChunks<'a> { pub(crate) fn new( diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index e1dfe0eab1..61fcf0fa94 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -836,7 +836,7 @@ impl SyntaxSnapshot { } #[cfg(test)] - pub fn layers<'a>(&'a self, buffer: &'a BufferSnapshot) -> Vec { + pub fn layers<'a>(&'a self, buffer: &'a BufferSnapshot) -> Vec> { self.layers_for_range(0..buffer.len(), buffer, true) .collect() } @@ -1142,7 +1142,7 @@ impl<'a> SyntaxMapMatches<'a> { } } -impl<'a> SyntaxMapCapturesLayer<'a> { +impl SyntaxMapCapturesLayer<'_> { fn advance(&mut self) { self.next_capture = self.captures.next().map(|(mat, ix)| mat.captures[*ix]); } @@ -1157,7 +1157,7 @@ impl<'a> SyntaxMapCapturesLayer<'a> { } } -impl<'a> SyntaxMapMatchesLayer<'a> { +impl SyntaxMapMatchesLayer<'_> { fn advance(&mut self) { if let Some(mat) = self.matches.next() { self.next_captures.clear(); @@ -1740,7 +1740,7 @@ impl sum_tree::Summary for SyntaxLayerSummary { } } -impl<'a> SeekTarget<'a, SyntaxLayerSummary, SyntaxLayerSummary> for SyntaxLayerPosition { +impl SeekTarget<'_, SyntaxLayerSummary, SyntaxLayerSummary> for SyntaxLayerPosition { fn cmp(&self, cursor_location: &SyntaxLayerSummary, buffer: &BufferSnapshot) -> Ordering { Ord::cmp(&self.depth, &cursor_location.max_depth) .then_with(|| { @@ -1758,16 +1758,14 @@ impl<'a> SeekTarget<'a, SyntaxLayerSummary, SyntaxLayerSummary> for SyntaxLayerP } } -impl<'a> SeekTarget<'a, SyntaxLayerSummary, SyntaxLayerSummary> for ChangeStartPosition { +impl SeekTarget<'_, SyntaxLayerSummary, SyntaxLayerSummary> for ChangeStartPosition { fn cmp(&self, cursor_location: &SyntaxLayerSummary, text: &BufferSnapshot) -> Ordering { Ord::cmp(&self.depth, &cursor_location.max_depth) .then_with(|| self.position.cmp(&cursor_location.range.end, text)) } } -impl<'a> SeekTarget<'a, SyntaxLayerSummary, SyntaxLayerSummary> - for SyntaxLayerPositionBeforeChange -{ +impl SeekTarget<'_, SyntaxLayerSummary, SyntaxLayerSummary> for SyntaxLayerPositionBeforeChange { fn cmp(&self, cursor_location: &SyntaxLayerSummary, buffer: &BufferSnapshot) -> Ordering { if self.change.cmp(cursor_location, buffer).is_le() { Ordering::Less @@ -1869,7 +1867,7 @@ struct LogPoint(Point); struct LogAnchorRange<'a>(&'a Range, &'a text::BufferSnapshot); struct LogChangedRegions<'a>(&'a ChangeRegionSet, &'a text::BufferSnapshot); -impl<'a> fmt::Debug for LogIncludedRanges<'a> { +impl fmt::Debug for LogIncludedRanges<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries(self.0.iter().map(|range| { @@ -1881,14 +1879,14 @@ impl<'a> fmt::Debug for LogIncludedRanges<'a> { } } -impl<'a> fmt::Debug for LogAnchorRange<'a> { +impl fmt::Debug for LogAnchorRange<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let range = self.0.to_point(self.1); (LogPoint(range.start)..LogPoint(range.end)).fmt(f) } } -impl<'a> fmt::Debug for LogChangedRegions<'a> { +impl fmt::Debug for LogChangedRegions<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list() .entries( diff --git a/crates/language_extension/src/extension_lsp_adapter.rs b/crates/language_extension/src/extension_lsp_adapter.rs index 26b53a11c1..28ccdd04c3 100644 --- a/crates/language_extension/src/extension_lsp_adapter.rs +++ b/crates/language_extension/src/extension_lsp_adapter.rs @@ -305,13 +305,7 @@ impl LspAdapter for ExtensionLspAdapter { .labels_for_symbols(self.language_server_id.clone(), symbols) .await?; - Ok(labels_from_extension( - labels - .into_iter() - .map(|label| label.map(Into::into)) - .collect(), - language, - )) + Ok(labels_from_extension(labels, language)) } } diff --git a/crates/language_model/src/model/cloud_model.rs b/crates/language_model/src/model/cloud_model.rs index 3d3741895b..44e2199a84 100644 --- a/crates/language_model/src/model/cloud_model.rs +++ b/crates/language_model/src/model/cloud_model.rs @@ -153,8 +153,8 @@ impl LlmApiToken { Self::fetch(self.0.write().await, client).await } - async fn fetch<'a>( - mut lock: RwLockWriteGuard<'a, Option>, + async fn fetch( + mut lock: RwLockWriteGuard<'_, Option>, client: &Arc, ) -> Result { let response = client.request(proto::GetLlmToken {}).await?; diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index c28a528418..26e1ae1467 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -684,7 +684,7 @@ impl<'a> EnvironmentApi<'a> { } } -impl<'a> pet_core::os_environment::Environment for EnvironmentApi<'a> { +impl pet_core::os_environment::Environment for EnvironmentApi<'_> { fn get_user_home(&self) -> Option { self.user_home() } diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index 5ed4dcdcfd..9262b5597d 100644 --- a/crates/multi_buffer/src/multi_buffer.rs +++ b/crates/multi_buffer/src/multi_buffer.rs @@ -6896,7 +6896,7 @@ impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for ExcerptOffset { } } -impl<'a> sum_tree::SeekTarget<'a, ExcerptSummary, ExcerptSummary> for ExcerptOffset { +impl sum_tree::SeekTarget<'_, ExcerptSummary, ExcerptSummary> for ExcerptOffset { fn cmp(&self, cursor_location: &ExcerptSummary, _: &()) -> cmp::Ordering { Ord::cmp(&self.value, &cursor_location.text.len) } @@ -6908,7 +6908,7 @@ impl<'a> sum_tree::SeekTarget<'a, ExcerptSummary, Option<&'a Locator>> for Locat } } -impl<'a> sum_tree::SeekTarget<'a, ExcerptSummary, ExcerptSummary> for Locator { +impl sum_tree::SeekTarget<'_, ExcerptSummary, ExcerptSummary> for Locator { fn cmp(&self, cursor_location: &ExcerptSummary, _: &()) -> cmp::Ordering { Ord::cmp(self, &cursor_location.excerpt_locator) } @@ -6982,16 +6982,16 @@ impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for ExcerptPoint { } } -impl<'a, D: TextDimension + Ord> - sum_tree::SeekTarget<'a, DiffTransformSummary, DiffTransformSummary> for ExcerptDimension +impl sum_tree::SeekTarget<'_, DiffTransformSummary, DiffTransformSummary> + for ExcerptDimension { fn cmp(&self, cursor_location: &DiffTransformSummary, _: &()) -> cmp::Ordering { Ord::cmp(&self.0, &D::from_text_summary(&cursor_location.input)) } } -impl<'a, D: TextDimension + Ord> - sum_tree::SeekTarget<'a, DiffTransformSummary, (OutputDimension, ExcerptDimension)> +impl + sum_tree::SeekTarget<'_, DiffTransformSummary, (OutputDimension, ExcerptDimension)> for ExcerptDimension { fn cmp( @@ -7053,14 +7053,14 @@ impl<'a> sum_tree::Dimension<'a, DiffTransformSummary> for Point { } } -impl<'a> MultiBufferRows<'a> { +impl MultiBufferRows<'_> { pub fn seek(&mut self, MultiBufferRow(row): MultiBufferRow) { self.point = Point::new(row, 0); self.cursor.seek(&self.point); } } -impl<'a> Iterator for MultiBufferRows<'a> { +impl Iterator for MultiBufferRows<'_> { type Item = RowInfo; fn next(&mut self) -> Option { @@ -7304,7 +7304,7 @@ impl<'a> Iterator for MultiBufferChunks<'a> { } } -impl<'a> MultiBufferBytes<'a> { +impl MultiBufferBytes<'_> { fn consume(&mut self, len: usize) { self.range.start += len; self.chunk = &self.chunk[len..]; @@ -7351,7 +7351,7 @@ impl<'a> Iterator for MultiBufferBytes<'a> { } } -impl<'a> io::Read for MultiBufferBytes<'a> { +impl io::Read for MultiBufferBytes<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { let len = cmp::min(buf.len(), self.chunk.len()); buf[..len].copy_from_slice(&self.chunk[..len]); @@ -7362,7 +7362,7 @@ impl<'a> io::Read for MultiBufferBytes<'a> { } } -impl<'a> io::Read for ReversedMultiBufferBytes<'a> { +impl io::Read for ReversedMultiBufferBytes<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { let len = cmp::min(buf.len(), self.chunk.len()); buf[..len].copy_from_slice(&self.chunk[..len]); diff --git a/crates/notifications/src/notification_store.rs b/crates/notifications/src/notification_store.rs index d8037a02f9..ae6b761b5f 100644 --- a/crates/notifications/src/notification_store.rs +++ b/crates/notifications/src/notification_store.rs @@ -469,7 +469,7 @@ impl sum_tree::Summary for NotificationSummary { } } -impl<'a> sum_tree::Dimension<'a, NotificationSummary> for NotificationId { +impl sum_tree::Dimension<'_, NotificationSummary> for NotificationId { fn zero(_cx: &()) -> Self { Default::default() } @@ -480,7 +480,7 @@ impl<'a> sum_tree::Dimension<'a, NotificationSummary> for NotificationId { } } -impl<'a> sum_tree::Dimension<'a, NotificationSummary> for Count { +impl sum_tree::Dimension<'_, NotificationSummary> for Count { fn zero(_cx: &()) -> Self { Default::default() } diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index 7bb76a06d6..d8a71a534d 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -1632,9 +1632,9 @@ impl BufferStore { // file in the Cargo registry (presumably opened with go-to-definition // from a normal Rust file). If so, we can put together a permalink // using crate metadata. - if !buffer + if buffer .language() - .is_some_and(|lang| lang.name() == "Rust".into()) + .is_none_or(|lang| lang.name() != "Rust".into()) { return Task::ready(Err(anyhow!("no permalink available"))); } diff --git a/crates/rope/src/chunk.rs b/crates/rope/src/chunk.rs index b6ddc69c00..cf27f8a100 100644 --- a/crates/rope/src/chunk.rs +++ b/crates/rope/src/chunk.rs @@ -78,7 +78,7 @@ pub struct ChunkSlice<'a> { text: &'a str, } -impl<'a> Into for ChunkSlice<'a> { +impl Into for ChunkSlice<'_> { fn into(self) -> Chunk { Chunk { chars: self.chars, diff --git a/crates/rope/src/point.rs b/crates/rope/src/point.rs index a9d2e3a174..a5a0a442c3 100644 --- a/crates/rope/src/point.rs +++ b/crates/rope/src/point.rs @@ -124,8 +124,8 @@ impl PartialOrd for Point { impl Ord for Point { #[cfg(target_pointer_width = "64")] fn cmp(&self, other: &Point) -> Ordering { - let a = (self.row as usize) << 32 | self.column as usize; - let b = (other.row as usize) << 32 | other.column as usize; + let a = ((self.row as usize) << 32) | self.column as usize; + let b = ((other.row as usize) << 32) | other.column as usize; a.cmp(&b) } diff --git a/crates/rope/src/point_utf16.rs b/crates/rope/src/point_utf16.rs index 7b76ee3776..096c2defa4 100644 --- a/crates/rope/src/point_utf16.rs +++ b/crates/rope/src/point_utf16.rs @@ -104,8 +104,8 @@ impl PartialOrd for PointUtf16 { impl Ord for PointUtf16 { #[cfg(target_pointer_width = "64")] fn cmp(&self, other: &PointUtf16) -> Ordering { - let a = (self.row as usize) << 32 | self.column as usize; - let b = (other.row as usize) << 32 | other.column as usize; + let a = ((self.row as usize) << 32) | self.column as usize; + let b = ((other.row as usize) << 32) | other.column as usize; a.cmp(&b) } diff --git a/crates/rope/src/rope.rs b/crates/rope/src/rope.rs index 919b3ea809..5adb5c886c 100644 --- a/crates/rope/src/rope.rs +++ b/crates/rope/src/rope.rs @@ -145,7 +145,7 @@ impl Rope { // We also round up the capacity up by one, for a good measure; we *really* don't want to realloc here, as we assume that the # of characters // we're working with there is large. - let capacity = (text.len() + MIN_CHUNK_SIZE - 1) / MIN_CHUNK_SIZE; + let capacity = text.len().div_ceil(MIN_CHUNK_SIZE); let mut new_chunks = Vec::with_capacity(capacity); while !text.is_empty() { @@ -855,7 +855,7 @@ impl<'a> Iterator for Bytes<'a> { } } -impl<'a> io::Read for Bytes<'a> { +impl io::Read for Bytes<'_> { fn read(&mut self, buf: &mut [u8]) -> io::Result { if let Some(chunk) = self.peek() { let len = cmp::min(buf.len(), chunk.len()); @@ -889,7 +889,7 @@ pub struct Lines<'a> { reversed: bool, } -impl<'a> Lines<'a> { +impl Lines<'_> { pub fn next(&mut self) -> Option<&str> { if self.done { return None; diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 628eba1703..75f31e6819 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -1909,7 +1909,7 @@ mod tests { .unindent(); let expected_query_matches_count = buffer_text .chars() - .filter(|c| c.to_ascii_lowercase() == 'a') + .filter(|c| c.eq_ignore_ascii_case(&'a')) .count(); assert!( expected_query_matches_count > 1, diff --git a/crates/settings/src/json_schema.rs b/crates/settings/src/json_schema.rs index 91249d5b0b..5fd340fffa 100644 --- a/crates/settings/src/json_schema.rs +++ b/crates/settings/src/json_schema.rs @@ -8,7 +8,7 @@ pub struct SettingsJsonSchemaParams<'a> { pub font_names: &'a [String], } -impl<'a> SettingsJsonSchemaParams<'a> { +impl SettingsJsonSchemaParams<'_> { pub fn font_family_schema(&self) -> Schema { let available_fonts: Vec<_> = self.font_names.iter().cloned().map(Value::String).collect(); diff --git a/crates/sqlez/src/statement.rs b/crates/sqlez/src/statement.rs index f1d89919ec..75be504e7b 100644 --- a/crates/sqlez/src/statement.rs +++ b/crates/sqlez/src/statement.rs @@ -377,7 +377,7 @@ impl<'a> Statement<'a> { } } -impl<'a> Drop for Statement<'a> { +impl Drop for Statement<'_> { fn drop(&mut self) { unsafe { for raw_statement in self.raw_statements.iter() { diff --git a/crates/sum_tree/src/cursor.rs b/crates/sum_tree/src/cursor.rs index b079365b8e..3257976df4 100644 --- a/crates/sum_tree/src/cursor.rs +++ b/crates/sum_tree/src/cursor.rs @@ -9,7 +9,7 @@ struct StackEntry<'a, T: Item, D> { position: D, } -impl<'a, T: Item + fmt::Debug, D: fmt::Debug> fmt::Debug for StackEntry<'a, T, D> { +impl fmt::Debug for StackEntry<'_, T, D> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("StackEntry") .field("index", &self.index) @@ -27,7 +27,7 @@ pub struct Cursor<'a, T: Item, D> { at_end: bool, } -impl<'a, T: Item + fmt::Debug, D: fmt::Debug> fmt::Debug for Cursor<'a, T, D> +impl fmt::Debug for Cursor<'_, T, D> where T::Summary: fmt::Debug, { @@ -742,14 +742,14 @@ struct SliceSeekAggregate { struct SummarySeekAggregate(D); -impl<'a, T: Item> SeekAggregate<'a, T> for () { +impl SeekAggregate<'_, T> for () { fn begin_leaf(&mut self) {} fn end_leaf(&mut self, _: &::Context) {} fn push_item(&mut self, _: &T, _: &T::Summary, _: &::Context) {} fn push_tree(&mut self, _: &SumTree, _: &T::Summary, _: &::Context) {} } -impl<'a, T: Item> SeekAggregate<'a, T> for SliceSeekAggregate { +impl SeekAggregate<'_, T> for SliceSeekAggregate { fn begin_leaf(&mut self) {} fn end_leaf(&mut self, cx: &::Context) { self.tree.append( diff --git a/crates/sum_tree/src/sum_tree.rs b/crates/sum_tree/src/sum_tree.rs index 58ca7dbfa9..237e314c14 100644 --- a/crates/sum_tree/src/sum_tree.rs +++ b/crates/sum_tree/src/sum_tree.rs @@ -1468,7 +1468,7 @@ mod tests { } } - impl<'a> Dimension<'a, IntegersSummary> for u8 { + impl Dimension<'_, IntegersSummary> for u8 { fn zero(_cx: &()) -> Self { Default::default() } @@ -1478,7 +1478,7 @@ mod tests { } } - impl<'a> Dimension<'a, IntegersSummary> for Count { + impl Dimension<'_, IntegersSummary> for Count { fn zero(_cx: &()) -> Self { Default::default() } @@ -1488,13 +1488,13 @@ mod tests { } } - impl<'a> SeekTarget<'a, IntegersSummary, IntegersSummary> for Count { + impl SeekTarget<'_, IntegersSummary, IntegersSummary> for Count { fn cmp(&self, cursor_location: &IntegersSummary, _: &()) -> Ordering { self.0.cmp(&cursor_location.count) } } - impl<'a> Dimension<'a, IntegersSummary> for Sum { + impl Dimension<'_, IntegersSummary> for Sum { fn zero(_cx: &()) -> Self { Default::default() } diff --git a/crates/sum_tree/src/tree_map.rs b/crates/sum_tree/src/tree_map.rs index 09274c37c2..28d4f08771 100644 --- a/crates/sum_tree/src/tree_map.rs +++ b/crates/sum_tree/src/tree_map.rs @@ -26,7 +26,7 @@ impl Default for MapKey { #[derive(Clone, Debug)] pub struct MapKeyRef<'a, K>(Option<&'a K>); -impl<'a, K> Default for MapKeyRef<'a, K> { +impl Default for MapKeyRef<'_, K> { fn default() -> Self { Self(None) } diff --git a/crates/terminal/src/pty_info.rs b/crates/terminal/src/pty_info.rs index 6478cb4ad8..80627b4673 100644 --- a/crates/terminal/src/pty_info.rs +++ b/crates/terminal/src/pty_info.rs @@ -123,10 +123,7 @@ impl PtyProcessInfo { fn load(&mut self) -> Option { let process = self.refresh()?; - let cwd = process - .cwd() - .take() - .map_or(PathBuf::new(), |p| p.to_owned()); + let cwd = process.cwd().map_or(PathBuf::new(), |p| p.to_owned()); let info = ProcessInfo { name: process.name().to_str()?.to_owned(), diff --git a/crates/text/src/operation_queue.rs b/crates/text/src/operation_queue.rs index 52b534a41b..38864e66c8 100644 --- a/crates/text/src/operation_queue.rs +++ b/crates/text/src/operation_queue.rs @@ -81,7 +81,7 @@ impl Summary for OperationSummary { } } -impl<'a> Add<&'a Self> for OperationSummary { +impl Add<&Self> for OperationSummary { type Output = Self; fn add(self, other: &Self) -> Self { @@ -93,7 +93,7 @@ impl<'a> Add<&'a Self> for OperationSummary { } } -impl<'a> Dimension<'a, OperationSummary> for OperationKey { +impl Dimension<'_, OperationSummary> for OperationKey { fn zero(_cx: &()) -> Self { Default::default() } diff --git a/crates/text/src/text.rs b/crates/text/src/text.rs index a0d0f8df17..612e92c6a8 100644 --- a/crates/text/src/text.rs +++ b/crates/text/src/text.rs @@ -2533,7 +2533,7 @@ impl<'a> RopeBuilder<'a> { } } -impl<'a, D: TextDimension + Ord, F: FnMut(&FragmentSummary) -> bool> Iterator for Edits<'a, D, F> { +impl bool> Iterator for Edits<'_, D, F> { type Item = (Edit, Range); fn next(&mut self) -> Option { @@ -2801,7 +2801,7 @@ impl ops::Sub for FullOffset { } } -impl<'a> sum_tree::Dimension<'a, FragmentSummary> for usize { +impl sum_tree::Dimension<'_, FragmentSummary> for usize { fn zero(_: &Option) -> Self { Default::default() } @@ -2811,7 +2811,7 @@ impl<'a> sum_tree::Dimension<'a, FragmentSummary> for usize { } } -impl<'a> sum_tree::Dimension<'a, FragmentSummary> for FullOffset { +impl sum_tree::Dimension<'_, FragmentSummary> for FullOffset { fn zero(_: &Option) -> Self { Default::default() } @@ -2831,7 +2831,7 @@ impl<'a> sum_tree::Dimension<'a, FragmentSummary> for Option<&'a Locator> { } } -impl<'a> sum_tree::SeekTarget<'a, FragmentSummary, FragmentTextSummary> for usize { +impl sum_tree::SeekTarget<'_, FragmentSummary, FragmentTextSummary> for usize { fn cmp( &self, cursor_location: &FragmentTextSummary, @@ -2880,7 +2880,7 @@ impl<'a> sum_tree::Dimension<'a, FragmentSummary> for VersionedFullOffset { } } -impl<'a> sum_tree::SeekTarget<'a, FragmentSummary, Self> for VersionedFullOffset { +impl sum_tree::SeekTarget<'_, FragmentSummary, Self> for VersionedFullOffset { fn cmp(&self, cursor_position: &Self, _: &Option) -> cmp::Ordering { match (self, cursor_position) { (Self::Offset(a), Self::Offset(b)) => Ord::cmp(a, b), @@ -2952,7 +2952,7 @@ impl ToOffset for Anchor { } } -impl<'a, T: ToOffset> ToOffset for &'a T { +impl ToOffset for &T { fn to_offset(&self, content: &BufferSnapshot) -> usize { (*self).to_offset(content) } diff --git a/crates/util/src/arc_cow.rs b/crates/util/src/arc_cow.rs index 06a2fa9cd0..41040671bc 100644 --- a/crates/util/src/arc_cow.rs +++ b/crates/util/src/arc_cow.rs @@ -11,7 +11,7 @@ pub enum ArcCow<'a, T: ?Sized> { Owned(Arc), } -impl<'a, T: ?Sized + PartialEq> PartialEq for ArcCow<'a, T> { +impl PartialEq for ArcCow<'_, T> { fn eq(&self, other: &Self) -> bool { let a = self.as_ref(); let b = other.as_ref(); @@ -19,21 +19,21 @@ impl<'a, T: ?Sized + PartialEq> PartialEq for ArcCow<'a, T> { } } -impl<'a, T: ?Sized + PartialOrd> PartialOrd for ArcCow<'a, T> { +impl PartialOrd for ArcCow<'_, T> { fn partial_cmp(&self, other: &Self) -> Option { self.as_ref().partial_cmp(other.as_ref()) } } -impl<'a, T: ?Sized + Ord> Ord for ArcCow<'a, T> { +impl Ord for ArcCow<'_, T> { fn cmp(&self, other: &Self) -> Ordering { self.as_ref().cmp(other.as_ref()) } } -impl<'a, T: ?Sized + Eq> Eq for ArcCow<'a, T> {} +impl Eq for ArcCow<'_, T> {} -impl<'a, T: ?Sized + Hash> Hash for ArcCow<'a, T> { +impl Hash for ArcCow<'_, T> { fn hash(&self, state: &mut H) { match self { Self::Borrowed(borrowed) => Hash::hash(borrowed, state), @@ -42,7 +42,7 @@ impl<'a, T: ?Sized + Hash> Hash for ArcCow<'a, T> { } } -impl<'a, T: ?Sized> Clone for ArcCow<'a, T> { +impl Clone for ArcCow<'_, T> { fn clone(&self) -> Self { match self { Self::Borrowed(borrowed) => Self::Borrowed(borrowed), @@ -102,7 +102,7 @@ impl<'a> From<&'a str> for ArcCow<'a, [u8]> { } } -impl<'a, T: ?Sized + ToOwned> std::borrow::Borrow for ArcCow<'a, T> { +impl std::borrow::Borrow for ArcCow<'_, T> { fn borrow(&self) -> &T { match self { ArcCow::Borrowed(borrowed) => borrowed, @@ -131,7 +131,7 @@ impl AsRef for ArcCow<'_, T> { } } -impl<'a, T: ?Sized + Debug> Debug for ArcCow<'a, T> { +impl Debug for ArcCow<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { ArcCow::Borrowed(borrowed) => Debug::fmt(borrowed, f), diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs index 79abd1065b..c8ce5ade0c 100644 --- a/crates/util/src/util.rs +++ b/crates/util/src/util.rs @@ -781,7 +781,7 @@ impl Ord for NumericPrefixWithSuffix<'_> { } } -impl<'a> PartialOrd for NumericPrefixWithSuffix<'a> { +impl PartialOrd for NumericPrefixWithSuffix<'_> { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 49e75c56b5..d3614cfb64 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -1498,9 +1498,7 @@ impl LocalWorktree { }; scanner - .run(Box::pin( - events.map(|events| events.into_iter().map(Into::into).collect()), - )) + .run(Box::pin(events.map(|events| events.into_iter().collect()))) .await; } }); @@ -3630,7 +3628,7 @@ impl fmt::Debug for Snapshot { struct EntriesById<'a>(&'a SumTree); struct EntriesByPath<'a>(&'a SumTree); - impl<'a> fmt::Debug for EntriesByPath<'a> { + impl fmt::Debug for EntriesByPath<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_map() .entries(self.0.iter().map(|entry| (&entry.path, entry.id))) @@ -3638,7 +3636,7 @@ impl fmt::Debug for Snapshot { } } - impl<'a> fmt::Debug for EntriesById<'a> { + impl fmt::Debug for EntriesById<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_list().entries(self.0.iter()).finish() } @@ -5922,7 +5920,7 @@ struct TraversalProgress<'a> { non_ignored_file_count: usize, } -impl<'a> TraversalProgress<'a> { +impl TraversalProgress<'_> { fn count(&self, include_files: bool, include_dirs: bool, include_ignored: bool) -> usize { match (include_files, include_dirs, include_ignored) { (true, true, true) => self.count, @@ -5950,7 +5948,7 @@ impl<'a> sum_tree::Dimension<'a, EntrySummary> for TraversalProgress<'a> { } } -impl<'a> Default for TraversalProgress<'a> { +impl Default for TraversalProgress<'_> { fn default() -> Self { Self { max_path: Path::new(""), @@ -5968,7 +5966,7 @@ pub struct GitEntryRef<'a> { pub git_summary: GitSummary, } -impl<'a> GitEntryRef<'a> { +impl GitEntryRef<'_> { pub fn to_owned(&self) -> GitEntry { GitEntry { entry: self.entry.clone(), @@ -5977,7 +5975,7 @@ impl<'a> GitEntryRef<'a> { } } -impl<'a> Deref for GitEntryRef<'a> { +impl Deref for GitEntryRef<'_> { type Target = Entry; fn deref(&self) -> &Self::Target { @@ -5985,7 +5983,7 @@ impl<'a> Deref for GitEntryRef<'a> { } } -impl<'a> AsRef for GitEntryRef<'a> { +impl AsRef for GitEntryRef<'_> { fn as_ref(&self) -> &Entry { self.entry } @@ -6246,7 +6244,7 @@ enum PathTarget<'a> { Successor(&'a Path), } -impl<'a> PathTarget<'a> { +impl PathTarget<'_> { fn cmp_path(&self, other: &Path) -> Ordering { match self { PathTarget::Path(path) => path.cmp(&other), @@ -6261,20 +6259,20 @@ impl<'a> PathTarget<'a> { } } -impl<'a, 'b, S: Summary> SeekTarget<'a, PathSummary, PathProgress<'a>> for PathTarget<'b> { +impl<'a, S: Summary> SeekTarget<'a, PathSummary, PathProgress<'a>> for PathTarget<'_> { fn cmp(&self, cursor_location: &PathProgress<'a>, _: &S::Context) -> Ordering { self.cmp_path(&cursor_location.max_path) } } -impl<'a, 'b, S: Summary> SeekTarget<'a, PathSummary, TraversalProgress<'a>> for PathTarget<'b> { +impl<'a, S: Summary> SeekTarget<'a, PathSummary, TraversalProgress<'a>> for PathTarget<'_> { fn cmp(&self, cursor_location: &TraversalProgress<'a>, _: &S::Context) -> Ordering { self.cmp_path(&cursor_location.max_path) } } -impl<'a, 'b> SeekTarget<'a, PathSummary, (TraversalProgress<'a>, GitSummary)> - for PathTarget<'b> +impl<'a> SeekTarget<'a, PathSummary, (TraversalProgress<'a>, GitSummary)> + for PathTarget<'_> { fn cmp(&self, cursor_location: &(TraversalProgress<'a>, GitSummary), _: &()) -> Ordering { self.cmp_path(&cursor_location.0.max_path) @@ -6317,13 +6315,13 @@ impl<'a> TraversalTarget<'a> { } } -impl<'a, 'b> SeekTarget<'a, EntrySummary, TraversalProgress<'a>> for TraversalTarget<'b> { +impl<'a> SeekTarget<'a, EntrySummary, TraversalProgress<'a>> for TraversalTarget<'_> { fn cmp(&self, cursor_location: &TraversalProgress<'a>, _: &()) -> Ordering { self.cmp_progress(cursor_location) } } -impl<'a, 'b> SeekTarget<'a, PathSummary, TraversalProgress<'a>> for TraversalTarget<'b> { +impl<'a> SeekTarget<'a, PathSummary, TraversalProgress<'a>> for TraversalTarget<'_> { fn cmp(&self, cursor_location: &TraversalProgress<'a>, _: &()) -> Ordering { self.cmp_progress(cursor_location) } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 820aa9bbc7..cf9e0ee6ea 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.81" +channel = "1.85" profile = "minimal" components = [ "rustfmt", "clippy" ] targets = [ "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "wasm32-wasip1", "x86_64-pc-windows-msvc" ]