From 377e24b798a9b99237a53de26489be46ba519545 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:46:53 +0200 Subject: [PATCH] chore: Fix clippy for upcoming 1.79 Rust release (#12727) 1.79 is due for release in a week. Release Notes: - N/A --- crates/collab/src/tests/randomized_test_helpers.rs | 2 -- crates/color/src/color.rs | 8 ++++---- crates/editor/src/hover_links.rs | 2 -- crates/editor/src/hover_popover.rs | 3 +-- crates/gpui/src/platform/mac/display_link.rs | 2 +- crates/gpui/src/taffy.rs | 4 +++- crates/language/src/syntax_map.rs | 10 ++++++---- crates/project/src/project.rs | 4 ++-- crates/project/src/project_settings.rs | 1 + crates/project/src/project_tests.rs | 2 +- crates/workspace/src/workspace.rs | 3 +-- 11 files changed, 20 insertions(+), 21 deletions(-) diff --git a/crates/collab/src/tests/randomized_test_helpers.rs b/crates/collab/src/tests/randomized_test_helpers.rs index 80ff9fe5d5..c788dd28e0 100644 --- a/crates/collab/src/tests/randomized_test_helpers.rs +++ b/crates/collab/src/tests/randomized_test_helpers.rs @@ -69,7 +69,6 @@ struct TestPlan { pub struct UserTestPlan { pub user_id: UserId, pub username: String, - pub allow_client_reconnection: bool, pub allow_client_disconnection: bool, next_root_id: usize, operation_ix: usize, @@ -237,7 +236,6 @@ impl TestPlan { next_root_id: 0, operation_ix: 0, allow_client_disconnection, - allow_client_reconnection, }); } diff --git a/crates/color/src/color.rs b/crates/color/src/color.rs index 49bdc53fd1..750d6f8cd6 100644 --- a/crates/color/src/color.rs +++ b/crates/color/src/color.rs @@ -129,10 +129,10 @@ where impl Clamp for RGBAColor { fn clamp(self) -> Self { RGBAColor { - r: self.r.min(1.0).max(0.0), - g: self.g.min(1.0).max(0.0), - b: self.b.min(1.0).max(0.0), - a: self.a.min(1.0).max(0.0), + r: self.r.clamp(0., 1.), + g: self.g.clamp(0., 1.), + b: self.b.clamp(0., 1.), + a: self.a.clamp(0., 1.), } } } diff --git a/crates/editor/src/hover_links.rs b/crates/editor/src/hover_links.rs index 8a893f8bc9..88798cba68 100644 --- a/crates/editor/src/hover_links.rs +++ b/crates/editor/src/hover_links.rs @@ -322,7 +322,6 @@ pub fn update_inlay_link_and_hover_points( hover_popover::hover_at_inlay( editor, InlayHover { - excerpt: excerpt_id, tooltip: match tooltip { InlayHintTooltip::String(text) => HoverBlock { text, @@ -370,7 +369,6 @@ pub fn update_inlay_link_and_hover_points( hover_popover::hover_at_inlay( editor, InlayHover { - excerpt: excerpt_id, tooltip: match tooltip { InlayHintLabelPartTooltip::String(text) => { HoverBlock { diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rs index 6ce4afb17c..e0351cc2ed 100644 --- a/crates/editor/src/hover_popover.rs +++ b/crates/editor/src/hover_popover.rs @@ -3,7 +3,7 @@ use crate::{ hover_links::{InlayHighlight, RangeInEditor}, scroll::ScrollAmount, Anchor, AnchorRangeExt, DisplayPoint, DisplayRow, Editor, EditorSettings, EditorSnapshot, - EditorStyle, ExcerptId, Hover, RangeToAnchorExt, + EditorStyle, Hover, RangeToAnchorExt, }; use futures::{stream::FuturesUnordered, FutureExt}; use gpui::{ @@ -49,7 +49,6 @@ pub fn hover_at(editor: &mut Editor, anchor: Option, cx: &mut ViewContex } pub struct InlayHover { - pub excerpt: ExcerptId, pub range: InlayHighlight, pub tooltip: HoverBlock, } diff --git a/crates/gpui/src/platform/mac/display_link.rs b/crates/gpui/src/platform/mac/display_link.rs index 782c34486d..000db5ac94 100644 --- a/crates/gpui/src/platform/mac/display_link.rs +++ b/crates/gpui/src/platform/mac/display_link.rs @@ -201,7 +201,7 @@ mod sys { #[link(name = "CoreFoundation", kind = "framework")] #[link(name = "CoreVideo", kind = "framework")] - #[allow(improper_ctypes)] + #[allow(improper_ctypes, unknown_lints, clippy::duplicated_attributes)] extern "C" { pub fn CVDisplayLinkCreateWithActiveCGDisplays( display_link_out: *mut *mut CVDisplayLink, diff --git a/crates/gpui/src/taffy.rs b/crates/gpui/src/taffy.rs index 16f887414e..50086f778f 100644 --- a/crates/gpui/src/taffy.rs +++ b/crates/gpui/src/taffy.rs @@ -63,7 +63,9 @@ impl TaffyLayoutEngine { let parent_id = self .taffy // This is safe because LayoutId is repr(transparent) to taffy::tree::NodeId. - .new_with_children(taffy_style, unsafe { std::mem::transmute(children) }) + .new_with_children(taffy_style, unsafe { + std::mem::transmute::<&[LayoutId], &[taffy::NodeId]>(children) + }) .expect(EXPECT_MESSAGE) .into(); self.children_to_parents diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 765ff33096..92c9d52a7a 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -48,7 +48,6 @@ pub struct SyntaxMapMatches<'a> { #[derive(Debug)] pub struct SyntaxMapCapture<'a> { - pub depth: usize, pub node: Node<'a>, pub index: u32, pub grammar_index: usize, @@ -886,7 +885,9 @@ impl<'a> SyntaxMapCaptures<'a> { // TODO - add a Tree-sitter API to remove the need for this. let cursor = unsafe { - std::mem::transmute::<_, &'static mut QueryCursor>(query_cursor.deref_mut()) + std::mem::transmute::<&mut tree_sitter::QueryCursor, &'static mut QueryCursor>( + query_cursor.deref_mut(), + ) }; cursor.set_byte_range(range.clone()); @@ -933,7 +934,6 @@ impl<'a> SyntaxMapCaptures<'a> { let layer = self.layers[..self.active_layer_count].first()?; let capture = layer.next_capture?; Some(SyntaxMapCapture { - depth: layer.depth, grammar_index: layer.grammar_index, index: capture.index, node: capture.node, @@ -1004,7 +1004,9 @@ impl<'a> SyntaxMapMatches<'a> { // TODO - add a Tree-sitter API to remove the need for this. let cursor = unsafe { - std::mem::transmute::<_, &'static mut QueryCursor>(query_cursor.deref_mut()) + std::mem::transmute::<&mut tree_sitter::QueryCursor, &'static mut QueryCursor>( + query_cursor.deref_mut(), + ) }; cursor.set_byte_range(range.clone()); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 0a3152401f..2255efb4f7 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -10282,7 +10282,7 @@ impl Project { fn deserialize_symbol(serialized_symbol: proto::Symbol) -> Result { let source_worktree_id = WorktreeId::from_proto(serialized_symbol.source_worktree_id); let worktree_id = WorktreeId::from_proto(serialized_symbol.worktree_id); - let kind = unsafe { mem::transmute(serialized_symbol.kind) }; + let kind = unsafe { mem::transmute::(serialized_symbol.kind) }; let path = ProjectPath { worktree_id, path: PathBuf::from(serialized_symbol.path).into(), @@ -11393,7 +11393,7 @@ fn serialize_symbol(symbol: &Symbol) -> proto::Symbol { worktree_id: symbol.path.worktree_id.to_proto(), path: symbol.path.path.to_string_lossy().to_string(), name: symbol.name.clone(), - kind: unsafe { mem::transmute(symbol.kind) }, + kind: unsafe { mem::transmute::(symbol.kind) }, start: Some(proto::PointUtf16 { row: symbol.range.start.0.row, column: symbol.range.start.0.column, diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index ed32b11dd4..c852833c98 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -38,6 +38,7 @@ pub struct GitSettings { impl GitSettings { pub fn inline_blame_enabled(&self) -> bool { + #[allow(unknown_lints, clippy::manual_unwrap_or_default)] match self.inline_blame { Some(InlineBlameSettings { enabled, .. }) => enabled, _ => false, diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index 3562366096..843a69e9f6 100644 --- a/crates/project/src/project_tests.rs +++ b/crates/project/src/project_tests.rs @@ -1295,7 +1295,7 @@ async fn test_restarting_server_with_diagnostics_running(cx: &mut gpui::TestAppC project .language_servers_running_disk_based_diagnostics() .collect::>(), - [LanguageServerId(0); 0] + [] as [language::LanguageServerId; 0] ); }); } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index d4989d0d58..feafc07406 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -3969,8 +3969,7 @@ impl Workspace { fn adjust_padding(padding: Option) -> f32 { padding .unwrap_or(Self::DEFAULT_PADDING) - .min(Self::MAX_PADDING) - .max(0.0) + .clamp(0.0, Self::MAX_PADDING) } }