Skip to content

Commit 18a1831

Browse files
committed
Auto merge of rust-lang#8743 - Alexendoo:useless-attribute-redundant-pub-crate, r=llogiq
ignore `redundant_pub_crate` in `useless_attribute` changelog: [`useless_attribute`] no longer lints [`redundant_pub_crate`] As mentioned in rust-lang/rust-clippy#8732 (comment) > And it turns out I can't even explicitly allow it at the usage site, because then `clippy::useless_attribute` fires (which would also be a FP?), which is deny-by-default. > > Though it does work if I then allow `clippy::useless_attribute`. 😂 > > ```rust > #[allow(clippy::useless_attribute)] > #[allow(clippy::redundant_pub_crate)] > pub(crate) use bit; > ``` > > The originally-reported warning now no longer occurs.
2 parents 95396f6 + 0c164bb commit 18a1831

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

clippy_lints/src/attrs.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,20 +335,19 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
335335
}
336336
if let Some(lint_list) = &attr.meta_item_list() {
337337
if attr.ident().map_or(false, |ident| is_lint_level(ident.name)) {
338-
// permit `unused_imports`, `deprecated`, `unreachable_pub`,
339-
// `clippy::wildcard_imports`, and `clippy::enum_glob_use` for `use` items
340-
// and `unused_imports` for `extern crate` items with `macro_use`
341338
for lint in lint_list {
342339
match item.kind {
343340
ItemKind::Use(..) => {
344341
if is_word(lint, sym!(unused_imports))
345342
|| is_word(lint, sym::deprecated)
346343
|| is_word(lint, sym!(unreachable_pub))
347344
|| is_word(lint, sym!(unused))
348-
|| extract_clippy_lint(lint)
349-
.map_or(false, |s| s.as_str() == "wildcard_imports")
350-
|| extract_clippy_lint(lint)
351-
.map_or(false, |s| s.as_str() == "enum_glob_use")
345+
|| extract_clippy_lint(lint).map_or(false, |s| {
346+
matches!(
347+
s.as_str(),
348+
"wildcard_imports" | "enum_glob_use" | "redundant_pub_crate",
349+
)
350+
})
352351
{
353352
return;
354353
}

tests/ui/useless_attribute.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ pub use std::io::prelude::*;
5757
#[allow(clippy::enum_glob_use)]
5858
pub use std::cmp::Ordering::*;
5959

60+
// don't lint on clippy::redundant_pub_crate
61+
mod c {
62+
#[allow(clippy::redundant_pub_crate)]
63+
pub(crate) struct S;
64+
}
65+
6066
fn test_indented_attr() {
6167
#![allow(clippy::almost_swapped)]
6268
use std::collections::HashSet;

tests/ui/useless_attribute.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ pub use std::io::prelude::*;
5757
#[allow(clippy::enum_glob_use)]
5858
pub use std::cmp::Ordering::*;
5959

60+
// don't lint on clippy::redundant_pub_crate
61+
mod c {
62+
#[allow(clippy::redundant_pub_crate)]
63+
pub(crate) struct S;
64+
}
65+
6066
fn test_indented_attr() {
6167
#[allow(clippy::almost_swapped)]
6268
use std::collections::HashSet;

tests/ui/useless_attribute.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
1414

1515
error: useless lint attribute
16-
--> $DIR/useless_attribute.rs:61:5
16+
--> $DIR/useless_attribute.rs:67:5
1717
|
1818
LL | #[allow(clippy::almost_swapped)]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]`

0 commit comments

Comments
 (0)