Skip to content

Commit 5adeebf

Browse files
committed
Auto merge of rust-lang#10292 - xFrednet:0000-support-trait-item-in-dump, r=flip1995
Make `[clippy::dump]` support trait items Roses are red, violets are blue, trait items are rare, `[clippy::dump]` is too --- Let's just ignore the horrible poem... anyways. While working on Marker I noticed, that `[clippy::dump]` doesn't work on trait item (See [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e2d9791ffa2872e7c09a9dfbd470350c)). This simply adds support for that. `[clippy::dump]` doesn't have UI tests, to make it more resistant to changes in the AST. I tested it locally and the dump works after these changes. --- changelog: none
2 parents fd2d8be + c642cfe commit 5adeebf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clippy_lints/src/utils/dump_hir.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clippy_utils::get_attr;
2+
use hir::TraitItem;
23
use rustc_hir as hir;
34
use rustc_lint::{LateContext, LateLintPass, LintContext};
45
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -47,6 +48,18 @@ impl<'tcx> LateLintPass<'tcx> for DumpHir {
4748
println!("{stmt:#?}");
4849
}
4950
}
51+
52+
fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &TraitItem<'_>) {
53+
if has_attr(cx, item.hir_id()) {
54+
println!("{item:#?}");
55+
}
56+
}
57+
58+
fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &hir::ImplItem<'_>) {
59+
if has_attr(cx, item.hir_id()) {
60+
println!("{item:#?}");
61+
}
62+
}
5063
}
5164

5265
fn has_attr(cx: &LateContext<'_>, hir_id: hir::HirId) -> bool {

0 commit comments

Comments
 (0)