From a8276eabb93759237e13d21d54f5926cbc4c666d Mon Sep 17 00:00:00 2001 From: barry3406 Date: Thu, 9 Apr 2026 20:55:33 -0700 Subject: [PATCH] fix: deduplicate `warnings` lint in completion list The `warnings` lint appeared twice in `#[allow(w` completions because it exists as both a regular lint and a lint group in `rustc -Whelp` output. The codegen concatenated both into DEFAULT_LINTS without checking for overlap. Skip lint groups whose name already appears in the regular lint list when generating DEFAULT_LINTS and RUSTDOC_LINTS. Also regenerated the lints.rs file to remove the current duplicate. Fixes rust-lang/rust-analyzer#21943 --- crates/ide-completion/src/tests/attribute.rs | 10 ++++++++++ crates/ide-db/src/generated/lints.rs | 7 ------- xtask/src/codegen/lints.rs | 8 ++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/crates/ide-completion/src/tests/attribute.rs b/crates/ide-completion/src/tests/attribute.rs index 131911be9155..911fd70a51ba 100644 --- a/crates/ide-completion/src/tests/attribute.rs +++ b/crates/ide-completion/src/tests/attribute.rs @@ -1372,6 +1372,16 @@ mod lint { r#"#[allow(rustdoc::bare_urls struct Test;"#, ); } + + #[test] + fn no_duplicate_warnings_lint() { + let completions = crate::tests::completion_list(r#"#[allow(w$0)] struct Test;"#); + let warning_count = completions.lines().filter(|line| line.contains("warnings")).count(); + assert_eq!( + warning_count, 1, + "Expected `warnings` to appear exactly once, but found {warning_count} occurrences:\n{completions}" + ); + } } mod repr { diff --git a/crates/ide-db/src/generated/lints.rs b/crates/ide-db/src/generated/lints.rs index 9e6d58600888..949cc440f02b 100644 --- a/crates/ide-db/src/generated/lints.rs +++ b/crates/ide-db/src/generated/lints.rs @@ -1608,13 +1608,6 @@ pub const DEFAULT_LINTS: &[Lint] = &[ 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/xtask/src/codegen/lints.rs b/xtask/src/codegen/lints.rs index 3b4c2e8da3c3..360ed3276650 100644 --- a/xtask/src/codegen/lints.rs +++ b/xtask/src/codegen/lints.rs @@ -352,7 +352,9 @@ fn generate_lint_descriptor(sh: &Shell, buf: &mut String) { push_lint_completion(buf, name, lint); } for (name, (group, _)) in &lint_groups { - push_lint_completion(buf, name, group); + if !lints.iter().any(|(n, _)| n == name) { + push_lint_completion(buf, name, group); + } } buf.push_str("];\n\n"); @@ -376,7 +378,9 @@ fn generate_lint_descriptor(sh: &Shell, buf: &mut String) { push_lint_completion(buf, name, lint); } for (name, (group, _)) in &lint_groups_rustdoc { - push_lint_completion(buf, name, group); + if !lints_rustdoc.iter().any(|(n, _)| n == name) { + push_lint_completion(buf, name, group); + } } buf.push_str("];\n\n");