chore: Clippy fixes for 1.80 (#13987)

The biggest hurdle turned out to be use of `Arc<Language>` 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
This commit is contained in:
Piotr Osiewicz 2024-07-10 17:53:17 +02:00 committed by GitHub
parent d4ddc4c62c
commit 33a67ad6b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 12 additions and 33 deletions

View File

@ -518,7 +518,7 @@ single_range_in_vec_init = "allow"
# There are a bunch of rules currently failing in the `style` group, so # There are a bunch of rules currently failing in the `style` group, so
# allow all of those, for now. # allow all of those, for now.
style = "allow" style = { level = "allow", priority = -1 }
# Individual rules that have violations in the codebase: # Individual rules that have violations in the codebase:
almost_complete_range = "allow" almost_complete_range = "allow"

View File

@ -562,7 +562,7 @@ fn test_fuzzy_like_string() {
assert_eq!(Database::fuzzy_like_string(" z "), "%z%"); assert_eq!(Database::fuzzy_like_string(" z "), "%z%");
} }
#[cfg(target = "macos")] #[cfg(target_os = "macos")]
#[gpui::test] #[gpui::test]
async fn test_fuzzy_search_users(cx: &mut gpui::TestAppContext) { async fn test_fuzzy_search_users(cx: &mut gpui::TestAppContext) {
let test_db = tests::TestDb::postgres(cx.executor()); let test_db = tests::TestDb::postgres(cx.executor());

View File

@ -11093,6 +11093,7 @@ impl Editor {
if *singleton_buffer_edited { if *singleton_buffer_edited {
if let Some(project) = &self.project { if let Some(project) = &self.project {
let project = project.read(cx); let project = project.read(cx);
#[allow(clippy::mutable_key_type)]
let languages_affected = multibuffer let languages_affected = multibuffer
.read(cx) .read(cx)
.all_buffers() .all_buffers()

View File

@ -7,7 +7,7 @@ use std::env;
fn main() { fn main() {
let target = env::var("CARGO_CFG_TARGET_OS"); let target = env::var("CARGO_CFG_TARGET_OS");
println!("cargo::rustc-check-cfg=cfg(gles)");
match target.as_deref() { match target.as_deref() {
Ok("macos") => { Ok("macos") => {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]

View File

@ -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<H: Hasher>(&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. /// The configuration details for identifying a specific font.
#[derive(Clone, Debug, Eq, PartialEq, Hash)] #[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Font { pub struct Font {

View File

@ -1207,7 +1207,7 @@ fn get_injections(
language_registry: &Arc<LanguageRegistry>, language_registry: &Arc<LanguageRegistry>,
depth: usize, depth: usize,
changed_ranges: &[Range<usize>], changed_ranges: &[Range<usize>],
combined_injection_ranges: &mut HashMap<Arc<Language>, Vec<tree_sitter::Range>>, combined_injection_ranges: &mut HashMap<LanguageId, (Arc<Language>, Vec<tree_sitter::Range>)>,
queue: &mut BinaryHeap<ParseStep>, queue: &mut BinaryHeap<ParseStep>,
) { ) {
let mut query_cursor = QueryCursorHandle::new(); let mut query_cursor = QueryCursorHandle::new();
@ -1223,7 +1223,7 @@ fn get_injections(
.now_or_never() .now_or_never()
.and_then(|language| language.ok()) .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 let Some(language) = language {
if combined { if combined {
combined_injection_ranges combined_injection_ranges
.entry(language.clone()) .entry(language.id)
.or_default() .or_insert_with(|| (language.clone(), vec![]))
.1
.extend(content_ranges); .extend(content_ranges);
} else { } else {
queue.push(ParseStep { 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| { 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)) Ord::cmp(&a.start_byte, &b.start_byte).then_with(|| Ord::cmp(&a.end_byte, &b.end_byte))
}); });

View File

@ -4106,6 +4106,7 @@ impl Project {
return; return;
} }
#[allow(clippy::mutable_key_type)]
let language_server_lookup_info: HashSet<(Model<Worktree>, Arc<Language>)> = buffers let language_server_lookup_info: HashSet<(Model<Worktree>, Arc<Language>)> = buffers
.into_iter() .into_iter()
.filter_map(|buffer| { .filter_map(|buffer| {
@ -11066,6 +11067,7 @@ async fn populate_labels_for_symbols(
lsp_adapter: Option<Arc<CachedLspAdapter>>, lsp_adapter: Option<Arc<CachedLspAdapter>>,
output: &mut Vec<Symbol>, output: &mut Vec<Symbol>,
) { ) {
#[allow(clippy::mutable_key_type)]
let mut symbols_by_language = HashMap::<Option<Arc<Language>>, Vec<CoreSymbol>>::default(); let mut symbols_by_language = HashMap::<Option<Arc<Language>>, Vec<CoreSymbol>>::default();
let mut unknown_path = None; let mut unknown_path = None;

View File

@ -444,11 +444,6 @@ mod test_inventory {
use super::{task_source_kind_preference, TaskSourceKind, UnboundedSender}; use super::{task_source_kind_preference, TaskSourceKind, UnboundedSender};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TestTask {
name: String,
}
pub(super) fn static_test_source( pub(super) fn static_test_source(
task_names: impl IntoIterator<Item = String>, task_names: impl IntoIterator<Item = String>,
updates: UnboundedSender<()>, updates: UnboundedSender<()>,