1
Fork 0

Add checks for more empty attributes.

This commit is contained in:
Eric Huss 2021-09-05 17:16:28 -07:00
parent 67a5b193c1
commit 4c60ea8228
7 changed files with 255 additions and 120 deletions

View file

@ -173,8 +173,17 @@ impl CheckAttrVisitor<'tcx> {
}
// Warn on useless empty attributes.
if matches!(attr.name_or_empty(), sym::macro_use)
&& attr.meta_item_list().map_or(false, |list| list.is_empty())
if matches!(
attr.name_or_empty(),
sym::macro_use
| sym::allow
| sym::warn
| sym::deny
| sym::forbid
| sym::feature
| sym::repr
| sym::target_feature
) && attr.meta_item_list().map_or(false, |list| list.is_empty())
{
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
lint.build("unused attribute")