Make [clippy::dump] support trait items

This commit is contained in:
xFrednet 2023-02-04 19:10:19 +01:00
parent 8a9860901f
commit c642cfe3bf
No known key found for this signature in database
GPG key ID: F5C59D0E669E5302

View file

@ -1,4 +1,5 @@
use clippy_utils::get_attr;
use hir::TraitItem;
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_session::{declare_lint_pass, declare_tool_lint};
@ -47,6 +48,18 @@ impl<'tcx> LateLintPass<'tcx> for DumpHir {
println!("{stmt:#?}");
}
}
fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) {
if has_attr(cx, item.hir_id()) {
println!("{item:#?}");
}
}
fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &hir::ImplItem<'_>) {
if has_attr(cx, item.hir_id()) {
println!("{item:#?}");
}
}
}
fn has_attr(cx: &LateContext<'_>, hir_id: hir::HirId) -> bool {