Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Clippy fixes for 1.80 #13987

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, what does priority = -1 do here?

Copy link
Contributor Author

@osiewicz osiewicz Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR:

error: lint group `style` has the same priority (0) as a lint
   --> Cargo.toml:521:1
    |
521 | style = { level = "allow"}
    | ^^^^^   ------------------ has an implicit priority of 0
...
524 | almost_complete_range = "allow"
    | --------------------- has the same priority as this lint
    |
    = note: the order of the lints in the table is ignored by Cargo
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lint_groups_priority
    = note: `#[deny(clippy::lint_groups_priority)]` on by default
help: to have lints override the group set `style` to a lower priority
    |
521 | style = { level = "allow", priority = -1 }

So in short, it seems that it explicitly gives style group lower priority, in case other items in the lints table wanted to override a single/several item from it. It's a bit silly, because we do not opt into style lints, but that's probably on the lint implementation and not on us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like in the lint implementation, they simply look for a group specifier (style) and any other specifier (almost_complete_range) that has the same priority.
https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/cargo/lint_groups_priority.rs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! That's good to know.


# Individual rules that have violations in the codebase:
almost_complete_range = "allow"
Expand Down
2 changes: 1 addition & 1 deletion crates/collab/src/db/tests/db_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11094,6 11094,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()
Expand Down
2 changes: 1 addition & 1 deletion crates/gpui/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
20 changes: 0 additions & 20 deletions crates/gpui/src/text_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Font {
Expand Down
11 changes: 6 additions & 5 deletions crates/language/src/syntax_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 1207,7 @@ fn get_injections(
language_registry: &Arc<LanguageRegistry>,
depth: 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>,
) {
let mut query_cursor = QueryCursorHandle::new();
Expand All @@ -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()));
}
}
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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))
});
Expand Down
2 changes: 2 additions & 0 deletions crates/project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4076,6 4076,7 @@ impl Project {
return;
}

#[allow(clippy::mutable_key_type)]
let language_server_lookup_info: HashSet<(Model<Worktree>, Arc<Language>)> = buffers
.into_iter()
.filter_map(|buffer| {
Expand Down Expand Up @@ -11035,6 11036,7 @@ async fn populate_labels_for_symbols(
lsp_adapter: Option<Arc<CachedLspAdapter>>,
output: &mut Vec<Symbol>,
) {
#[allow(clippy::mutable_key_type)]
let mut symbols_by_language = HashMap::<Option<Arc<Language>>, Vec<CoreSymbol>>::default();

let mut unknown_path = None;
Expand Down
5 changes: 0 additions & 5 deletions crates/project/src/task_inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item = String>,
updates: UnboundedSender<()>,
Expand Down
Loading