Closed
Description
I was testing using per module passes (like #113734) in Clippy and saw test failures when trying clippy::allow_attributes
, it seems only inner attributes of the root crate are visited by per module late lint passes
Reproducer without having to compile clippy:
diff --git i/compiler/rustc_lint/src/for_loops_over_fallibles.rs w/compiler/rustc_lint/src/for_loops_over_fallibles.rs
index c299e38842a..47595bcba77 100644
--- i/compiler/rustc_lint/src/for_loops_over_fallibles.rs
+++ w/compiler/rustc_lint/src/for_loops_over_fallibles.rs
@@ -80,6 +80,10 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
ForLoopsOverFalliblesDiag { article, ty, sub, question_mark, suggestion },
);
}
+
+ fn check_attribute(&mut self, _: &LateContext<'_>, attr: &'_ rustc_ast::Attribute) {
+ dbg!(attr.span);
+ }
}
fn extract_for_loop<'tcx>(expr: &Expr<'tcx>) -> Option<(&'tcx Pat<'tcx>, &'tcx Expr<'tcx>)> {
Compile + run rustc on
#![warn(clippy::a)]
#[warn(clippy::b)]
pub struct B;
pub mod m {
#![warn(clippy::c)]
#[warn(clippy::d)]
pub struct D;
}
fn main() {}
You'll see only one attribute in the output
[compiler/rustc_lint/src/for_loops_over_fallibles.rs:85] attr.span = foo.rs:1:1: 1:20 (#0)
Metadata
Metadata
Assignees
Labels
No labels