mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 17:48:10 +00:00
Auto merge of #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 https://github.com/rust-lang/rust-clippy/issues/8732#issuecomment-1106489634 > 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.
This commit is contained in:
commit
18a1831377
@ -335,9 +335,6 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
|
||||
}
|
||||
if let Some(lint_list) = &attr.meta_item_list() {
|
||||
if attr.ident().map_or(false, |ident| is_lint_level(ident.name)) {
|
||||
// permit `unused_imports`, `deprecated`, `unreachable_pub`,
|
||||
// `clippy::wildcard_imports`, and `clippy::enum_glob_use` for `use` items
|
||||
// and `unused_imports` for `extern crate` items with `macro_use`
|
||||
for lint in lint_list {
|
||||
match item.kind {
|
||||
ItemKind::Use(..) => {
|
||||
@ -345,10 +342,12 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
|
||||
|| is_word(lint, sym::deprecated)
|
||||
|| is_word(lint, sym!(unreachable_pub))
|
||||
|| is_word(lint, sym!(unused))
|
||||
|| extract_clippy_lint(lint)
|
||||
.map_or(false, |s| s.as_str() == "wildcard_imports")
|
||||
|| extract_clippy_lint(lint)
|
||||
.map_or(false, |s| s.as_str() == "enum_glob_use")
|
||||
|| extract_clippy_lint(lint).map_or(false, |s| {
|
||||
matches!(
|
||||
s.as_str(),
|
||||
"wildcard_imports" | "enum_glob_use" | "redundant_pub_crate",
|
||||
)
|
||||
})
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -57,6 +57,12 @@ pub use std::io::prelude::*;
|
||||
#[allow(clippy::enum_glob_use)]
|
||||
pub use std::cmp::Ordering::*;
|
||||
|
||||
// don't lint on clippy::redundant_pub_crate
|
||||
mod c {
|
||||
#[allow(clippy::redundant_pub_crate)]
|
||||
pub(crate) struct S;
|
||||
}
|
||||
|
||||
fn test_indented_attr() {
|
||||
#![allow(clippy::almost_swapped)]
|
||||
use std::collections::HashSet;
|
||||
|
@ -57,6 +57,12 @@ pub use std::io::prelude::*;
|
||||
#[allow(clippy::enum_glob_use)]
|
||||
pub use std::cmp::Ordering::*;
|
||||
|
||||
// don't lint on clippy::redundant_pub_crate
|
||||
mod c {
|
||||
#[allow(clippy::redundant_pub_crate)]
|
||||
pub(crate) struct S;
|
||||
}
|
||||
|
||||
fn test_indented_attr() {
|
||||
#[allow(clippy::almost_swapped)]
|
||||
use std::collections::HashSet;
|
||||
|
@ -13,7 +13,7 @@ LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
|
||||
|
||||
error: useless lint attribute
|
||||
--> $DIR/useless_attribute.rs:61:5
|
||||
--> $DIR/useless_attribute.rs:67:5
|
||||
|
|
||||
LL | #[allow(clippy::almost_swapped)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::almost_swapped)]`
|
||||
|
Loading…
Reference in New Issue
Block a user