From 6c13e42a1d768d113c73acc8297a55970de09ce6 Mon Sep 17 00:00:00 2001 From: Jeremie Drouet Date: Wed, 15 Apr 2026 14:28:52 +0200 Subject: [PATCH] fix: filter rules by names before pushing them Signed-off-by: Jeremie Drouet --- .../crates/ide-db/src/generated/lints.rs | 7 ------- src/tools/rust-analyzer/xtask/src/codegen/lints.rs | 13 ++++++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs b/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs index be595ec0f608..af462567ff15 100644 --- a/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs +++ b/src/tools/rust-analyzer/crates/ide-db/src/generated/lints.rs @@ -1790,13 +1790,6 @@ pub struct LintGroup { warn_since: None, deny_since: None, }, - Lint { - label: "warnings", - description: r##"lint group for: all lints that are set to issue warnings"##, - default_severity: Severity::Allow, - warn_since: None, - deny_since: None, - }, ]; pub const DEFAULT_LINT_GROUPS: &[LintGroup] = &[ diff --git a/src/tools/rust-analyzer/xtask/src/codegen/lints.rs b/src/tools/rust-analyzer/xtask/src/codegen/lints.rs index 788ae8d6c1dd..c09092e74e63 100644 --- a/src/tools/rust-analyzer/xtask/src/codegen/lints.rs +++ b/src/tools/rust-analyzer/xtask/src/codegen/lints.rs @@ -3,7 +3,7 @@ #![allow(clippy::disallowed_types)] use std::{ - collections::{HashMap, hash_map}, + collections::{HashMap, HashSet, hash_map}, fs, path::Path, str::FromStr, @@ -348,10 +348,12 @@ fn get_lints( buf.push_str(r#"pub const DEFAULT_LINTS: &[Lint] = &["#); buf.push('\n'); + let mut known_lints: HashSet<&String> = HashSet::with_capacity(lints.len() + lint_groups.len()); for (name, lint) in &lints { push_lint_completion(buf, name, lint); + known_lints.insert(name); } - for (name, (group, _)) in &lint_groups { + for (name, (group, _)) in lint_groups.iter().filter(|(name, _)| !known_lints.contains(name)) { push_lint_completion(buf, name, group); } buf.push_str("];\n\n"); @@ -372,10 +374,15 @@ fn get_lints( buf.push_str(r#"pub const RUSTDOC_LINTS: &[Lint] = &["#); buf.push('\n'); + let mut known_rustdoc_lints: HashSet<&String> = + HashSet::with_capacity(lints_rustdoc.len() + lint_groups_rustdoc.len()); for (name, lint) in &lints_rustdoc { push_lint_completion(buf, name, lint); + known_rustdoc_lints.insert(name); } - for (name, (group, _)) in &lint_groups_rustdoc { + for (name, (group, _)) in + lint_groups_rustdoc.iter().filter(|(name, _)| !known_rustdoc_lints.contains(name)) + { push_lint_completion(buf, name, group); } buf.push_str("];\n\n");