Skip to content

Commit 4b6fdb4

Browse files
committed
Auto merge of #10683 - Centri3:allow-attributes, r=Alexendoo
Fix false positive in `allow_attributes` This would emit a warning if used in a proc-macro with the feature `lint_reasons` enabled. This is now fixed. changelog: [`allow_attributes`]: Don't lint if in external macro
2 parents 5161c4c + 3045998 commit 4b6fdb4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clippy_lints/src/allow_attributes.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use ast::AttrStyle;
22
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use rustc_ast as ast;
44
use rustc_errors::Applicability;
5-
use rustc_lint::{LateContext, LateLintPass};
5+
use rustc_lint::{LateContext, LateLintPass, LintContext};
6+
use rustc_middle::lint::in_external_macro;
67
use rustc_session::{declare_lint_pass, declare_tool_lint};
78

89
declare_clippy_lint! {
@@ -51,6 +52,7 @@ impl LateLintPass<'_> for AllowAttribute {
5152
// Separate each crate's features.
5253
fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &ast::Attribute) {
5354
if_chain! {
55+
if !in_external_macro(cx.sess(), attr.span);
5456
if cx.tcx.features().lint_reasons;
5557
if let AttrStyle::Outer = attr.style;
5658
if let Some(ident) = attr.ident();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![warn(clippy::allow_attributes)]
2+
#![feature(lint_reasons)]
3+
#![crate_type = "proc-macro"]
4+
5+
fn main() {}

0 commit comments

Comments
 (0)