From e9761bdc015430b818ee771b2acf00a00b40bd97 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 2 May 2024 11:56:38 -0700 Subject: [PATCH] useless_attribute: allow dead_code Closes https://github.com/rust-lang/rust-clippy/issues/4467 --- clippy_lints/src/attrs/useless_attribute.rs | 1 + tests/ui/useless_attribute.fixed | 4 ++++ tests/ui/useless_attribute.rs | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/clippy_lints/src/attrs/useless_attribute.rs b/clippy_lints/src/attrs/useless_attribute.rs index 40572731b..720e4e793 100644 --- a/clippy_lints/src/attrs/useless_attribute.rs +++ b/clippy_lints/src/attrs/useless_attribute.rs @@ -26,6 +26,7 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute]) || is_word(lint, sym!(unused)) || is_word(lint, sym!(unused_import_braces)) || is_word(lint, sym!(unused_braces)) + || is_word(lint, sym!(dead_code)) || extract_clippy_lint(lint).map_or(false, |s| { matches!( s.as_str(), diff --git a/tests/ui/useless_attribute.fixed b/tests/ui/useless_attribute.fixed index cb1c03464..5fafc05cd 100644 --- a/tests/ui/useless_attribute.fixed +++ b/tests/ui/useless_attribute.fixed @@ -92,3 +92,7 @@ use module::{Struct}; fn main() { test_indented_attr(); } + +// Regression test for https://github.com/rust-lang/rust-clippy/issues/4467 +#[allow(dead_code)] +use std::collections as puppy_doggy; diff --git a/tests/ui/useless_attribute.rs b/tests/ui/useless_attribute.rs index 44a52cba0..c9de7677f 100644 --- a/tests/ui/useless_attribute.rs +++ b/tests/ui/useless_attribute.rs @@ -92,3 +92,7 @@ use module::{Struct}; fn main() { test_indented_attr(); } + +// Regression test for https://github.com/rust-lang/rust-clippy/issues/4467 +#[allow(dead_code)] +use std::collections as puppy_doggy;