mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
ignore redundant_pub_crate
in useless_attribute
This commit is contained in:
parent
cef882cc9d
commit
0c164bbfdb
4 changed files with 19 additions and 8 deletions
|
@ -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 a new issue