From 33a67ad6b926f0de7e9632d1ee89d8c07e19e1ae Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:53:17 +0200 Subject: [PATCH] chore: Clippy fixes for 1.80 (#13987) The biggest hurdle turned out to be use of `Arc` in maps, as `clippy::mutable_key_type` started triggering on it (due to - I suppose - internal mutability on `HighlightMap`?). I switched over to using `LanguageId` as the key type in some of the callsites, as that's what `Language` uses anyways for it's hash/eq, though I've still had to suppress the lint outside of language crate. /cc @maxdeviant , le clippy guru. Release Notes: - N/A --- Cargo.toml | 2 +- crates/collab/src/db/tests/db_tests.rs | 2 +- crates/editor/src/editor.rs | 1 + crates/gpui/build.rs | 2 +- crates/gpui/src/text_system.rs | 20 -------------------- crates/language/src/syntax_map.rs | 11 ++++++----- crates/project/src/project.rs | 2 ++ crates/project/src/task_inventory.rs | 5 ----- 8 files changed, 12 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a3772d799d..aa665f6897 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -518,7 +518,7 @@ single_range_in_vec_init = "allow" # There are a bunch of rules currently failing in the `style` group, so # allow all of those, for now. -style = "allow" +style = { level = "allow", priority = -1 } # Individual rules that have violations in the codebase: almost_complete_range = "allow" diff --git a/crates/collab/src/db/tests/db_tests.rs b/crates/collab/src/db/tests/db_tests.rs index 92baf29837..4f9bb035fb 100644 --- a/crates/collab/src/db/tests/db_tests.rs +++ b/crates/collab/src/db/tests/db_tests.rs @@ -562,7 +562,7 @@ fn test_fuzzy_like_string() { assert_eq!(Database::fuzzy_like_string(" z "), "%z%"); } -#[cfg(target = "macos")] +#[cfg(target_os = "macos")] #[gpui::test] async fn test_fuzzy_search_users(cx: &mut gpui::TestAppContext) { let test_db = tests::TestDb::postgres(cx.executor()); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 73e97448f8..4c5aab6ebe 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -11093,6 +11093,7 @@ impl Editor { if *singleton_buffer_edited { if let Some(project) = &self.project { let project = project.read(cx); + #[allow(clippy::mutable_key_type)] let languages_affected = multibuffer .read(cx) .all_buffers() diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index 0808288e59..56fca5f7e8 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -7,7 +7,7 @@ use std::env; fn main() { let target = env::var("CARGO_CFG_TARGET_OS"); - + println!("cargo::rustc-check-cfg=cfg(gles)"); match target.as_deref() { Ok("macos") => { #[cfg(target_os = "macos")] diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rs index 5a414c216c..b884e2ef93 100644 --- a/crates/gpui/src/text_system.rs +++ b/crates/gpui/src/text_system.rs @@ -658,26 +658,6 @@ impl Hash for RenderGlyphParams { } } -/// The parameters for rendering an emoji glyph. -#[derive(Clone, Debug, PartialEq)] -pub struct RenderEmojiParams { - pub(crate) font_id: FontId, - pub(crate) glyph_id: GlyphId, - pub(crate) font_size: Pixels, - pub(crate) scale_factor: f32, -} - -impl Eq for RenderEmojiParams {} - -impl Hash for RenderEmojiParams { - fn hash(&self, state: &mut H) { - self.font_id.0.hash(state); - self.glyph_id.0.hash(state); - self.font_size.0.to_bits().hash(state); - self.scale_factor.to_bits().hash(state); - } -} - /// The configuration details for identifying a specific font. #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Font { diff --git a/crates/language/src/syntax_map.rs b/crates/language/src/syntax_map.rs index 92c9d52a7a..cdc6d14259 100644 --- a/crates/language/src/syntax_map.rs +++ b/crates/language/src/syntax_map.rs @@ -1207,7 +1207,7 @@ fn get_injections( language_registry: &Arc, depth: usize, changed_ranges: &[Range], - combined_injection_ranges: &mut HashMap, Vec>, + combined_injection_ranges: &mut HashMap, Vec)>, queue: &mut BinaryHeap, ) { let mut query_cursor = QueryCursorHandle::new(); @@ -1223,7 +1223,7 @@ fn get_injections( .now_or_never() .and_then(|language| language.ok()) { - combined_injection_ranges.insert(language, Vec::new()); + combined_injection_ranges.insert(language.id, (language, Vec::new())); } } } @@ -1276,8 +1276,9 @@ fn get_injections( if let Some(language) = language { if combined { combined_injection_ranges - .entry(language.clone()) - .or_default() + .entry(language.id) + .or_insert_with(|| (language.clone(), vec![])) + .1 .extend(content_ranges); } else { queue.push(ParseStep { @@ -1303,7 +1304,7 @@ fn get_injections( } } - for (language, mut included_ranges) in combined_injection_ranges.drain() { + for (_, (language, mut included_ranges)) in combined_injection_ranges.drain() { included_ranges.sort_unstable_by(|a, b| { Ord::cmp(&a.start_byte, &b.start_byte).then_with(|| Ord::cmp(&a.end_byte, &b.end_byte)) }); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 4d99454299..80edc90659 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -4106,6 +4106,7 @@ impl Project { return; } + #[allow(clippy::mutable_key_type)] let language_server_lookup_info: HashSet<(Model, Arc)> = buffers .into_iter() .filter_map(|buffer| { @@ -11066,6 +11067,7 @@ async fn populate_labels_for_symbols( lsp_adapter: Option>, output: &mut Vec, ) { + #[allow(clippy::mutable_key_type)] let mut symbols_by_language = HashMap::>, Vec>::default(); let mut unknown_path = None; diff --git a/crates/project/src/task_inventory.rs b/crates/project/src/task_inventory.rs index ac3f93201c..b544361739 100644 --- a/crates/project/src/task_inventory.rs +++ b/crates/project/src/task_inventory.rs @@ -444,11 +444,6 @@ mod test_inventory { use super::{task_source_kind_preference, TaskSourceKind, UnboundedSender}; - #[derive(Debug, Clone, PartialEq, Eq)] - pub struct TestTask { - name: String, - } - pub(super) fn static_test_source( task_names: impl IntoIterator, updates: UnboundedSender<()>,