mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
useless_attribute: Update docs for allowed attributes
This commit is contained in:
@@ -61,11 +61,21 @@
|
||||
///
|
||||
/// This lint permits lint attributes for lints emitted on the items themself.
|
||||
/// For `use` items these lints are:
|
||||
/// * ambiguous_glob_reexports
|
||||
/// * dead_code
|
||||
/// * deprecated
|
||||
/// * hidden_glob_reexports
|
||||
/// * unreachable_pub
|
||||
/// * unused_imports
|
||||
/// * unused
|
||||
/// * unused_braces
|
||||
/// * unused_import_braces
|
||||
/// * clippy::disallowed_types
|
||||
/// * clippy::enum_glob_use
|
||||
/// * clippy::macro_use_imports
|
||||
/// * clippy::module_name_repetitions
|
||||
/// * clippy::redundant_pub_crate
|
||||
/// * clippy::single_component_path_imports
|
||||
/// * clippy::unsafe_removed_from_name
|
||||
/// * clippy::wildcard_imports
|
||||
///
|
||||
/// For `extern crate` items these lints are:
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
use super::{Attribute, USELESS_ATTRIBUTE};
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::source::{first_line_of_span, snippet_opt};
|
||||
use rustc_ast::NestedMetaItem;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Item, ItemKind};
|
||||
use rustc_lint::{LateContext, LintContext};
|
||||
@@ -20,31 +21,40 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
|
||||
for lint in lint_list {
|
||||
match item.kind {
|
||||
ItemKind::Use(..) => {
|
||||
if is_word(lint, sym::unused_imports)
|
||||
|| is_word(lint, sym::deprecated)
|
||||
|| is_word(lint, sym!(unreachable_pub))
|
||||
|| is_word(lint, sym!(unused))
|
||||
|| is_word(lint, sym!(unused_import_braces))
|
||||
|| is_word(lint, sym!(unused_braces))
|
||||
|| is_word(lint, sym::dead_code)
|
||||
|| is_word(lint, sym!(hidden_glob_reexports))
|
||||
|| is_word(lint, sym!(ambiguous_glob_reexports))
|
||||
|| extract_clippy_lint(lint).map_or(false, |s| {
|
||||
matches!(
|
||||
s.as_str(),
|
||||
"wildcard_imports"
|
||||
| "enum_glob_use"
|
||||
| "redundant_pub_crate"
|
||||
| "macro_use_imports"
|
||||
| "unsafe_removed_from_name"
|
||||
| "module_name_repetitions"
|
||||
| "single_component_path_imports"
|
||||
| "disallowed_types"
|
||||
)
|
||||
})
|
||||
if let NestedMetaItem::MetaItem(meta_item) = lint
|
||||
&& meta_item.is_word()
|
||||
&& let Some(ident) = meta_item.ident()
|
||||
&& matches!(
|
||||
ident.name.as_str(),
|
||||
"ambiguous_glob_reexports"
|
||||
| "dead_code"
|
||||
| "deprecated"
|
||||
| "hidden_glob_reexports"
|
||||
| "unreachable_pub"
|
||||
| "unused"
|
||||
| "unused_braces"
|
||||
| "unused_import_braces"
|
||||
| "unused_imports"
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if extract_clippy_lint(lint).is_some_and(|symbol| {
|
||||
matches!(
|
||||
symbol.as_str(),
|
||||
"wildcard_imports"
|
||||
| "enum_glob_use"
|
||||
| "redundant_pub_crate"
|
||||
| "macro_use_imports"
|
||||
| "unsafe_removed_from_name"
|
||||
| "module_name_repetitions"
|
||||
| "single_component_path_imports"
|
||||
| "disallowed_types"
|
||||
)
|
||||
}) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
ItemKind::ExternCrate(..) => {
|
||||
if is_word(lint, sym::unused_imports) && skip_unused_imports {
|
||||
|
||||
Reference in New Issue
Block a user