Skip to content

Commit fe57ab7

Browse files
committed
Auto merge of #9630 - CatDevz:fix-aawr-lint, r=flip1995
Fix allow_attributes_without_reason applying to external crate macros Previously the `clippy::allow_attributes_without_reason` lint would apply to external crate macros. Many macros in the Rust ecosystem include these `allow` attributes without adding a reason, making this lint pretty much unusable in any sizable Rust project. This commit fixes that by adding a check to the lint if the attribute is from an external crate macro and returning early. ``` changelog: [`allow_attributes_without_reason`]: allow_attributes_without_reason no longer applies to external crate macros ```
2 parents b97d29a + 9ebd691 commit fe57ab7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clippy_lints/src/attrs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ fn check_lint_reason(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem
464464
return;
465465
}
466466

467+
// Check if the attribute is in an external macro and therefore out of the developer's control
468+
if in_external_macro(cx.sess(), attr.span) {
469+
return;
470+
}
471+
467472
span_lint_and_help(
468473
cx,
469474
ALLOW_ATTRIBUTES_WITHOUT_REASON,

0 commit comments

Comments
 (0)